diff mbox

mtd: nand: print erase size on init

Message ID 1413842464-18016-1-git-send-email-zajec5@gmail.com
State Accepted
Commit 3755a99157d3b038f9dfe9bb203c520cb9728b93
Headers show

Commit Message

Rafał Miłecki Oct. 20, 2014, 10:01 p.m. UTC
It may be useful info, e.g. if someone wants to use ubinize.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/mtd/nand/nand_base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ezequiel Garcia Oct. 22, 2014, 10:48 p.m. UTC | #1
On 10/20/2014 07:01 PM, Rafał Miłecki wrote:
> It may be useful info, e.g. if someone wants to use ubinize.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>  drivers/mtd/nand/nand_base.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 5b5c627..5e9ffbe 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3765,9 +3765,9 @@ ident_done:
>  		pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,
>  				type->name);
>  
> -	pr_info("%dMiB, %s, page size: %d, OOB size: %d\n",
> +	pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n",
>  		(int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
> -		mtd->writesize, mtd->oobsize);
> +		mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
>  	return type;
>  }
>  
> 

Hm, this line is already way too long! I'd say we should try to make it
shorter, instead of longer.

Moreover, you have a /proc and a /sysfs interface to retrieve the erasesize:

What's wrong with using any of the currently available interfaces:

$ cat /sys/class/mtd/mtd0/erasesize 
131072

$ cat /proc/mtd | grep mtd0 | awk '{print $3}'
00020000

Any reason why you want the info in the kernel log?
Artem Bityutskiy Oct. 30, 2014, 7:33 a.m. UTC | #2
On Wed, 2014-10-22 at 19:48 -0300, Ezequiel Garcia wrote:
> Hm, this line is already way too long!

Can be split then.

> Moreover, you have a /proc and a /sysfs interface to retrieve the erasesize:
> 
> What's wrong with using any of the currently available interfaces:
> 
> $ cat /sys/class/mtd/mtd0/erasesize 
> 131072
> 
> $ cat /proc/mtd | grep mtd0 | awk '{print $3}'
> 00020000
> 
> Any reason why you want the info in the kernel log?

When people ask for help and send their logs, it is very handy to have
this information there.
Rafał Miłecki Oct. 30, 2014, 12:35 p.m. UTC | #3
On 30 October 2014 08:33, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Wed, 2014-10-22 at 19:48 -0300, Ezequiel Garcia wrote:
>> Moreover, you have a /proc and a /sysfs interface to retrieve the erasesize:
>>
>> What's wrong with using any of the currently available interfaces:
>>
>> $ cat /sys/class/mtd/mtd0/erasesize
>> 131072
>>
>> $ cat /proc/mtd | grep mtd0 | awk '{print $3}'
>> 00020000
>>
>> Any reason why you want the info in the kernel log?
>
> When people ask for help and send their logs, it is very handy to have
> this information there.

Oops, forgot to reply. There are two reasons for this:
1) It's easier to get erasesize from users/reporters when it simply
appears in the boot log.
2) If user space breaks (e.g. because of wrong UBI image) we can't use
"cat" to read the erasesize
Ezequiel Garcia Nov. 23, 2014, 12:51 a.m. UTC | #4
On 10/30/2014 09:35 AM, Rafał Miłecki wrote:
> On 30 October 2014 08:33, Artem Bityutskiy <dedekind1@gmail.com> wrote:
>> On Wed, 2014-10-22 at 19:48 -0300, Ezequiel Garcia wrote:
>>> Moreover, you have a /proc and a /sysfs interface to retrieve the erasesize:
>>>
>>> What's wrong with using any of the currently available interfaces:
>>>
>>> $ cat /sys/class/mtd/mtd0/erasesize
>>> 131072
>>>
>>> $ cat /proc/mtd | grep mtd0 | awk '{print $3}'
>>> 00020000
>>>
>>> Any reason why you want the info in the kernel log?
>>
>> When people ask for help and send their logs, it is very handy to have
>> this information there.
> 
> Oops, forgot to reply. There are two reasons for this:
> 1) It's easier to get erasesize from users/reporters when it simply
> appears in the boot log.
> 2) If user space breaks (e.g. because of wrong UBI image) we can't use
> "cat" to read the erasesize
> 

Hm.. OK. Those sound like good reasons.
Brian Norris Nov. 26, 2014, 3:02 a.m. UTC | #5
On Sat, Nov 22, 2014 at 09:51:03PM -0300, Ezequiel Garcia wrote:
> On 10/30/2014 09:35 AM, Rafał Miłecki wrote:
> > On 30 October 2014 08:33, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> >> On Wed, 2014-10-22 at 19:48 -0300, Ezequiel Garcia wrote:
> >>> Moreover, you have a /proc and a /sysfs interface to retrieve the erasesize:
> >>>
> >>> What's wrong with using any of the currently available interfaces:
> >>>
> >>> $ cat /sys/class/mtd/mtd0/erasesize
> >>> 131072
> >>>
> >>> $ cat /proc/mtd | grep mtd0 | awk '{print $3}'
> >>> 00020000
> >>>
> >>> Any reason why you want the info in the kernel log?
> >>
> >> When people ask for help and send their logs, it is very handy to have
> >> this information there.
> > 
> > Oops, forgot to reply. There are two reasons for this:
> > 1) It's easier to get erasesize from users/reporters when it simply
> > appears in the boot log.
> > 2) If user space breaks (e.g. because of wrong UBI image) we can't use
> > "cat" to read the erasesize
> > 
> 
> Hm.. OK. Those sound like good reasons.

Glad we can agree on this important issue :)

Pushed to l2-mtd.git.

Brian
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 5b5c627..5e9ffbe 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3765,9 +3765,9 @@  ident_done:
 		pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,
 				type->name);
 
-	pr_info("%dMiB, %s, page size: %d, OOB size: %d\n",
+	pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n",
 		(int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
-		mtd->writesize, mtd->oobsize);
+		mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
 	return type;
 }