aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0383-driver-char-rpivid-Clean-up-error-handling-use-of-ER.patch
blob: b61e2c5cfe061dda2797130cb30763549b855562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 8b95d0d18fcfb940fb0d171663ce5c93b8fb0024 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Tue, 21 Jan 2020 16:24:45 +0000
Subject: [PATCH] driver: char: rpivid: Clean up error handling use of
 ERR_PTR/IS_ERR

The driver used an unnecessary intermediate void* variable so it
only called ERR_PTR once to convert to the error value.

Switch to converting as the error arises to remove these intermediate
variables.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/char/broadcom/rpivid-mem.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

--- a/drivers/char/broadcom/rpivid-mem.c
+++ b/drivers/char/broadcom/rpivid-mem.c
@@ -130,10 +130,8 @@ static const struct of_device_id rpivid_
 static int rpivid_mem_probe(struct platform_device *pdev)
 {
 	int err;
-	void *ptr_err;
 	const struct of_device_id *id;
 	struct device *dev = &pdev->dev;
-	struct device *rpivid_mem_dev;
 	struct resource *ioresource;
 	struct rpivid_mem_priv *priv;
 
@@ -183,16 +181,16 @@ static int rpivid_mem_probe(struct platf
 	/* Create sysfs entries */
 
 	priv->class = class_create(THIS_MODULE, priv->name);
-	ptr_err = priv->class;
-	if (IS_ERR(ptr_err))
+	if (IS_ERR(priv->class)) {
+		err = PTR_ERR(priv->class);
 		goto failed_class_create;
+	}
 
-	rpivid_mem_dev = device_create(priv->class, NULL,
-					priv->devid, NULL,
-					priv->name);
-	ptr_err = rpivid_mem_dev;
-	if (IS_ERR(ptr_err))
+	dev = device_create(priv->class, NULL, priv->devid, NULL, priv->name);
+	if (IS_ERR(dev)) {
+		err = PTR_ERR(dev);
 		goto failed_device_create;
+	}
 
 	/* Legacy alias */
 	{
@@ -217,7 +215,6 @@ failed_device_create:
 	class_destroy(priv->class);
 failed_class_create:
 	cdev_del(&priv->rpivid_mem_cdev);
-	err = PTR_ERR(ptr_err);
 failed_cdev_add:
 	unregister_chrdev_region(priv->devid, 1);
 failed_alloc_chrdev: