Skip to content

Commit 3b79121

Browse files
Dragan Simicstorulf
authored andcommitted
mmc: core: Trim trailing whitespace from card product names
Product names for some eMMC chips can include trailing whitespace, which seems to be rather uncommon, but makes emitted messages and /sys properties somewhat unsightly. Here's such an example from a Pine64 PineNote, in which "Biwin ", as the eMMC product name, contains trailing whitespace: mmc0: new HS200 MMC card at address 0001 mmcblk0: mmc0:0001 Biwin 115 GiB mmcblk0: p1 p2 p3 p4 p5 p6 p7 mmcblk0boot0: mmc0:0001 Biwin 4.00 MiB mmcblk0boot1: mmc0:0001 Biwin 4.00 MiB mmcblk0rpmb: mmc0:0001 Biwin 4.00 MiB, chardev (249:0) Trailing whitespace in /sys properties may even cause some unforeseen issues with some scripts, so let's have the trailing whitespace trimmed in product names for eMMC chips. Although not observed yet by the author of these changes, the same trailing whitespace may appear in SD card product names, so let's trim them as well, which can't hurt. Touch-up one comment as well, by using proper capitalization. Signed-off-by: Dragan Simic <[email protected]> Acked-by: Avri Altman <[email protected]> Link: https://lore.kernel.org/r/fb7fcecae737f3e8b279854d7c853000527cba9a.1740597891.git.dsimic@manjaro.org Signed-off-by: Ulf Hansson <[email protected]>
1 parent c784b76 commit 3b79121

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

drivers/mmc/core/mmc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/of.h>
1212
#include <linux/slab.h>
1313
#include <linux/stat.h>
14+
#include <linux/string.h>
1415
#include <linux/pm_runtime.h>
1516
#include <linux/random.h>
1617
#include <linux/sysfs.h>
@@ -66,7 +67,7 @@ static int mmc_decode_cid(struct mmc_card *card)
6667

6768
/*
6869
* The selection of the format here is based upon published
69-
* specs from sandisk and from what people have reported.
70+
* specs from SanDisk and from what people have reported.
7071
*/
7172
switch (card->csd.mmca_vsn) {
7273
case 0: /* MMC v1.0 - v1.2 */
@@ -109,6 +110,9 @@ static int mmc_decode_cid(struct mmc_card *card)
109110
return -EINVAL;
110111
}
111112

113+
/* some product names include trailing whitespace */
114+
strim(card->cid.prod_name);
115+
112116
return 0;
113117
}
114118

drivers/mmc/core/sd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/sizes.h>
1212
#include <linux/slab.h>
1313
#include <linux/stat.h>
14+
#include <linux/string.h>
1415
#include <linux/pm_runtime.h>
1516
#include <linux/random.h>
1617
#include <linux/scatterlist.h>
@@ -95,6 +96,9 @@ void mmc_decode_cid(struct mmc_card *card)
9596
card->cid.month = unstuff_bits(resp, 8, 4);
9697

9798
card->cid.year += 2000; /* SD cards year offset */
99+
100+
/* some product names may include trailing whitespace */
101+
strim(card->cid.prod_name);
98102
}
99103

100104
/*

0 commit comments

Comments
 (0)