Skip to contentSkip to conversation

hwrng: n2-drv - Use device_get_match_data() to simplify the code

PATCH In review [email protected] 2 participants 2 messages Nov 17, 2022 – Nov 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: n2-drv - Use device_get_match_data() to simplify the code

From: ye xingchen <[email protected]>

Directly get the match data with device_get_match_data().

---
 drivers/char/hw_random/n2-drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/char/hw_random/n2-drv.c +1 -6
index 73e408146420..2f784addb717 100644
@@ -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);
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Re: [PATCH linux-next] hwrng: n2-drv - Use device_get_match_data() to simplify the?? code

Quoted 22 lines · On Thu, Nov 17, 2022 at 05:10:15PM +0800, [email protected] wrote:

From: ye xingchen <[email protected]>

Directly get the match data with device_get_match_data().

---
 drivers/char/hw_random/n2-drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/char/hw_random/n2-drv.c +0 -2
index 73e408146420..2f784addb717 100644
@@ -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);

drivers/char/hw_random/n2-drv.c static void n2rng_driver_version(void) · line 706

Quoted 10 lines
drivers/char/hw_random/n2-drv.c +1 -4
-	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,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt