public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the   code
@ 2022-11-17  9:10 ye.xingchen
  2022-11-25  8:56 ` [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the?? code Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: ye.xingchen @ 2022-11-17  9:10 UTC (permalink / raw)
  To: herbert; +Cc: olivia, linux-crypto, linux-kernel

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);

 	INIT_DELAYED_WORK(&np->work, n2rng_work);

-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the?? code
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2022-11-25  8:56 UTC (permalink / raw)
  To: ye.xingchen; +Cc: olivia, linux-crypto, linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-25  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the?? code Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox