mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Zijun Hu <quic_zijuhu@quicinc.com>
Cc: linux-kernel@vger.kernel.org, rafael@kernel.org, brgl@bgdev.pl,
	madalin.bucur@nxp.com, davem@davemloft.net,
	andriy.shevchenko@linux.intel.com
Subject: Re: [PATCH v1 4/5] devres: Simplify devm_percpu_match() implementation
Date: Thu, 4 Jul 2024 12:34:00 +0200	[thread overview]
Message-ID: <2024070424-deplete-dangling-bcc6@gregkh> (raw)
In-Reply-To: <1719931914-19035-5-git-send-email-quic_zijuhu@quicinc.com>

On Tue, Jul 02, 2024 at 10:51:53PM +0800, Zijun Hu wrote:
> Simplify devm_percpu_match() implementation by removing redundant
> conversions.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> Previous discussion link:
> https://lore.kernel.org/lkml/1719496036-24642-1-git-send-email-quic_zijuhu@quicinc.com/
> 
> Changes since the original one:
>  - Select the simplier solution
> 
>  drivers/base/devres.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index e9b0d94aeabd..2ad6dacb3472 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -1176,9 +1176,8 @@ static void devm_percpu_release(struct device *dev, void *pdata)
>  
>  static int devm_percpu_match(struct device *dev, void *data, void *p)
>  {
> -	struct devres *devr = container_of(data, struct devres, data);
> -
> -	return *(void **)devr->data == p;
> +	/* @data is already and must be (void *)devr->data */
> +	return *(void **)data == p;

The compiler output should be identical here, right?  And container_of()
enforces the placement so I'd prefer the original here as a comment
isn't going to enforce anything :)

thanks,

greg k-h

  reply	other threads:[~2024-07-04 10:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 14:51 [PATCH v1 0/5] Collection of my bug fixes and code optimizations for devres Zijun Hu
2024-07-02 14:51 ` [PATCH v1 1/5] devres: Fix devm_krealloc() wasting memory Zijun Hu
2024-07-02 14:51 ` [PATCH v1 2/5] devres: Fix memory leakage caused by driver API devm_free_percpu() Zijun Hu
2024-07-02 14:51 ` [PATCH v1 3/5] devres: Initialize an uninitialized struct member Zijun Hu
2024-07-02 14:51 ` [PATCH v1 4/5] devres: Simplify devm_percpu_match() implementation Zijun Hu
2024-07-04 10:34   ` Greg KH [this message]
2024-07-04 13:17     ` quic_zijuhu
2024-07-08 13:50       ` quic_zijuhu
2024-07-02 14:51 ` [PATCH v1 5/5] devres: Correct code style for functions that return a pointer type 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=2024070424-deplete-dangling-bcc6@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=quic_zijuhu@quicinc.com \
    --cc=rafael@kernel.org \
    /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®