@@ -364,9 +364,9 @@ void watchdog_unregister_device(struct watchdog_device *wdd)
EXPORT_SYMBOL_GPL(watchdog_unregister_device);
-static void devm_watchdog_unregister_device(struct device *dev, void *res)
+static void devm_watchdog_unregister_device(void *wdd)
{
- watchdog_unregister_device(*(struct watchdog_device **)res);
+ watchdog_unregister_device(wdd);
}
/**
@@ -381,23 +381,14 @@ static void devm_watchdog_unregister_device(struct device *dev, void *res)
int devm_watchdog_register_device(struct device *dev,
struct watchdog_device *wdd)
{
- struct watchdog_device **rcwdd;
int ret;
- rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*rcwdd),
- GFP_KERNEL);
- if (!rcwdd)
- return -ENOMEM;
-
ret = watchdog_register_device(wdd);
- if (!ret) {
- *rcwdd = wdd;
- devres_add(dev, rcwdd);
- } else {
- devres_free(rcwdd);
- }
+ if (ret)
+ return ret;
- return ret;
+ return devm_add_action_or_reset(dev, devm_watchdog_unregister_device,
+ wdd);
}
EXPORT_SYMBOL_GPL(devm_watchdog_register_device);