b61e2c5cfe061dda2797130cb30763549b855562
[openwrt/staging/wigyori.git] /
1 From 8b95d0d18fcfb940fb0d171663ce5c93b8fb0024 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 21 Jan 2020 16:24:45 +0000
4 Subject: [PATCH] driver: char: rpivid: Clean up error handling use of
5 ERR_PTR/IS_ERR
6
7 The driver used an unnecessary intermediate void* variable so it
8 only called ERR_PTR once to convert to the error value.
9
10 Switch to converting as the error arises to remove these intermediate
11 variables.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 ---
15 drivers/char/broadcom/rpivid-mem.c | 17 +++++++----------
16 1 file changed, 7 insertions(+), 10 deletions(-)
17
18 --- a/drivers/char/broadcom/rpivid-mem.c
19 +++ b/drivers/char/broadcom/rpivid-mem.c
20 @@ -130,10 +130,8 @@ static const struct of_device_id rpivid_
21 static int rpivid_mem_probe(struct platform_device *pdev)
22 {
23 int err;
24 - void *ptr_err;
25 const struct of_device_id *id;
26 struct device *dev = &pdev->dev;
27 - struct device *rpivid_mem_dev;
28 struct resource *ioresource;
29 struct rpivid_mem_priv *priv;
30
31 @@ -183,16 +181,16 @@ static int rpivid_mem_probe(struct platf
32 /* Create sysfs entries */
33
34 priv->class = class_create(THIS_MODULE, priv->name);
35 - ptr_err = priv->class;
36 - if (IS_ERR(ptr_err))
37 + if (IS_ERR(priv->class)) {
38 + err = PTR_ERR(priv->class);
39 goto failed_class_create;
40 + }
41
42 - rpivid_mem_dev = device_create(priv->class, NULL,
43 - priv->devid, NULL,
44 - priv->name);
45 - ptr_err = rpivid_mem_dev;
46 - if (IS_ERR(ptr_err))
47 + dev = device_create(priv->class, NULL, priv->devid, NULL, priv->name);
48 + if (IS_ERR(dev)) {
49 + err = PTR_ERR(dev);
50 goto failed_device_create;
51 + }
52
53 /* Legacy alias */
54 {
55 @@ -217,7 +215,6 @@ failed_device_create:
56 class_destroy(priv->class);
57 failed_class_create:
58 cdev_del(&priv->rpivid_mem_cdev);
59 - err = PTR_ERR(ptr_err);
60 failed_cdev_add:
61 unregister_chrdev_region(priv->devid, 1);
62 failed_alloc_chrdev: