Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] - change calculating of position page containing BBM
@ 2019-09-19 12:41 Piotr Sroka
  2019-09-19 12:58 ` Miquel Raynal
  0 siblings, 1 reply; 6+ messages in thread
From: Piotr Sroka @ 2019-09-19 12:41 UTC (permalink / raw)
  Cc: Vignesh Raghavendra, Boris Brezillon, Richard Weinberger,
	linux-kernel, Frieder Schrempf, Marek Vasut, linux-mtd,
	Miquel Raynal, Brian Norris, David Woodhouse, Piotr Sroka

Change calculating of position page containing BBM

If none of BBM flags is set then function nand_bbm_get_next_page 
reports EINVAL. It causes that BBM is not read at all during scanning
factory bad blocks. The result is that the BBT table is build without 
checking factory BBM at all. For Micron flash memories none of this 
flag is set if page size is different than 2048 bytes.

This patch changes the nand_bbm_get_next_page function.
It will return 0 if none of BBM flag is set and page parameter is 0. 
After that modification way of discovering factory bad blocks will work 
similar as in kernel version 5.1.

Signed-off-by: Piotr Sroka <piotrs@cadence.com>
---
 drivers/mtd/nand/raw/nand_base.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 5c2c30a7dffa..f64e3b6605c6 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	int last_page = ((mtd->erasesize - mtd->writesize) >>
 			 chip->page_shift) & chip->pagemask;
+	unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
+		| NAND_BBM_LASTPAGE;
 
+	if (page == 0 && !(chip->options & bbm_flags))
+		return 0;
 	if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
 		return 0;
-	else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
+	if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
 		return 1;
-	else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
+	if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
 		return last_page;
 
 	return -EINVAL;
-- 
2.15.0


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

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

* Re: [PATCH] - change calculating of position page containing BBM
  2019-09-19 12:41 [PATCH] - change calculating of position page containing BBM Piotr Sroka
@ 2019-09-19 12:58 ` Miquel Raynal
  2019-09-19 13:15   ` Schrempf Frieder
  0 siblings, 1 reply; 6+ messages in thread
From: Miquel Raynal @ 2019-09-19 12:58 UTC (permalink / raw)
  To: Piotr Sroka
  Cc: Vignesh Raghavendra, Boris Brezillon, Richard Weinberger,
	linux-kernel, Frieder Schrempf, Marek Vasut, linux-mtd,
	Brian Norris, David Woodhouse

Hi Piotr,

Piotr Sroka <piotrs@cadence.com> wrote on Thu, 19 Sep 2019 13:41:35
+0100:

> Change calculating of position page containing BBM
> 
> If none of BBM flags is set then function nand_bbm_get_next_page 
> reports EINVAL. It causes that BBM is not read at all during scanning
> factory bad blocks. The result is that the BBT table is build without 
> checking factory BBM at all. For Micron flash memories none of this 
> flag is set if page size is different than 2048 bytes.

"none of these flags are set"

> 
> This patch changes the nand_bbm_get_next_page function.

"Address this regression by changing the
nand_bbm_get_next_page_function."

> It will return 0 if none of BBM flag is set and page parameter is 0. 

                      no BBM flag is set

> After that modification way of discovering factory bad blocks will work 
> similar as in kernel version 5.1.
> 

Fixes + stable tags would be great!

> Signed-off-by: Piotr Sroka <piotrs@cadence.com>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 5c2c30a7dffa..f64e3b6605c6 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
>  	struct mtd_info *mtd = nand_to_mtd(chip);
>  	int last_page = ((mtd->erasesize - mtd->writesize) >>
>  			 chip->page_shift) & chip->pagemask;
> +	unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
> +		| NAND_BBM_LASTPAGE;
>  
> +	if (page == 0 && !(chip->options & bbm_flags))
> +		return 0;
>  	if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
>  		return 0;
> -	else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
> +	if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>  		return 1;
> -	else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
> +	if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>  		return last_page;
>  
>  	return -EINVAL;

Lookgs good otherwise.

Thanks,
Miquèl

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

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

* Re: [PATCH] - change calculating of position page containing BBM
  2019-09-19 12:58 ` Miquel Raynal
@ 2019-09-19 13:15   ` Schrempf Frieder
  2019-09-19 13:18     ` Miquel Raynal
  0 siblings, 1 reply; 6+ messages in thread
From: Schrempf Frieder @ 2019-09-19 13:15 UTC (permalink / raw)
  To: Miquel Raynal, Piotr Sroka
  Cc: Vignesh Raghavendra, Boris Brezillon, Richard Weinberger,
	linux-kernel, Marek Vasut, linux-mtd, Brian Norris,
	David Woodhouse

On 19.09.19 14:58, Miquel Raynal wrote:
> Hi Piotr,
> 
> Piotr Sroka <piotrs@cadence.com> wrote on Thu, 19 Sep 2019 13:41:35
> +0100:
> 
>> Change calculating of position page containing BBM
>>
>> If none of BBM flags is set then function nand_bbm_get_next_page
>> reports EINVAL. It causes that BBM is not read at all during scanning
>> factory bad blocks. The result is that the BBT table is build without
>> checking factory BBM at all. For Micron flash memories none of this
>> flag is set if page size is different than 2048 bytes.

I wonder if it wouldn't be better to fix the Micron driver instead:

--- a/drivers/mtd/nand/raw/nand_micron.c
+++ b/drivers/mtd/nand/raw/nand_micron.c
@@ -448,6 +448,8 @@ static int micron_nand_init(struct nand_chip *chip)

         if (mtd->writesize == 2048)
                 chip->options |= NAND_BBM_FIRSTPAGE |
                                  NAND_BBM_SECONDPAGE;
+       else
+               chip->options |= NAND_BBM_FIRSTPAGE;

         ondie = micron_supports_on_die_ecc(chip);


> 
> "none of these flags are set"
> 
>>
>> This patch changes the nand_bbm_get_next_page function.
> 
> "Address this regression by changing the
> nand_bbm_get_next_page_function."
> 
>> It will return 0 if none of BBM flag is set and page parameter is 0.
> 
>                        no BBM flag is set
> 
>> After that modification way of discovering factory bad blocks will work
>> similar as in kernel version 5.1.
>>
> 
> Fixes + stable tags would be great!
> 
>> Signed-off-by: Piotr Sroka <piotrs@cadence.com>
>> ---
>>   drivers/mtd/nand/raw/nand_base.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>> index 5c2c30a7dffa..f64e3b6605c6 100644
>> --- a/drivers/mtd/nand/raw/nand_base.c
>> +++ b/drivers/mtd/nand/raw/nand_base.c
>> @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
>>   	struct mtd_info *mtd = nand_to_mtd(chip);
>>   	int last_page = ((mtd->erasesize - mtd->writesize) >>
>>   			 chip->page_shift) & chip->pagemask;
>> +	unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
>> +		| NAND_BBM_LASTPAGE;
>>   
>> +	if (page == 0 && !(chip->options & bbm_flags))
>> +		return 0;
>>   	if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
>>   		return 0;
>> -	else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>> +	if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>>   		return 1;
>> -	else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>> +	if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>>   		return last_page;
>>   
>>   	return -EINVAL;
> 
> Lookgs good otherwise.
> 
> Thanks,
> Miquèl
> 
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] - change calculating of position page containing BBM
  2019-09-19 13:15   ` Schrempf Frieder
@ 2019-09-19 13:18     ` Miquel Raynal
  2019-09-19 13:33       ` Schrempf Frieder
  0 siblings, 1 reply; 6+ messages in thread
From: Miquel Raynal @ 2019-09-19 13:18 UTC (permalink / raw)
  To: Schrempf Frieder
  Cc: Vignesh Raghavendra, Boris Brezillon, Richard Weinberger,
	linux-kernel, Marek Vasut, linux-mtd, Brian Norris,
	David Woodhouse, Piotr Sroka

Hello,

Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Thu, 19 Sep
2019 13:15:08 +0000:

> On 19.09.19 14:58, Miquel Raynal wrote:
> > Hi Piotr,
> > 
> > Piotr Sroka <piotrs@cadence.com> wrote on Thu, 19 Sep 2019 13:41:35
> > +0100:
> >   
> >> Change calculating of position page containing BBM
> >>
> >> If none of BBM flags is set then function nand_bbm_get_next_page
> >> reports EINVAL. It causes that BBM is not read at all during scanning
> >> factory bad blocks. The result is that the BBT table is build without
> >> checking factory BBM at all. For Micron flash memories none of this
> >> flag is set if page size is different than 2048 bytes.  
> 
> I wonder if it wouldn't be better to fix the Micron driver instead:
> 
> --- a/drivers/mtd/nand/raw/nand_micron.c
> +++ b/drivers/mtd/nand/raw/nand_micron.c
> @@ -448,6 +448,8 @@ static int micron_nand_init(struct nand_chip *chip)
> 
>          if (mtd->writesize == 2048)
>                  chip->options |= NAND_BBM_FIRSTPAGE |
>                                   NAND_BBM_SECONDPAGE;
> +       else
> +               chip->options |= NAND_BBM_FIRSTPAGE;

That's what I forgot in my last answer to this thread, I think I only
told Piotr privately: I would like both. I think it is important to fix
the bbm_get_next_page function but for clarity, setting the FIRSTPAGE
flag in Micron's driver seems also pertinent.

> 
>          ondie = micron_supports_on_die_ecc(chip);
> 
> 
> > 
> > "none of these flags are set"
> >   
> >>
> >> This patch changes the nand_bbm_get_next_page function.  
> > 
> > "Address this regression by changing the
> > nand_bbm_get_next_page_function."
> >   
> >> It will return 0 if none of BBM flag is set and page parameter is 0.  
> > 
> >                        no BBM flag is set
> >   
> >> After that modification way of discovering factory bad blocks will work
> >> similar as in kernel version 5.1.
> >>  
> > 
> > Fixes + stable tags would be great!
> >   
> >> Signed-off-by: Piotr Sroka <piotrs@cadence.com>
> >> ---
> >>   drivers/mtd/nand/raw/nand_base.c | 8 ++++++--
> >>   1 file changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> >> index 5c2c30a7dffa..f64e3b6605c6 100644
> >> --- a/drivers/mtd/nand/raw/nand_base.c
> >> +++ b/drivers/mtd/nand/raw/nand_base.c
> >> @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
> >>   	struct mtd_info *mtd = nand_to_mtd(chip);
> >>   	int last_page = ((mtd->erasesize - mtd->writesize) >>
> >>   			 chip->page_shift) & chip->pagemask;
> >> +	unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
> >> +		| NAND_BBM_LASTPAGE;
> >>   
> >> +	if (page == 0 && !(chip->options & bbm_flags))
> >> +		return 0;
> >>   	if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
> >>   		return 0;
> >> -	else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
> >> +	if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
> >>   		return 1;
> >> -	else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
> >> +	if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
> >>   		return last_page;
> >>   
> >>   	return -EINVAL;  
> > 
> > Lookgs good otherwise.
> > 
> > Thanks,
> > Miquèl
> >  

Thanks,
Miquèl

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

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

* Re: [PATCH] - change calculating of position page containing BBM
  2019-09-19 13:18     ` Miquel Raynal
@ 2019-09-19 13:33       ` Schrempf Frieder
  2019-09-23 12:13         ` Piotr Sroka
  0 siblings, 1 reply; 6+ messages in thread
From: Schrempf Frieder @ 2019-09-19 13:33 UTC (permalink / raw)
  To: Miquel Raynal, Piotr Sroka
  Cc: Vignesh Raghavendra, Boris Brezillon, Richard Weinberger,
	linux-kernel, Marek Vasut, linux-mtd, Brian Norris,
	David Woodhouse

On 19.09.19 15:18, Miquel Raynal wrote:
> Hello,
> 
> Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Thu, 19 Sep
> 2019 13:15:08 +0000:
> 
>> On 19.09.19 14:58, Miquel Raynal wrote:
>>> Hi Piotr,
>>>
>>> Piotr Sroka <piotrs@cadence.com> wrote on Thu, 19 Sep 2019 13:41:35
>>> +0100:
>>>    
>>>> Change calculating of position page containing BBM
>>>>
>>>> If none of BBM flags is set then function nand_bbm_get_next_page
>>>> reports EINVAL. It causes that BBM is not read at all during scanning
>>>> factory bad blocks. The result is that the BBT table is build without
>>>> checking factory BBM at all. For Micron flash memories none of this
>>>> flag is set if page size is different than 2048 bytes.
>>
>> I wonder if it wouldn't be better to fix the Micron driver instead:
>>
>> --- a/drivers/mtd/nand/raw/nand_micron.c
>> +++ b/drivers/mtd/nand/raw/nand_micron.c
>> @@ -448,6 +448,8 @@ static int micron_nand_init(struct nand_chip *chip)
>>
>>           if (mtd->writesize == 2048)
>>                   chip->options |= NAND_BBM_FIRSTPAGE |
>>                                    NAND_BBM_SECONDPAGE;
>> +       else
>> +               chip->options |= NAND_BBM_FIRSTPAGE;
> 
> That's what I forgot in my last answer to this thread, I think I only
> told Piotr privately: I would like both. I think it is important to fix
> the bbm_get_next_page function but for clarity, setting the FIRSTPAGE
> flag in Micron's driver seems also pertinent.

Indeed, that sounds reasonable. Piotr, can you send another patch with 
the diff above? And by the way: thanks for fixing my code ;)

Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>

> 
>>
>>           ondie = micron_supports_on_die_ecc(chip);
>>
>>
>>>
>>> "none of these flags are set"
>>>    
>>>>
>>>> This patch changes the nand_bbm_get_next_page function.
>>>
>>> "Address this regression by changing the
>>> nand_bbm_get_next_page_function."
>>>    
>>>> It will return 0 if none of BBM flag is set and page parameter is 0.
>>>
>>>                         no BBM flag is set
>>>    
>>>> After that modification way of discovering factory bad blocks will work
>>>> similar as in kernel version 5.1.
>>>>   
>>>
>>> Fixes + stable tags would be great!
>>>    
>>>> Signed-off-by: Piotr Sroka <piotrs@cadence.com>
>>>> ---
>>>>    drivers/mtd/nand/raw/nand_base.c | 8 ++++++--
>>>>    1 file changed, 6 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>>>> index 5c2c30a7dffa..f64e3b6605c6 100644
>>>> --- a/drivers/mtd/nand/raw/nand_base.c
>>>> +++ b/drivers/mtd/nand/raw/nand_base.c
>>>> @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
>>>>    	struct mtd_info *mtd = nand_to_mtd(chip);
>>>>    	int last_page = ((mtd->erasesize - mtd->writesize) >>
>>>>    			 chip->page_shift) & chip->pagemask;
>>>> +	unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
>>>> +		| NAND_BBM_LASTPAGE;
>>>>    
>>>> +	if (page == 0 && !(chip->options & bbm_flags))
>>>> +		return 0;
>>>>    	if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
>>>>    		return 0;
>>>> -	else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>>>> +	if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>>>>    		return 1;
>>>> -	else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>>>> +	if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>>>>    		return last_page;
>>>>    
>>>>    	return -EINVAL;
>>>
>>> Lookgs good otherwise.
>>>
>>> Thanks,
>>> Miquèl
>>>   
> 
> Thanks,
> Miquèl
> 
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] - change calculating of position page containing BBM
  2019-09-19 13:33       ` Schrempf Frieder
@ 2019-09-23 12:13         ` Piotr Sroka
  0 siblings, 0 replies; 6+ messages in thread
From: Piotr Sroka @ 2019-09-23 12:13 UTC (permalink / raw)
  To: Schrempf Frieder
  Cc: Vignesh Raghavendra, Boris Brezillon, Richard Weinberger,
	linux-kernel, Marek Vasut, linux-mtd, Miquel Raynal,
	Brian Norris, David Woodhouse

Hello

The 09/19/2019 13:33, Schrempf Frieder wrote:
>EXTERNAL MAIL
>
>
>On 19.09.19 15:18, Miquel Raynal wrote:
>> Hello,
>>
>> Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Thu, 19 Sep
>> 2019 13:15:08 +0000:
>>
>>> On 19.09.19 14:58, Miquel Raynal wrote:
>>>> Hi Piotr,
>>>>
>>>> Piotr Sroka <piotrs@cadence.com> wrote on Thu, 19 Sep 2019 13:41:35
>>>> +0100:
>>>>
>>>>> Change calculating of position page containing BBM
>>>>>
>>>>> If none of BBM flags is set then function nand_bbm_get_next_page
>>>>> reports EINVAL. It causes that BBM is not read at all during scanning
>>>>> factory bad blocks. The result is that the BBT table is build without
>>>>> checking factory BBM at all. For Micron flash memories none of this
>>>>> flag is set if page size is different than 2048 bytes.
>>>
>>> I wonder if it wouldn't be better to fix the Micron driver instead:
>>>
>>> --- a/drivers/mtd/nand/raw/nand_micron.c
>>> +++ b/drivers/mtd/nand/raw/nand_micron.c
>>> @@ -448,6 +448,8 @@ static int micron_nand_init(struct nand_chip *chip)
>>>
>>>           if (mtd->writesize == 2048)
>>>                   chip->options |= NAND_BBM_FIRSTPAGE |
>>>                                    NAND_BBM_SECONDPAGE;
>>> +       else
>>> +               chip->options |= NAND_BBM_FIRSTPAGE;
>>
>> That's what I forgot in my last answer to this thread, I think I only
>> told Piotr privately: I would like both. I think it is important to fix
>> the bbm_get_next_page function but for clarity, setting the FIRSTPAGE
>> flag in Micron's driver seems also pertinent.
>
>Indeed, that sounds reasonable. Piotr, can you send another patch with
>the diff above? And by the way: thanks for fixing my code ;)
>
>Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
>
Thanks Frieder and Miquel for the very quick reply. I will send next
version containing Micron driver fix.

>>
>>>
>>>           ondie = micron_supports_on_die_ecc(chip);
>>>
>>>
>>>>
>>>> "none of these flags are set"
>>>>
>>>>>
>>>>> This patch changes the nand_bbm_get_next_page function.
>>>>
>>>> "Address this regression by changing the
>>>> nand_bbm_get_next_page_function."
>>>>
>>>>> It will return 0 if none of BBM flag is set and page parameter is 0.
>>>>
>>>>                         no BBM flag is set
>>>>
>>>>> After that modification way of discovering factory bad blocks will work
>>>>> similar as in kernel version 5.1.
>>>>>
>>>>
>>>> Fixes + stable tags would be great!
Ok I will add fixes tag and "Cc: <stable@vger.kernel.org>". 

>>>>
>>>>> Signed-off-by: Piotr Sroka <piotrs@cadence.com>
>>>>> ---
>>>>>    drivers/mtd/nand/raw/nand_base.c | 8 ++++++--
>>>>>    1 file changed, 6 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
>>>>> index 5c2c30a7dffa..f64e3b6605c6 100644
>>>>> --- a/drivers/mtd/nand/raw/nand_base.c
>>>>> +++ b/drivers/mtd/nand/raw/nand_base.c
>>>>> @@ -292,12 +292,16 @@ int nand_bbm_get_next_page(struct nand_chip *chip, int page)
>>>>>    	struct mtd_info *mtd = nand_to_mtd(chip);
>>>>>    	int last_page = ((mtd->erasesize - mtd->writesize) >>
>>>>>    			 chip->page_shift) & chip->pagemask;
>>>>> +	unsigned int bbm_flags = NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE
>>>>> +		| NAND_BBM_LASTPAGE;
>>>>>
>>>>> +	if (page == 0 && !(chip->options & bbm_flags))
>>>>> +		return 0;
>>>>>    	if (page == 0 && chip->options & NAND_BBM_FIRSTPAGE)
>>>>>    		return 0;
>>>>> -	else if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>>>>> +	if (page <= 1 && chip->options & NAND_BBM_SECONDPAGE)
>>>>>    		return 1;
>>>>> -	else if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>>>>> +	if (page <= last_page && chip->options & NAND_BBM_LASTPAGE)
>>>>>    		return last_page;
>>>>>
>>>>>    	return -EINVAL;
>>>>
>>>> Lookgs good otherwise.
>>>>
>>>> Thanks,
>>>> Miquèl
>>>>
>>
>> Thanks,
>> Miquèl
>>

Thanks,
Piotr

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

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-19 12:41 [PATCH] - change calculating of position page containing BBM Piotr Sroka
2019-09-19 12:58 ` Miquel Raynal
2019-09-19 13:15   ` Schrempf Frieder
2019-09-19 13:18     ` Miquel Raynal
2019-09-19 13:33       ` Schrempf Frieder
2019-09-23 12:13         ` Piotr Sroka

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox