pccardctl: fix prod_id parsing and formatting
Commit f31a75997f33 broke prod_id crc32 parsing and formatting, as
it depends on the output string being _exactly_ as what the kernel
provides internally -- i.e., without a linebreak at the end.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
diff --git a/src/pccardctl.c b/src/pccardctl.c
index c3df55d..d5d67fb 100644
--- a/src/pccardctl.c
+++ b/src/pccardctl.c
@@ -154,11 +154,21 @@
const char *in_file, char **output)
{
char file[SYSFS_PATH_MAX];
+ int ret;
snprintf(file, SYSFS_PATH_MAX, "/sys/bus/pcmcia/devices/%lu.0/%s",
socket_no, in_file);
- return sysfs_read_whole_file(file, output);
+ ret = sysfs_read_whole_file(file, output);
+
+ if (ret)
+ return ret;
+
+ /* remove trailing '\n', as it messes up formatting and crc32 */
+ if ((strlen(*output) > 2) && ((*output)[strlen(*output) - 1] == '\n'))
+ (*output)[strlen(*output) - 1] = '\0';
+
+ return 0;
}
static int pccardctl_get_one_f(unsigned long socket_no, unsigned int dev,