The product name field PNM is available for both SD cards (len=5) and MMC cards (len=6). The currently used method doesn't respect the length for MMC cards. Signed-off-by: Stefan Kerkmann <s.kerkmann@xxxxxxxxxxxxxx> --- drivers/mci/mci-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 2a71fdd39a..df72445edd 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -1939,6 +1939,31 @@ static unsigned extract_oid(struct mci *mci) return (mci->cid[0] >> 8) & 0xffff; } +/** + * Extract the product name from the CID + * @param mci Instance data + * + * The 'PNM' is encoded in bit 103:64 in the CID for SD cards and 103:56 for + * MMC cards + */ +static void extract_pnm(struct mci *mci, char pnm[static 7]) +{ + pnm[0] = UNSTUFF_BITS(mci->cid, 96, 8); + pnm[1] = UNSTUFF_BITS(mci->cid, 88, 8); + pnm[2] = UNSTUFF_BITS(mci->cid, 80, 8); + pnm[3] = UNSTUFF_BITS(mci->cid, 72, 8); + pnm[4] = UNSTUFF_BITS(mci->cid, 64, 8); + + if (IS_SD(mci)) { + // SD cards have a 5 character long product name + pnm[5] = '\0'; + } else { + // MMC cards have a 6 character long product name + pnm[5] = UNSTUFF_BITS(mci->cid, 56, 8); + pnm[6] = '\0'; + } +} + /** * Extract the product revision from the CID * @param mci Instance data -- 2.39.2