Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: da9052_wdt: Drop reference counting

Reference counting is now implemented in the watchdog core and no longer
required in watchdog drivers.

Since it was implememented a no-op, and since the local memory is allocated
with devm_kzalloc(), the reference counting code in the driver really did
not really work anyway, and this patch effectively fixes a bug which could
cause a crash on unloading if the watchdog device was still open.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Guenter Roeck and committed by
Wim Van Sebroeck
756d1e92 b4ffb190

-24
-24
drivers/watchdog/da9052_wdt.c
··· 31 31 struct da9052_wdt_data { 32 32 struct watchdog_device wdt; 33 33 struct da9052 *da9052; 34 - struct kref kref; 35 34 unsigned long jpast; 36 35 }; 37 36 ··· 49 50 { 7, 131 }, 50 51 }; 51 52 52 - 53 - static void da9052_wdt_release_resources(struct kref *r) 54 - { 55 - } 56 53 57 54 static int da9052_wdt_set_timeout(struct watchdog_device *wdt_dev, 58 55 unsigned int timeout) ··· 97 102 } 98 103 99 104 return 0; 100 - } 101 - 102 - static void da9052_wdt_ref(struct watchdog_device *wdt_dev) 103 - { 104 - struct da9052_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev); 105 - 106 - kref_get(&driver_data->kref); 107 - } 108 - 109 - static void da9052_wdt_unref(struct watchdog_device *wdt_dev) 110 - { 111 - struct da9052_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev); 112 - 113 - kref_put(&driver_data->kref, da9052_wdt_release_resources); 114 105 } 115 106 116 107 static int da9052_wdt_start(struct watchdog_device *wdt_dev) ··· 151 170 .stop = da9052_wdt_stop, 152 171 .ping = da9052_wdt_ping, 153 172 .set_timeout = da9052_wdt_set_timeout, 154 - .ref = da9052_wdt_ref, 155 - .unref = da9052_wdt_unref, 156 173 }; 157 174 158 175 ··· 177 198 da9052_wdt->parent = &pdev->dev; 178 199 watchdog_set_drvdata(da9052_wdt, driver_data); 179 200 180 - kref_init(&driver_data->kref); 181 - 182 201 ret = da9052_reg_update(da9052, DA9052_CONTROL_D_REG, 183 202 DA9052_CONTROLD_TWDSCALE, 0); 184 203 if (ret < 0) { ··· 202 225 struct da9052_wdt_data *driver_data = platform_get_drvdata(pdev); 203 226 204 227 watchdog_unregister_device(&driver_data->wdt); 205 - kref_put(&driver_data->kref, da9052_wdt_release_resources); 206 228 207 229 return 0; 208 230 }