Skip to contentSkip to conversation

Hide flash name if it is not set

PATCH In review Jaime Liao 4 participants 12 messages Nov 27, 2023

Subsystems (2)
lore
Share & tools
lore

Jaime Liao

author
#0 lore raw

cover Hide flash name if it is not set

From: JaimeLiao <[email protected]>

hide flash name if it is not set

JaimeLiao (2):
mtd: spi-nor:sysfs: hide flash name if it is not set
mtd: spi-nor: hide flash name when the flash name does not exist

 Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++
 drivers/mtd/spi-nor/core.c                              | 2 +-
 drivers/mtd/spi-nor/sysfs.c                             | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
author
#1 lore raw

PATCH 1/2 mtd: spi-nor:sysfs: hide flash name if it is not set

From: JaimeLiao <[email protected]>

The info->name may be optional when flash ID founded in ID table but didn't include flash name.

---
 Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++
 drivers/mtd/spi-nor/sysfs.c                             | 2 ++
 2 files changed, 5 insertions(+)
Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor +3 -0
index c800621eff95..6d7be97bf7d1 100644
@@ -25,6 +25,9 @@ KernelVersion:	5.14
 Contact:	[email protected]
 Description:	(RO) Part name of the SPI NOR flash.
 
+		The attribute is not present if the jedec_id founded in
+		ID table but flash name didn't include in it.
+
 
 What:		/sys/bus/spi/devices/.../spi-nor/sfdp
 Date:		April 2021
drivers/mtd/spi-nor/sysfs.c +2 -0
index 2dfdc555a69f..96064e4babf0 100644
@@ -78,6 +78,8 @@ static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj,
 
 	if (attr == &dev_attr_manufacturer.attr && !nor->manufacturer)
 		return 0;
+	if (attr == &dev_attr_partname.attr && !nor->info->name)
+		return 0;
 	if (attr == &dev_attr_jedec_id.attr && !nor->info->id && !nor->id)
 		return 0;
 
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
author
#2 lore raw

PATCH 2/2 mtd: spi-nor: hide flash name when the flash name does not exist

In reply to Jaime Liao

From: JaimeLiao <[email protected]>

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
 drivers/mtd/spi-nor/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +1 -1
index 1c443fe568cf..73405bed2a5a 100644
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
 	/* No mtd_info fields should be used up to this point. */
 	spi_nor_set_mtd_info(nor);
 
-	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+	dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",
 			(long long)mtd->size >> 10);
 
 	dev_dbg(dev,
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#3 lore raw

Re: [PATCH v1 2/2] mtd: spi-nor: hide flash name when the flash name does not exist

Hi,

Quoted 16 lines

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
 drivers/mtd/spi-nor/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index 1c443fe568cf..73405bed2a5a 100644

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char · line 3522

Quoted 6 lines
drivers/mtd/spi-nor/core.c +1 -1
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const char 
 *name,
 	/* No mtd_info fields should be used up to this point. */
 	spi_nor_set_mtd_info(nor);
 
-	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+	dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",

Maybe print the jedec id if the name is empty.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

maintainer
#4 lore raw

Re: [PATCH v1 2/2] mtd: spi-nor: hide flash name when the flash name does not exist

Hi Michael,

[email protected] wrote on Mon, 27 Nov 2023 13:21:34 +0100:

Quoted 21 lines

Hi,

Quoted 19 lines

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
 drivers/mtd/spi-nor/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index 1c443fe568cf..73405bed2a5a 100644
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const char > *name,
 	/* No mtd_info fields should be used up to this point. */
 	spi_nor_set_mtd_info(nor);
 
Quoted 4 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3521

Quoted 2 lines
drivers/mtd/spi-nor/core.c +1 -1
-	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+	dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",  

Maybe print the jedec id if the name is empty.

What about always printing the jedec id if names aren't reliable enough?

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#5 lore raw

Re: [PATCH v1 2/2] mtd: spi-nor: hide flash name when the flash name does not exist

Hi,

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
 drivers/mtd/spi-nor/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index 1c443fe568cf..73405bed2a5a 100644
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const char > *name,
 	/* No mtd_info fields should be used up to this point. */
 	spi_nor_set_mtd_info(nor);
 
Quoted 7 lines
Quoted 4 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3521

Quoted 2 lines
drivers/mtd/spi-nor/core.c +1 -1
-	dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+	dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",

Maybe print the jedec id if the name is empty.

What about always printing the jedec id if names aren't reliable enough?

I'm fine with that, too. Actually I've considered that myself, but maybe Tudor or Pratyush want to keep the output backwards compatible.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw

Re: [PATCH v1 2/2] mtd: spi-nor: hide flash name when the flash name does not exist

Quoted 25 lines · Michael Walle

Hi,

Quoted 23 lines
Quoted 23 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const

Quoted 16 lines

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
  drivers/mtd/spi-nor/core.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index 1c443fe568cf..73405bed2a5a 100644
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const

char > *name,

Quoted 5 lines
drivers/mtd/spi-nor/core.c +1 -1
       /* No mtd_info fields should be used up to this point. */
       spi_nor_set_mtd_info(nor);
 
-    dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+    dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Maybe print the jedec id if the name is empty.

What about always printing the jedec id if names aren't reliable enough?

I'm fine with that, too. Actually I've considered that myself, but maybe Tudor or Pratyush want to keep the output backwards compatible.

We won't remove the names for flashes that already have a name defined, won't we? We just deprecate the name field and not use it anymore with new flash additions. No backward compatibility problem.

BTW, that print should be lowered to dev_dbg, let's no longer pollute the kernel log. Drivers should be quiet if all goes well.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#7 lore raw

Re: [PATCH v1 2/2] mtd: spi-nor: hide flash name when the flash name does not exist

Hi,

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 17 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const

Quoted 16 lines

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
  drivers/mtd/spi-nor/core.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index 1c443fe568cf..73405bed2a5a 100644
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const

char > *name,

Quoted 7 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3521

Quoted 5 lines
drivers/mtd/spi-nor/core.c +1 -1
       /* No mtd_info fields should be used up to this point. */
       spi_nor_set_mtd_info(nor);
 
-    dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+    dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",

Maybe print the jedec id if the name is empty.

What about always printing the jedec id if names aren't reliable enough?

Quoted 6 lines
Quoted 3 lines

I'm fine with that, too. Actually I've considered that myself, but maybe Tudor or Pratyush want to keep the output backwards compatible.

We won't remove the names for flashes that already have a name defined, won't we?

No.

Quoted 2 lines

We just deprecate the name field and not use it anymore with new flash additions. No backward compatibility problem.

I mean in the kernel console output. Someone out there might parse it.

If you switch from
dev_info(dev, "%s (%lld Kbytes)\n", info->name, ...)
to
dev_info(dev, ""%*phN (%lld Kbytes)\n", id_len, id, ...)

Quoted 2 lines

BTW, that print should be lowered to dev_dbg, let's no longer pollute the kernel log. Drivers should be quiet if all goes well.

Well, ok, that will also answer my question :) So let's go with the dev_dbg() and id only.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#8 lore raw

Re: [PATCH v1 2/2] mtd: spi-nor: hide flash name when the flash name does not exist

Quoted 42 lines · Michael Walle

Hi,

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 17 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const

Quoted 16 lines

(null) will print when flash ID founded in ID table but the flash name didn't include in it.

Make info->name optional in the print for showing flash name and flash size.

---
  drivers/mtd/spi-nor/core.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index 1c443fe568cf..73405bed2a5a 100644
@@ -3518,7 +3518,7 @@ int spi_nor_scan(struct spi_nor *nor, const

char > *name,

Quoted 7 lines

drivers/mtd/spi-nor/core.c int spi_nor_scan(struct spi_nor *nor, const char *name, · line 3521

Quoted 5 lines
drivers/mtd/spi-nor/core.c +1 -1
       /* No mtd_info fields should be used up to this point. */
       spi_nor_set_mtd_info(nor);
 
-    dev_info(dev, "%s (%lld Kbytes)\n", info->name,
+    dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",

Maybe print the jedec id if the name is empty.

What about always printing the jedec id if names aren't reliable enough?

Quoted 6 lines
Quoted 3 lines

I'm fine with that, too. Actually I've considered that myself, but maybe Tudor or Pratyush want to keep the output backwards compatible.

We won't remove the names for flashes that already have a name defined, won't we?

No.

Quoted 2 lines

We just deprecate the name field and not use it anymore with new flash additions. No backward compatibility problem.

Quoted 7 lines

I mean in the kernel console output. Someone out there might parse it.

If you switch from
  dev_info(dev, "%s (%lld Kbytes)\n", info->name, ...) to
  dev_info(dev, ""%*phN (%lld Kbytes)\n", id_len, id, ...)

no problem in changing what we print to kernel log, there's no guarantees associated with it.

Quoted 6 lines
Quoted 2 lines

BTW, that print should be lowered to dev_dbg, let's no longer pollute the kernel log. Drivers should be quiet if all goes well.

Well, ok, that will also answer my question :) So let's go with the dev_dbg() and id only.

I looked again and I saw that together with the name we printed the flash size in Kbytes. But then the next print printed the same flash size in bytes and then in MBytes. And then we printed some mtd data that should be obtained with the mtd ioctls. I didn't like that mess and ended up removing all those prints. We shall now have a faster kernel boot (got rid of the print info), and cleaner kernel log. All that debug data shall be obtained with the mtd ioctls and the SPI NOR sysfs and debugfs entries, so hopefully more people will start using them.

Here's the patch that I mentioned:
https://lore.kernel.org/linux-mtd/[email protected]/T/#u

Cheers,
ta

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

maintainer
#9 lore raw
In reply to Jaime Liao

Hi Jaime,

[email protected] wrote on Mon, 27 Nov 2023 18:07:52 +0800:

Quoted 3 lines

From: JaimeLiao <[email protected]>

hide flash name if it is not set

Is this really needed? I'm fine exposing en empty (or "(null)") name. I guess it shows to people that the name might be missing somewhere and might push people to fix the name instead.

What's your use case?

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#10 lore raw

Hi,

Quoted 7 lines
Quoted 1 line

hide flash name if it is not set

Is this really needed? I'm fine exposing en empty (or "(null)") name. I guess it shows to people that the name might be missing somewhere and might push people to fix the name instead.

What's your use case?

An empty string is not a bug. I'm trying to push the part names out of the kernel and just expose the jedec id.

That being said, the description is really missing the point. See my previous suggestion:

The attribute is optional. User space shouldn't rely on it to be present or even correct. Instead, user space should read the jedec_id attribute.

-michael

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#11 lore raw
Quoted 13 lines · Michael Walle

Hi,

Quoted 7 lines
Quoted 1 line

hide flash name if it is not set

Is this really needed? I'm fine exposing en empty (or "(null)") name. I guess it shows to people that the name might be missing somewhere and might push people to fix the name instead.

What's your use case?

An empty string is not a bug. I'm trying to push the part names out of the kernel and just expose the jedec id.

Quoted 7 lines

That being said, the description is really missing the point. See my previous suggestion:

 The attribute is optional. User space shouldn't rely on it to be present or even correct. Instead, user space should read the jedec_id attribute.

+1

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/