[PATCH v2 3/3] bcache: Use of hlist_count_nodes()

Pierre Gondois posted 3 patches 1 year, 11 months ago
[PATCH v2 3/3] bcache: Use of hlist_count_nodes()
Posted by Pierre Gondois 1 year, 11 months ago
Make use of the newly added hlist_count_nodes().

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/md/bcache/sysfs.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index a438efb66069..6956beb55326 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -702,13 +702,7 @@ static unsigned int bch_cache_max_chain(struct cache_set *c)
 	for (h = c->bucket_hash;
 	     h < c->bucket_hash + (1 << BUCKET_HASH_BITS);
 	     h++) {
-		unsigned int i = 0;
-		struct hlist_node *p;
-
-		hlist_for_each(p, h)
-			i++;
-
-		ret = max(ret, i);
+		ret = max(ret, hlist_count_nodes(h));
 	}
 
 	mutex_unlock(&c->bucket_lock);
-- 
2.25.1
Re: [PATCH v2 3/3] bcache: Use of hlist_count_nodes()
Posted by Andy Shevchenko 1 year, 11 months ago
On Thu, Jan 04, 2024 at 05:49:35PM +0100, Pierre Gondois wrote:
> Make use of the newly added hlist_count_nodes().

...

>  	for (h = c->bucket_hash;
>  	     h < c->bucket_hash + (1 << BUCKET_HASH_BITS);
>  	     h++) {
> -		unsigned int i = 0;
> -		struct hlist_node *p;
> -
> -		hlist_for_each(p, h)
> -			i++;
> -
> -		ret = max(ret, i);
> +		ret = max(ret, hlist_count_nodes(h));
>  	}

After this you probably may drop {}.


-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 3/3] bcache: Use of hlist_count_nodes()
Posted by Coly Li 1 year, 11 months ago
On Thu, Jan 04, 2024 at 05:49:35PM +0100, Pierre Gondois wrote:
> Make use of the newly added hlist_count_nodes().
> 
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>

Acked-by: Coly Li <colyli@suse.de>

Thanks.

> ---
>  drivers/md/bcache/sysfs.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index a438efb66069..6956beb55326 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -702,13 +702,7 @@ static unsigned int bch_cache_max_chain(struct cache_set *c)
>  	for (h = c->bucket_hash;
>  	     h < c->bucket_hash + (1 << BUCKET_HASH_BITS);
>  	     h++) {
> -		unsigned int i = 0;
> -		struct hlist_node *p;
> -
> -		hlist_for_each(p, h)
> -			i++;
> -
> -		ret = max(ret, i);
> +		ret = max(ret, hlist_count_nodes(h));
>  	}
>  
>  	mutex_unlock(&c->bucket_lock);
> -- 
> 2.25.1
> 
> 

-- 
Coly Li