3cf723a9bcb58dc1df215eff030335c8247edb23
[openwrt/staging/chunkeey.git] /
1 From 43f676ace2e0591718ff493d290bc49b35ec2ffc Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Fri, 25 Dec 2015 16:01:44 -0800
4 Subject: watchdog: da9055_wdt: Drop reference counting
5
6 Reference counting is now implemented in the watchdog core and no longer
7 required in watchdog drivers.
8
9 Since it was implememented a no-op, and since the local memory is allocated
10 with devm_kzalloc(), the reference counting code in the driver really did
11 not really work anyway, and this patch effectively fixes a bug which could
12 cause a crash on unloading if the watchdog device was still open.
13
14 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
15 Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
16 ---
17 drivers/watchdog/da9055_wdt.c | 24 ------------------------
18 1 file changed, 24 deletions(-)
19
20 --- a/drivers/watchdog/da9055_wdt.c
21 +++ b/drivers/watchdog/da9055_wdt.c
22 @@ -35,7 +35,6 @@ MODULE_PARM_DESC(nowayout,
23 struct da9055_wdt_data {
24 struct watchdog_device wdt;
25 struct da9055 *da9055;
26 - struct kref kref;
27 };
28
29 static const struct {
30 @@ -99,24 +98,6 @@ static int da9055_wdt_ping(struct watchd
31 DA9055_WATCHDOG_MASK, 1);
32 }
33
34 -static void da9055_wdt_release_resources(struct kref *r)
35 -{
36 -}
37 -
38 -static void da9055_wdt_ref(struct watchdog_device *wdt_dev)
39 -{
40 - struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
41 -
42 - kref_get(&driver_data->kref);
43 -}
44 -
45 -static void da9055_wdt_unref(struct watchdog_device *wdt_dev)
46 -{
47 - struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
48 -
49 - kref_put(&driver_data->kref, da9055_wdt_release_resources);
50 -}
51 -
52 static int da9055_wdt_start(struct watchdog_device *wdt_dev)
53 {
54 return da9055_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
55 @@ -138,8 +119,6 @@ static const struct watchdog_ops da9055_
56 .stop = da9055_wdt_stop,
57 .ping = da9055_wdt_ping,
58 .set_timeout = da9055_wdt_set_timeout,
59 - .ref = da9055_wdt_ref,
60 - .unref = da9055_wdt_unref,
61 };
62
63 static int da9055_wdt_probe(struct platform_device *pdev)
64 @@ -165,8 +144,6 @@ static int da9055_wdt_probe(struct platf
65 watchdog_set_nowayout(da9055_wdt, nowayout);
66 watchdog_set_drvdata(da9055_wdt, driver_data);
67
68 - kref_init(&driver_data->kref);
69 -
70 ret = da9055_wdt_stop(da9055_wdt);
71 if (ret < 0) {
72 dev_err(&pdev->dev, "Failed to stop watchdog, %d\n", ret);
73 @@ -189,7 +166,6 @@ static int da9055_wdt_remove(struct plat
74 struct da9055_wdt_data *driver_data = platform_get_drvdata(pdev);
75
76 watchdog_unregister_device(&driver_data->wdt);
77 - kref_put(&driver_data->kref, da9055_wdt_release_resources);
78
79 return 0;
80 }