public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Trim trailing whitespace from card product names
@ 2025-02-26 19:26 Dragan Simic
  2025-02-26 19:30 ` Dragan Simic
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dragan Simic @ 2025-02-26 19:26 UTC (permalink / raw)
  To: linux-mmc; +Cc: ulf.hansson, git, linux-kernel

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 commit as well, by using proper capitalization.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
 drivers/mmc/core/mmc.c | 6 +++++-
 drivers/mmc/core/sd.c  | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 6a23be214543..1522fd2b517d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -11,6 +11,7 @@
 #include <linux/of.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
+#include <linux/string.h>
 #include <linux/pm_runtime.h>
 #include <linux/random.h>
 #include <linux/sysfs.h>
@@ -66,7 +67,7 @@ static int mmc_decode_cid(struct mmc_card *card)
 
 	/*
 	 * The selection of the format here is based upon published
-	 * specs from sandisk and from what people have reported.
+	 * specs from SanDisk and from what people have reported.
 	 */
 	switch (card->csd.mmca_vsn) {
 	case 0: /* MMC v1.0 - v1.2 */
@@ -109,6 +110,9 @@ static int mmc_decode_cid(struct mmc_card *card)
 		return -EINVAL;
 	}
 
+	/* some product names include trailing whitespace */
+	strim(card->cid.prod_name);
+
 	return 0;
 }
 
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index cc757b850e79..8eba697d3d86 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -11,6 +11,7 @@
 #include <linux/sizes.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
+#include <linux/string.h>
 #include <linux/pm_runtime.h>
 #include <linux/random.h>
 #include <linux/scatterlist.h>
@@ -95,6 +96,9 @@ void mmc_decode_cid(struct mmc_card *card)
 	card->cid.month			= unstuff_bits(resp, 8, 4);
 
 	card->cid.year += 2000; /* SD cards year offset */
+
+	/* some product names may include trailing whitespace */
+	strim(card->cid.prod_name);
 }
 
 /*

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: Trim trailing whitespace from card product names
  2025-02-26 19:26 [PATCH] mmc: core: Trim trailing whitespace from card product names Dragan Simic
@ 2025-02-26 19:30 ` Dragan Simic
  2025-02-27  7:56 ` Avri Altman
  2025-03-12 11:24 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Dragan Simic @ 2025-02-26 19:30 UTC (permalink / raw)
  To: linux-mmc; +Cc: ulf.hansson, git, linux-kernel

Hello,

On 2025-02-26 20:26, Dragan Simic wrote:
> 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 commit as well, by using proper capitalization.

Oops, s/commit/comment/, sorry...  Just saw it, a few seconds too late. 
:/

> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> ---
>  drivers/mmc/core/mmc.c | 6 +++++-
>  drivers/mmc/core/sd.c  | 4 ++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 6a23be214543..1522fd2b517d 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -11,6 +11,7 @@
>  #include <linux/of.h>
>  #include <linux/slab.h>
>  #include <linux/stat.h>
> +#include <linux/string.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/random.h>
>  #include <linux/sysfs.h>
> @@ -66,7 +67,7 @@ static int mmc_decode_cid(struct mmc_card *card)
> 
>  	/*
>  	 * The selection of the format here is based upon published
> -	 * specs from sandisk and from what people have reported.
> +	 * specs from SanDisk and from what people have reported.
>  	 */
>  	switch (card->csd.mmca_vsn) {
>  	case 0: /* MMC v1.0 - v1.2 */
> @@ -109,6 +110,9 @@ static int mmc_decode_cid(struct mmc_card *card)
>  		return -EINVAL;
>  	}
> 
> +	/* some product names include trailing whitespace */
> +	strim(card->cid.prod_name);
> +
>  	return 0;
>  }
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index cc757b850e79..8eba697d3d86 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -11,6 +11,7 @@
>  #include <linux/sizes.h>
>  #include <linux/slab.h>
>  #include <linux/stat.h>
> +#include <linux/string.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/random.h>
>  #include <linux/scatterlist.h>
> @@ -95,6 +96,9 @@ void mmc_decode_cid(struct mmc_card *card)
>  	card->cid.month			= unstuff_bits(resp, 8, 4);
> 
>  	card->cid.year += 2000; /* SD cards year offset */
> +
> +	/* some product names may include trailing whitespace */
> +	strim(card->cid.prod_name);
>  }
> 
>  /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] mmc: core: Trim trailing whitespace from card product names
  2025-02-26 19:26 [PATCH] mmc: core: Trim trailing whitespace from card product names Dragan Simic
  2025-02-26 19:30 ` Dragan Simic
@ 2025-02-27  7:56 ` Avri Altman
  2025-03-12 11:24 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Avri Altman @ 2025-02-27  7:56 UTC (permalink / raw)
  To: Dragan Simic, linux-mmc@vger.kernel.org
  Cc: ulf.hansson@linaro.org, git@hrdl.eu, linux-kernel@vger.kernel.org

> 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 commit as well, by using proper capitalization.
> 
> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Acked-by: Avri Altman <avri.altman@sandisk.com>

> ---
>  drivers/mmc/core/mmc.c | 6 +++++-
>  drivers/mmc/core/sd.c  | 4 ++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 6a23be214543..1522fd2b517d 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -11,6 +11,7 @@
>  #include <linux/of.h>
>  #include <linux/slab.h>
>  #include <linux/stat.h>
> +#include <linux/string.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/random.h>
>  #include <linux/sysfs.h>
> @@ -66,7 +67,7 @@ static int mmc_decode_cid(struct mmc_card *card)
> 
>  	/*
>  	 * The selection of the format here is based upon published
> -	 * specs from sandisk and from what people have reported.
> +	 * specs from SanDisk and from what people have reported.
>  	 */
>  	switch (card->csd.mmca_vsn) {
>  	case 0: /* MMC v1.0 - v1.2 */
> @@ -109,6 +110,9 @@ static int mmc_decode_cid(struct mmc_card *card)
>  		return -EINVAL;
>  	}
> 
> +	/* some product names include trailing whitespace */
> +	strim(card->cid.prod_name);
> +
>  	return 0;
>  }
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index cc757b850e79..8eba697d3d86 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -11,6 +11,7 @@
>  #include <linux/sizes.h>
>  #include <linux/slab.h>
>  #include <linux/stat.h>
> +#include <linux/string.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/random.h>
>  #include <linux/scatterlist.h>
> @@ -95,6 +96,9 @@ void mmc_decode_cid(struct mmc_card *card)
>  	card->cid.month			= unstuff_bits(resp, 8, 4);
> 
>  	card->cid.year += 2000; /* SD cards year offset */
> +
> +	/* some product names may include trailing whitespace */
> +	strim(card->cid.prod_name);
>  }
> 
>  /*


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: Trim trailing whitespace from card product names
  2025-02-26 19:26 [PATCH] mmc: core: Trim trailing whitespace from card product names Dragan Simic
  2025-02-26 19:30 ` Dragan Simic
  2025-02-27  7:56 ` Avri Altman
@ 2025-03-12 11:24 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2025-03-12 11:24 UTC (permalink / raw)
  To: Dragan Simic; +Cc: linux-mmc, git, linux-kernel

On Wed, 26 Feb 2025 at 20:26, Dragan Simic <dsimic@manjaro.org> wrote:
>
> 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 commit as well, by using proper capitalization.
>
> Signed-off-by: Dragan Simic <dsimic@manjaro.org>

Applied for next and by updating "commit" to "comment" in the
commit-msg, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/mmc.c | 6 +++++-
>  drivers/mmc/core/sd.c  | 4 ++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 6a23be214543..1522fd2b517d 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -11,6 +11,7 @@
>  #include <linux/of.h>
>  #include <linux/slab.h>
>  #include <linux/stat.h>
> +#include <linux/string.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/random.h>
>  #include <linux/sysfs.h>
> @@ -66,7 +67,7 @@ static int mmc_decode_cid(struct mmc_card *card)
>
>         /*
>          * The selection of the format here is based upon published
> -        * specs from sandisk and from what people have reported.
> +        * specs from SanDisk and from what people have reported.
>          */
>         switch (card->csd.mmca_vsn) {
>         case 0: /* MMC v1.0 - v1.2 */
> @@ -109,6 +110,9 @@ static int mmc_decode_cid(struct mmc_card *card)
>                 return -EINVAL;
>         }
>
> +       /* some product names include trailing whitespace */
> +       strim(card->cid.prod_name);
> +
>         return 0;
>  }
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index cc757b850e79..8eba697d3d86 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -11,6 +11,7 @@
>  #include <linux/sizes.h>
>  #include <linux/slab.h>
>  #include <linux/stat.h>
> +#include <linux/string.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/random.h>
>  #include <linux/scatterlist.h>
> @@ -95,6 +96,9 @@ void mmc_decode_cid(struct mmc_card *card)
>         card->cid.month                 = unstuff_bits(resp, 8, 4);
>
>         card->cid.year += 2000; /* SD cards year offset */
> +
> +       /* some product names may include trailing whitespace */
> +       strim(card->cid.prod_name);
>  }
>
>  /*

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-12 11:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 19:26 [PATCH] mmc: core: Trim trailing whitespace from card product names Dragan Simic
2025-02-26 19:30 ` Dragan Simic
2025-02-27  7:56 ` Avri Altman
2025-03-12 11:24 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox