From: Niklas Cassel <cassel@kernel.org>
To: kensanya@163.com
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org, TanZheng <tanzheng@kylinos.cn>,
Michael Lazin <microlaser@gmail.com>
Subject: Re: [PATCH] ahci: use hweight_long() to count port_map bits
Date: Wed, 27 May 2026 15:10:23 +0200 [thread overview]
Message-ID: <ahbtP36yIfbPHcut@ryzen> (raw)
In-Reply-To: <20260527091729.266582-1-kensanya@163.com>
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
next prev parent reply other threads:[~2026-05-27 13:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 9:17 [PATCH] ahci: use hweight_long() to count port_map bits kensanya
2026-05-27 13:10 ` Niklas Cassel [this message]
2026-05-27 18:18 ` Damien Le Moal
2026-05-28 5:27 ` Damien Le Moal
2026-05-28 5:57 ` kensanya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ahbtP36yIfbPHcut@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=kensanya@163.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=microlaser@gmail.com \
--cc=tanzheng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox