watchdog: core: Remove usage of the deprecated ida_simple_xx() API
ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove(). Note that the upper limit of ida_simple_get() is exclusive, but the one of ida_alloc_range()/ida_alloc_max() is inclusive. So a -1 has been added when needed. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/bc5b82db59ccac69f2612ba104e2f5100401a862.1705009009.git.christophe.jaillet@wanadoo.fr Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
This commit is contained in:
parent
41bccc98fb
commit
b568b1504d
@ -260,12 +260,12 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
|
|||||||
if (wdd->parent) {
|
if (wdd->parent) {
|
||||||
ret = of_alias_get_id(wdd->parent->of_node, "watchdog");
|
ret = of_alias_get_id(wdd->parent->of_node, "watchdog");
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
id = ida_simple_get(&watchdog_ida, ret,
|
id = ida_alloc_range(&watchdog_ida, ret, ret,
|
||||||
ret + 1, GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL);
|
id = ida_alloc_max(&watchdog_ida, MAX_DOGS - 1, GFP_KERNEL);
|
||||||
|
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
return id;
|
return id;
|
||||||
@ -273,19 +273,20 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
|
|||||||
|
|
||||||
ret = watchdog_dev_register(wdd);
|
ret = watchdog_dev_register(wdd);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ida_simple_remove(&watchdog_ida, id);
|
ida_free(&watchdog_ida, id);
|
||||||
if (!(id == 0 && ret == -EBUSY))
|
if (!(id == 0 && ret == -EBUSY))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Retry in case a legacy watchdog module exists */
|
/* Retry in case a legacy watchdog module exists */
|
||||||
id = ida_simple_get(&watchdog_ida, 1, MAX_DOGS, GFP_KERNEL);
|
id = ida_alloc_range(&watchdog_ida, 1, MAX_DOGS - 1,
|
||||||
|
GFP_KERNEL);
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
return id;
|
return id;
|
||||||
wdd->id = id;
|
wdd->id = id;
|
||||||
|
|
||||||
ret = watchdog_dev_register(wdd);
|
ret = watchdog_dev_register(wdd);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ida_simple_remove(&watchdog_ida, id);
|
ida_free(&watchdog_ida, id);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,7 +310,7 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
|
|||||||
pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
|
pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
|
||||||
wdd->id, ret);
|
wdd->id, ret);
|
||||||
watchdog_dev_unregister(wdd);
|
watchdog_dev_unregister(wdd);
|
||||||
ida_simple_remove(&watchdog_ida, id);
|
ida_free(&watchdog_ida, id);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -382,7 +383,7 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
|
|||||||
unregister_reboot_notifier(&wdd->reboot_nb);
|
unregister_reboot_notifier(&wdd->reboot_nb);
|
||||||
|
|
||||||
watchdog_dev_unregister(wdd);
|
watchdog_dev_unregister(wdd);
|
||||||
ida_simple_remove(&watchdog_ida, wdd->id);
|
ida_free(&watchdog_ida, wdd->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user