mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: ye.xingchen@zte.com.cn
Cc: olivia@selenic.com, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the?? code
Date: Fri, 25 Nov 2022 16:56:23 +0800	[thread overview]
Message-ID: <Y4CDN4eWfXtAKAdN@gondor.apana.org.au> (raw)
In-Reply-To: <202211171710153200734@zte.com.cn>

On Thu, Nov 17, 2022 at 05:10:15PM +0800, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Directly get the match data with device_get_match_data().
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
>  drivers/char/hw_random/n2-drv.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
> index 73e408146420..2f784addb717 100644
> --- a/drivers/char/hw_random/n2-drv.c
> +++ b/drivers/char/hw_random/n2-drv.c
> @@ -695,20 +695,15 @@ static void n2rng_driver_version(void)
>  static const struct of_device_id n2rng_match[];
>  static int n2rng_probe(struct platform_device *op)
>  {
> -	const struct of_device_id *match;
>  	int err = -ENOMEM;
>  	struct n2rng *np;
> 
> -	match = of_match_device(n2rng_match, &op->dev);
> -	if (!match)
> -		return -EINVAL;
> -
>  	n2rng_driver_version();
>  	np = devm_kzalloc(&op->dev, sizeof(*np), GFP_KERNEL);
>  	if (!np)
>  		goto out;
>  	np->op = op;
> -	np->data = (struct n2rng_template *)match->data;
> +	np->data = (struct n2rng_template *) device_get_match_data(&op->dev);

Please explain why changing the error case is OK.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2022-11-25  8:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  9:10 [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the code ye.xingchen
2022-11-25  8:56 ` Herbert Xu [this message]

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=Y4CDN4eWfXtAKAdN@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivia@selenic.com \
    --cc=ye.xingchen@zte.com.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

all inboxes | Powered by JetHome®