[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025090222-darn-tweet-739c@gregkh>
Date: Tue, 2 Sep 2025 14:20:14 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Zijun Hu <zijun_hu@...oud.com>
Cc: Dave Ertman <david.m.ertman@...el.com>, Ira Weiny <ira.weiny@...el.com>,
Leon Romanovsky <leon@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, linux-kernel@...r.kernel.org,
Zijun Hu <zijun.hu@....qualcomm.com>
Subject: Re: [PATCH] driver core: auxiliary bus: Optimize auxiliary_match_id()
On Tue, Sep 02, 2025 at 08:05:32PM +0800, Zijun Hu wrote:
> From: Zijun Hu <zijun.hu@....qualcomm.com>
>
> Variable @match_size is fixed in auxiliary_match_id().
>
> Optimize the function by moving the logic calculating the variable
> out of the for loop.
Optimize it how? Does this actually result in a difference somehow, if
so, what?
Please be specific.
> Signed-off-by: Zijun Hu <zijun.hu@....qualcomm.com>
> ---
> drivers/base/auxiliary.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
> index 12ffdd8437567f282374bbf3775d9de7ca0dc4c7..9a53ada043045031e565ade57fd7ba781e7d20ea 100644
> --- a/drivers/base/auxiliary.c
> +++ b/drivers/base/auxiliary.c
> @@ -171,14 +171,14 @@
> static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
> const struct auxiliary_device *auxdev)
> {
> - for (; id->name[0]; id++) {
> - const char *p = strrchr(dev_name(&auxdev->dev), '.');
> - int match_size;
> + const char *p = strrchr(dev_name(&auxdev->dev), '.');
> + int match_size;
>
> - if (!p)
> - continue;
> - match_size = p - dev_name(&auxdev->dev);
> + if (!p)
> + return NULL;
> + match_size = p - dev_name(&auxdev->dev);
>
> + for (; id->name[0]; id++) {
> /* use dev_name(&auxdev->dev) prefix before last '.' char to match to */
> if (strlen(id->name) == match_size &&
> !strncmp(dev_name(&auxdev->dev), id->name, match_size))
>
thanks,
greg k-h
Powered by blists - more mailing lists