16 Commits
Author SHA1 Message Date
Enrico Jorns 8ac394dd9c mmc-utils: do not hide CID manufacturer information
Reading the MID just to convert it to 'Unlisted' is quite unhelpful for
an info command.
Due to the (constantly increasing) amount of valid MIDs it is quite
unlikely to we have it in the database already anyway.

Thus simply always print the manufacturer ID as 0xNN and understand the
manufacturer name as an additional information held in parenthesis.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20230522214818.2038252-3-ejo@pengutronix.de
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-05-24 14:54:22 +02:00
Enrico Jorns 78af8638c2 mmc-utils: fix printing OID for mmc in non-verbose mode
It is parsed as an integer and printed as a char which does not really
make sense.
E.g. if OID is '0' (which does not seem to be uncommon), then this
prints a '\0' character and makes output nearly unreadable/unparsable.

Also, do not print it like it would be a string, instead use 0x<digit>
format.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20230522214818.2038252-2-ejo@pengutronix.de
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-05-24 14:54:22 +02:00
Enrico Jorns 36bcb85951 mmc-utils: add SanDisk to manufacturer database
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Acked-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20230522214818.2038252-1-ejo@pengutronix.de
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-05-24 14:54:22 +02:00
Avri Altman dfc3b6ecda mmc-utils: Fix a typo for ATP mid
Manufacturer id 0x44 is assign to ATP by 3c-LLC, and not to SanDisk.
mmc-utils inherited this typo when lsmmc got merged into it.

Reported-by: Mark Kanczak <Markk@us.atpinc.com>
Fixes: 4af1749d23 (mmc-utils: Merge the lsmmc tool into mmc-utils)
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220927084317.138-1-avri.altman@wdc.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-09-27 14:16:03 +02:00
Michael Heimpold 7769a4d7ab mmc-utils: One further optimization of trimming routine
The last change to the trimming routine made it more efficient,
however, we can even get rid of the memmove() as we leave the
function with strdup() anyway.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20210920194633.814-1-mhei@heimpold.de
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-09-30 11:46:07 +02:00
Stephane Fillod e9654ebc4a Various fixes
These warnings were mainly found using cppcheck.

Signed-off-by: Stephane Fillod <f8cfe@free.fr>
Reviewed-by: Michael Heimpold <mhei@heimpold.de>
Link: https://lore.kernel.org/r/1254580747.16828401.1547561163645.JavaMail.root@zimbra64-e11.priv.proxad.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:28:34 +02:00
Stephane Fillod 5edc6a4ed1 Add various SD/eMMC vendors to table
Part if this list update comes from a compilation of this web site[1].

[1] https://www.cameramemoryspeed.com/sd-memory-card-faq/reading-sd-card-cid-serial-psn-internal-numbers/

Signed-off-by: Stephane Fillod <f8cfe@free.fr>
Link: https://lore.kernel.org/r/886907785.16708970.1547560575203.JavaMail.root@zimbra64-e11.priv.proxad.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:28:10 +02:00
Stephane Fillod 51434a7ab2 Fix parsing of Product Revision and Serial Number
According to MMC Standard (similar to SDCard Standard).

Signed-off-by: Stephane Fillod <f8cfe@free.fr>
Acked-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/1823652044.3512532.1547484650178.JavaMail.root@zimbra64-e11.priv.proxad.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:19:53 +02:00
Michael Heimpold 73d6c59af8 Add eMMC vendor Micron to table
Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2019-10-04 20:47:33 -04:00
Michael Heimpold 6c595aea07 Optimize to_binstr() function
Appending multiple times to same string is slow since strcat() needs
to determine the end during each run. So manually maintain a pointer
to the end to speed-up things.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2019-10-04 20:47:30 -04:00
Michael Heimpold c19c7694d2 Fix parsing of character in to_binstr()
When a hex-digit > 'a' or 'A' is read, we have to add an offset of 10
to access the valid symbol in our mapping table.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2019-10-04 20:47:27 -04:00
Michael Heimpold de27fd9752 Cleanup memory in error case
In case that we leave due to malformed string,
free the allocated memory before returning.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2019-10-04 20:47:24 -04:00
Michael Heimpold de0715d5b0 Check calloc's return value before using the pointer
If calloc fails, bail out immediately instead of trying to
use the NULL pointer.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2019-10-04 20:47:11 -04:00
Wolfram Sang bd23a79e34 fix GCC7 build by refactoring trimming routines
I got a compile error with GCC7. When trimming white spaces from strings
lsmmc uses strncpy with overlapping memory areas. This is not allowed.
In addition, the implementation was not efficient with calling strlen
and strncpy once per iteration. Refactor the code to be valid and more
effective.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Chris Ball <chris@printf.net>
2018-12-08 00:03:54 -05:00
Uwe Kleine-König fcef164b23 mmc-utils: drop macro CHECK
This macro saves a few lines of code but is harder to read than the
equivalent code spelled out. IMHO the latter is more important, so
expand the macro everywhere and drop it.

While touching this also unbreak the strings used there for better
grepability.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Chris Ball <chris@printf.net>
2018-02-16 20:17:09 -05:00
Sebastian Rasmussen 4af1749d23 mmc-utils: Merge the lsmmc tool into mmc-utils
The lsmmc tools contains an extensive parser of the CID, CSD, SCR
registers from userspace. The utility works as-is and uses sysfs
to read the register values.

The original code is created by Sebastian Rasmussen and still lives
in an attachment in the mail archive of linux-mmc. It need to be merged
into mmc-utils repository, which is convenient for testing MMC device
from userspace.

Change since v3:
 - Remove the unused EXT_CSD parser in lsmmc.c file.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
2016-02-26 09:42:38 -05:00