mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Zijun Hu <zijun_hu@icloud.com>
Cc: Dave Ertman <david.m.ertman@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Leon Romanovsky <leon@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	linux-kernel@vger.kernel.org,
	Zijun Hu <zijun.hu@oss.qualcomm.com>
Subject: Re: [PATCH] driver core: auxiliary bus: Optimize auxiliary_match_id()
Date: Tue, 2 Sep 2025 14:20:14 +0200	[thread overview]
Message-ID: <2025090222-darn-tweet-739c@gregkh> (raw)
In-Reply-To: <20250902-fix_auxbus-v1-1-9ba6d8aff027@oss.qualcomm.com>

On Tue, Sep 02, 2025 at 08:05:32PM +0800, Zijun Hu wrote:
> From: Zijun Hu <zijun.hu@oss.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@oss.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

  reply	other threads:[~2025-09-02 12:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 12:05 Zijun Hu
2025-09-02 12:20 ` Greg Kroah-Hartman [this message]
2025-09-02 12:42   ` Zijun Hu
2025-09-02 12:49     ` Leon Romanovsky
2025-09-02 12:51     ` Greg Kroah-Hartman
2025-09-02 13:06       ` Zijun Hu

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=2025090222-darn-tweet-739c@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dakr@kernel.org \
    --cc=david.m.ertman@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=zijun.hu@oss.qualcomm.com \
    --cc=zijun_hu@icloud.com \
    /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

all inboxes | Powered by JetHome®