All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ahci: use hweight_long() to count port_map bits
@ 2026-05-27  9:17 kensanya
  2026-05-27 13:10 ` Niklas Cassel
  2026-05-27 18:18 ` Damien Le Moal
  0 siblings, 2 replies; 5+ messages in thread
From: kensanya @ 2026-05-27  9:17 UTC (permalink / raw)
  To: dlemoal, cassel; +Cc: linux-ide, linux-kernel, TanZheng

From: TanZheng <tanzheng@kylinos.cn>

Replace the open loop used to calculate the number of set bits
in the port mapping with the `hweight_long()` function, which
simplifies the code without altering its functionality.

Signed-off-by: TanZheng <tanzheng@kylinos.cn>
---
 drivers/ata/libahci.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index c79abdfcd7a9..15d44266c9df 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -552,11 +552,7 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
 
 	/* cross check port_map and cap.n_ports */
 	if (port_map) {
-		int map_ports = 0;
-
-		for (i = 0; i < AHCI_MAX_PORTS; i++)
-			if (port_map & (1 << i))
-				map_ports++;
+		int map_ports = hweight_long(port_map);
 
 		/* If PI has more ports than n_ports, whine, clear
 		 * port_map and let it be generated from n_ports.
-- 
2.25.1


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

* Re: [PATCH] ahci: use hweight_long() to count port_map bits
  2026-05-27  9:17 [PATCH] ahci: use hweight_long() to count port_map bits kensanya
@ 2026-05-27 13:10 ` Niklas Cassel
  2026-05-27 18:18 ` Damien Le Moal
  1 sibling, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2026-05-27 13:10 UTC (permalink / raw)
  To: kensanya; +Cc: dlemoal, linux-ide, linux-kernel, TanZheng, Michael Lazin

On Wed, May 27, 2026 at 05:17:29PM +0800, kensanya@163.com wrote:
> From: TanZheng <tanzheng@kylinos.cn>
> 
> Replace the open loop used to calculate the number of set bits
> in the port mapping with the `hweight_long()` function, which
> simplifies the code without altering its functionality.
> 
> Signed-off-by: TanZheng <tanzheng@kylinos.cn>
> ---
>  drivers/ata/libahci.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index c79abdfcd7a9..15d44266c9df 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -552,11 +552,7 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
>  
>  	/* cross check port_map and cap.n_ports */
>  	if (port_map) {
> -		int map_ports = 0;
> -
> -		for (i = 0; i < AHCI_MAX_PORTS; i++)
> -			if (port_map & (1 << i))
> -				map_ports++;
> +		int map_ports = hweight_long(port_map);
>  
>  		/* If PI has more ports than n_ports, whine, clear
>  		 * port_map and let it be generated from n_ports.
> -- 
> 2.25.1
> 

Hello TanZheng,

Is it a coincidence that you send this the same day as Michael pointed out
the same, or was this sent as a response to Michael's email?


Kind regards,
Niklas

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

* Re: [PATCH] ahci: use hweight_long() to count port_map bits
  2026-05-27  9:17 [PATCH] ahci: use hweight_long() to count port_map bits kensanya
  2026-05-27 13:10 ` Niklas Cassel
@ 2026-05-27 18:18 ` Damien Le Moal
  2026-05-28  5:27   ` Damien Le Moal
  1 sibling, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2026-05-27 18:18 UTC (permalink / raw)
  To: kensanya, cassel; +Cc: linux-ide, linux-kernel, TanZheng

On 2026/05/27 18:17, kensanya@163.com wrote:
> From: TanZheng <tanzheng@kylinos.cn>
> 
> Replace the open loop used to calculate the number of set bits
> in the port mapping with the `hweight_long()` function, which
> simplifies the code without altering its functionality.
> 
> Signed-off-by: TanZheng <tanzheng@kylinos.cn>

This looks good to me. But as Niklas commented, if this needs a Suggested-by
tag, please add it.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

-- 
Damien Le Moal
Western Digital Research

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

* Re: [PATCH] ahci: use hweight_long() to count port_map bits
  2026-05-27 18:18 ` Damien Le Moal
@ 2026-05-28  5:27   ` Damien Le Moal
  2026-05-28  5:57     ` kensanya
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2026-05-28  5:27 UTC (permalink / raw)
  To: kensanya, cassel; +Cc: linux-ide, linux-kernel, TanZheng

On 5/28/26 03:18, Damien Le Moal wrote:
> On 2026/05/27 18:17, kensanya@163.com wrote:
>> From: TanZheng <tanzheng@kylinos.cn>
>>
>> Replace the open loop used to calculate the number of set bits
>> in the port mapping with the `hweight_long()` function, which
>> simplifies the code without altering its functionality.
>>
>> Signed-off-by: TanZheng <tanzheng@kylinos.cn>
> 
> This looks good to me. But as Niklas commented, if this needs a Suggested-by
> tag, please add it.
> 
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

Note: the patch title should be:

ata: libahci: use hweight_long() to count port_map bits

Maybe Niklas can fix this when applying.


-- 
Damien Le Moal
Western Digital Research

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

* Re:Re: [PATCH] ahci: use hweight_long() to count port_map bits
  2026-05-28  5:27   ` Damien Le Moal
@ 2026-05-28  5:57     ` kensanya
  0 siblings, 0 replies; 5+ messages in thread
From: kensanya @ 2026-05-28  5:57 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: cassel, linux-ide, linux-kernel, TanZheng


















At 2026-05-28 13:27:15, "Damien Le Moal" <dlemoal@kernel.org> wrote:
>On 5/28/26 03:18, Damien Le Moal wrote:
>> On 2026/05/27 18:17, kensanya@163.com wrote:
>>> From: TanZheng <tanzheng@kylinos.cn>
>>>
>>> Replace the open loop used to calculate the number of set bits
>>> in the port mapping with the `hweight_long()` function, which
>>> simplifies the code without altering its functionality.
>>>
>>> Signed-off-by: TanZheng <tanzheng@kylinos.cn>
>> 
>> This looks good to me. But as Niklas commented, if this needs a Suggested-by
>> tag, please add it.
>> 
>> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
>
>Note: the patch title should be:
>
>ata: libahci: use hweight_long() to count port_map bits
>
>Maybe Niklas can fix this when applying.
>
>
>-- 
>Damien Le Moal
>Western Digital Research

Hi

I will modify the patch title and resend the patch.

Bset regards,
TanZheng


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

end of thread, other threads:[~2026-05-28  5:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27  9:17 [PATCH] ahci: use hweight_long() to count port_map bits kensanya
2026-05-27 13:10 ` Niklas Cassel
2026-05-27 18:18 ` Damien Le Moal
2026-05-28  5:27   ` Damien Le Moal
2026-05-28  5:57     ` kensanya

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.