Skip to content

Commit b568b15

Browse files
tititiou36Wim Van Sebroeck
authored andcommitted
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>
1 parent 41bccc9 commit b568b15

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/watchdog/watchdog_core.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,32 +260,33 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
260260
if (wdd->parent) {
261261
ret = of_alias_get_id(wdd->parent->of_node, "watchdog");
262262
if (ret >= 0)
263-
id = ida_simple_get(&watchdog_ida, ret,
264-
ret + 1, GFP_KERNEL);
263+
id = ida_alloc_range(&watchdog_ida, ret, ret,
264+
GFP_KERNEL);
265265
}
266266

267267
if (id < 0)
268-
id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL);
268+
id = ida_alloc_max(&watchdog_ida, MAX_DOGS - 1, GFP_KERNEL);
269269

270270
if (id < 0)
271271
return id;
272272
wdd->id = id;
273273

274274
ret = watchdog_dev_register(wdd);
275275
if (ret) {
276-
ida_simple_remove(&watchdog_ida, id);
276+
ida_free(&watchdog_ida, id);
277277
if (!(id == 0 && ret == -EBUSY))
278278
return ret;
279279

280280
/* Retry in case a legacy watchdog module exists */
281-
id = ida_simple_get(&watchdog_ida, 1, MAX_DOGS, GFP_KERNEL);
281+
id = ida_alloc_range(&watchdog_ida, 1, MAX_DOGS - 1,
282+
GFP_KERNEL);
282283
if (id < 0)
283284
return id;
284285
wdd->id = id;
285286

286287
ret = watchdog_dev_register(wdd);
287288
if (ret) {
288-
ida_simple_remove(&watchdog_ida, id);
289+
ida_free(&watchdog_ida, id);
289290
return ret;
290291
}
291292
}
@@ -309,7 +310,7 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
309310
pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
310311
wdd->id, ret);
311312
watchdog_dev_unregister(wdd);
312-
ida_simple_remove(&watchdog_ida, id);
313+
ida_free(&watchdog_ida, id);
313314
return ret;
314315
}
315316
}
@@ -382,7 +383,7 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
382383
unregister_reboot_notifier(&wdd->reboot_nb);
383384

384385
watchdog_dev_unregister(wdd);
385-
ida_simple_remove(&watchdog_ida, wdd->id);
386+
ida_free(&watchdog_ida, wdd->id);
386387
}
387388

388389
/**

0 commit comments

Comments
 (0)