[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DCJ52UB7OIXR.3MS54RJKMI4OK@kernel.org>
Date: Wed, 03 Sep 2025 13:46:58 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Zijun Hu" <zijun_hu@...oud.com>
Cc: "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>, "Dave Ertman"
<david.m.ertman@...el.com>, "Ira Weiny" <ira.weiny@...el.com>, "Leon
Romanovsky" <leon@...nel.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
<linux-kernel@...r.kernel.org>, "Zijun Hu" <zijun.hu@....qualcomm.com>
Subject: Re: [PATCH v2] driver core: auxiliary bus: Optimize logic of
auxiliary_match_id()
On Wed Sep 3, 2025 at 1:37 PM CEST, Zijun Hu wrote:
> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
> index 12ffdd8437567f282374bbf3775d9de7ca0dc4c7..ed2537cf3b048149e784e5a582631db549050734 100644
> --- a/drivers/base/auxiliary.c
> +++ b/drivers/base/auxiliary.c
> @@ -171,17 +171,18 @@
> 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 *auxdev_name = dev_name(&auxdev->dev);
I feel like this is a bit too ambitious. Using dev_name() directly for the calls
below seems more obvious to me.
Yes, dev_name() contains a branch, but I'm pretty sure the compiler optimizes
them away for subsequent calls anyways.
> + const char *p = strrchr(auxdev_name, '.');
> + int match_size;
>
> - if (!p)
> - continue;
> - match_size = p - dev_name(&auxdev->dev);
> + if (!p)
> + return NULL;
> + match_size = p - auxdev_name;
>
> + 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))
> + !strncmp(auxdev_name, id->name, match_size))
> return id;
> }
> return NULL;
>
> ---
> base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
> change-id: 20250902-fix_auxbus-76bec91376db
>
> Best regards,
> --
> Zijun Hu <zijun.hu@....qualcomm.com>
Powered by blists - more mailing lists