linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX
@ 2016-12-20 13:54 Geliang Tang
  2016-12-23 18:51 ` Marek Vasut
  2017-04-19 20:14 ` Brian Norris
  0 siblings, 2 replies; 5+ messages in thread
From: Geliang Tang @ 2016-12-20 13:54 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen
  Cc: Geliang Tang, linux-mtd, linux-kernel

Since macros MTDSWAP_ECNT_MIN() and MTDSWAP_ECNT_MAX() have been
defined in mtdswap.c, use them instead of open-coding.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/mtd/mtdswap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index c40e2c9..f12879a 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1235,10 +1235,8 @@ static int mtdswap_show(struct seq_file *s, void *data)
 
 		if (root->rb_node) {
 			count[i] = d->trees[i].count;
-			min[i] = rb_entry(rb_first(root), struct swap_eb,
-					rb)->erase_count;
-			max[i] = rb_entry(rb_last(root), struct swap_eb,
-					rb)->erase_count;
+			min[i] = MTDSWAP_ECNT_MIN(root);
+			max[i] = MTDSWAP_ECNT_MAX(root);
 		} else
 			count[i] = 0;
 	}
-- 
2.9.3

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

* Re: [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX
  2016-12-20 13:54 [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX Geliang Tang
@ 2016-12-23 18:51 ` Marek Vasut
  2016-12-24 15:18   ` Geliang Tang
  2017-04-19 20:14 ` Brian Norris
  1 sibling, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2016-12-23 18:51 UTC (permalink / raw)
  To: Geliang Tang, David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen
  Cc: linux-mtd, linux-kernel

On 12/20/2016 02:54 PM, Geliang Tang wrote:
> Since macros MTDSWAP_ECNT_MIN() and MTDSWAP_ECNT_MAX() have been
> defined in mtdswap.c, use them instead of open-coding.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Sorry for getting to this so late. The patch is fine, but if you grep
for 'rb_first' in the mtdswap driver , you'll see you can also use the
MTDSWAP_ECNT_MIN macro in mtdswap_map_free_block() and in
mtdswap_pick_gc_blk() . Can you fix those too ?

Otherwise:
Acked-by: Marek Vasut <marek.vasut@gmail.com>

> ---
>  drivers/mtd/mtdswap.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
> index c40e2c9..f12879a 100644
> --- a/drivers/mtd/mtdswap.c
> +++ b/drivers/mtd/mtdswap.c
> @@ -1235,10 +1235,8 @@ static int mtdswap_show(struct seq_file *s, void *data)
>  
>  		if (root->rb_node) {
>  			count[i] = d->trees[i].count;
> -			min[i] = rb_entry(rb_first(root), struct swap_eb,
> -					rb)->erase_count;
> -			max[i] = rb_entry(rb_last(root), struct swap_eb,
> -					rb)->erase_count;
> +			min[i] = MTDSWAP_ECNT_MIN(root);
> +			max[i] = MTDSWAP_ECNT_MAX(root);
>  		} else
>  			count[i] = 0;
>  	}
> 


-- 
Best regards,
Marek Vasut

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

* Re: [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX
  2016-12-23 18:51 ` Marek Vasut
@ 2016-12-24 15:18   ` Geliang Tang
  2016-12-25 13:49     ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: Geliang Tang @ 2016-12-24 15:18 UTC (permalink / raw)
  To: Marek Vasut
  Cc: David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen, linux-mtd, linux-kernel

On Fri, Dec 23, 2016 at 07:51:56PM +0100, Marek Vasut wrote:
> On 12/20/2016 02:54 PM, Geliang Tang wrote:
> > Since macros MTDSWAP_ECNT_MIN() and MTDSWAP_ECNT_MAX() have been
> > defined in mtdswap.c, use them instead of open-coding.
> > 
> > Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> 
> Sorry for getting to this so late. The patch is fine, but if you grep
> for 'rb_first' in the mtdswap driver , you'll see you can also use the
> MTDSWAP_ECNT_MIN macro in mtdswap_map_free_block() and in
> mtdswap_pick_gc_blk() . Can you fix those too ?

Hi Marek,

Thanks for your review. I double checked the code and found out that we can't
use MTDSWAP_ECNT_MIN macro in mtdswap_map_free_block() and mtdswap_pick_gc_eblk().
Since the MTDSWAP_ECNT_MIN macro points to erase_count field of swap_eb, and
erase_count field are not used in these two functions. Isn't it?

-Geliang

> 
> Otherwise:
> Acked-by: Marek Vasut <marek.vasut@gmail.com>
> 
> > ---
> >  drivers/mtd/mtdswap.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
> > index c40e2c9..f12879a 100644
> > --- a/drivers/mtd/mtdswap.c
> > +++ b/drivers/mtd/mtdswap.c
> > @@ -1235,10 +1235,8 @@ static int mtdswap_show(struct seq_file *s, void *data)
> >  
> >  		if (root->rb_node) {
> >  			count[i] = d->trees[i].count;
> > -			min[i] = rb_entry(rb_first(root), struct swap_eb,
> > -					rb)->erase_count;
> > -			max[i] = rb_entry(rb_last(root), struct swap_eb,
> > -					rb)->erase_count;
> > +			min[i] = MTDSWAP_ECNT_MIN(root);
> > +			max[i] = MTDSWAP_ECNT_MAX(root);
> >  		} else
> >  			count[i] = 0;
> >  	}
> > 
> 
> 
> -- 
> Best regards,
> Marek Vasut

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

* Re: [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX
  2016-12-24 15:18   ` Geliang Tang
@ 2016-12-25 13:49     ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2016-12-25 13:49 UTC (permalink / raw)
  To: Geliang Tang
  Cc: David Woodhouse, Brian Norris, Boris Brezillon,
	Richard Weinberger, Cyrille Pitchen, linux-mtd, linux-kernel

On 12/24/2016 04:18 PM, Geliang Tang wrote:
> On Fri, Dec 23, 2016 at 07:51:56PM +0100, Marek Vasut wrote:
>> On 12/20/2016 02:54 PM, Geliang Tang wrote:
>>> Since macros MTDSWAP_ECNT_MIN() and MTDSWAP_ECNT_MAX() have been
>>> defined in mtdswap.c, use them instead of open-coding.
>>>
>>> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
>>
>> Sorry for getting to this so late. The patch is fine, but if you grep
>> for 'rb_first' in the mtdswap driver , you'll see you can also use the
>> MTDSWAP_ECNT_MIN macro in mtdswap_map_free_block() and in
>> mtdswap_pick_gc_blk() . Can you fix those too ?
> 
> Hi Marek,
> 
> Thanks for your review. I double checked the code and found out that we can't
> use MTDSWAP_ECNT_MIN macro in mtdswap_map_free_block() and mtdswap_pick_gc_eblk().
> Since the MTDSWAP_ECNT_MIN macro points to erase_count field of swap_eb, and
> erase_count field are not used in these two functions. Isn't it?

Ah, true, I missed that. In that case, just this patch is fine, thanks !

> -Geliang
> 
>>
>> Otherwise:
>> Acked-by: Marek Vasut <marek.vasut@gmail.com>
>>
>>> ---
>>>  drivers/mtd/mtdswap.c | 6 ++----
>>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
>>> index c40e2c9..f12879a 100644
>>> --- a/drivers/mtd/mtdswap.c
>>> +++ b/drivers/mtd/mtdswap.c
>>> @@ -1235,10 +1235,8 @@ static int mtdswap_show(struct seq_file *s, void *data)
>>>  
>>>  		if (root->rb_node) {
>>>  			count[i] = d->trees[i].count;
>>> -			min[i] = rb_entry(rb_first(root), struct swap_eb,
>>> -					rb)->erase_count;
>>> -			max[i] = rb_entry(rb_last(root), struct swap_eb,
>>> -					rb)->erase_count;
>>> +			min[i] = MTDSWAP_ECNT_MIN(root);
>>> +			max[i] = MTDSWAP_ECNT_MAX(root);
>>>  		} else
>>>  			count[i] = 0;
>>>  	}
>>>
>>
>>
>> -- 
>> Best regards,
>> Marek Vasut


-- 
Best regards,
Marek Vasut

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

* Re: [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX
  2016-12-20 13:54 [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX Geliang Tang
  2016-12-23 18:51 ` Marek Vasut
@ 2017-04-19 20:14 ` Brian Norris
  1 sibling, 0 replies; 5+ messages in thread
From: Brian Norris @ 2017-04-19 20:14 UTC (permalink / raw)
  To: Geliang Tang
  Cc: David Woodhouse, Boris Brezillon, Marek Vasut,
	Richard Weinberger, Cyrille Pitchen, linux-mtd, linux-kernel

On Tue, Dec 20, 2016 at 09:54:33PM +0800, Geliang Tang wrote:
> Since macros MTDSWAP_ECNT_MIN() and MTDSWAP_ECNT_MAX() have been
> defined in mtdswap.c, use them instead of open-coding.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied to l2-mtd.git

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

end of thread, other threads:[~2017-04-19 20:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 13:54 [PATCH] mtd: mtdswap: use MTDSWAP_ECNT_MIN/MAX Geliang Tang
2016-12-23 18:51 ` Marek Vasut
2016-12-24 15:18   ` Geliang Tang
2016-12-25 13:49     ` Marek Vasut
2017-04-19 20:14 ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).