Commit 920e7522 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman

usb: gadget: function: 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_max() is inclusive. So a -1 has been added when needed.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/7cd361e2b377a5373968fa7deee4169229992a1e.1713107386.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d122e6d
...@@ -1029,9 +1029,9 @@ static inline int hidg_get_minor(void) ...@@ -1029,9 +1029,9 @@ static inline int hidg_get_minor(void)
{ {
int ret; int ret;
ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL); ret = ida_alloc(&hidg_ida, GFP_KERNEL);
if (ret >= HIDG_MINORS) { if (ret >= HIDG_MINORS) {
ida_simple_remove(&hidg_ida, ret); ida_free(&hidg_ida, ret);
ret = -ENODEV; ret = -ENODEV;
} }
...@@ -1176,7 +1176,7 @@ static const struct config_item_type hid_func_type = { ...@@ -1176,7 +1176,7 @@ static const struct config_item_type hid_func_type = {
static inline void hidg_put_minor(int minor) static inline void hidg_put_minor(int minor)
{ {
ida_simple_remove(&hidg_ida, minor); ida_free(&hidg_ida, minor);
} }
static void hidg_free_inst(struct usb_function_instance *f) static void hidg_free_inst(struct usb_function_instance *f)
......
...@@ -1312,9 +1312,9 @@ static inline int gprinter_get_minor(void) ...@@ -1312,9 +1312,9 @@ static inline int gprinter_get_minor(void)
{ {
int ret; int ret;
ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL); ret = ida_alloc(&printer_ida, GFP_KERNEL);
if (ret >= PRINTER_MINORS) { if (ret >= PRINTER_MINORS) {
ida_simple_remove(&printer_ida, ret); ida_free(&printer_ida, ret);
ret = -ENODEV; ret = -ENODEV;
} }
...@@ -1323,7 +1323,7 @@ static inline int gprinter_get_minor(void) ...@@ -1323,7 +1323,7 @@ static inline int gprinter_get_minor(void)
static inline void gprinter_put_minor(int minor) static inline void gprinter_put_minor(int minor)
{ {
ida_simple_remove(&printer_ida, minor); ida_free(&printer_ida, minor);
} }
static int gprinter_setup(int); static int gprinter_setup(int);
......
...@@ -869,12 +869,12 @@ EXPORT_SYMBOL_GPL(rndis_msg_parser); ...@@ -869,12 +869,12 @@ EXPORT_SYMBOL_GPL(rndis_msg_parser);
static inline int rndis_get_nr(void) static inline int rndis_get_nr(void)
{ {
return ida_simple_get(&rndis_ida, 0, 1000, GFP_KERNEL); return ida_alloc_max(&rndis_ida, 999, GFP_KERNEL);
} }
static inline void rndis_put_nr(int nr) static inline void rndis_put_nr(int nr)
{ {
ida_simple_remove(&rndis_ida, nr); ida_free(&rndis_ida, nr);
} }
struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v) struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment