diff mbox series

usb: gadget: function: Remove usage of the deprecated ida_simple_xx() API

Message ID fb14757b434ebbad82c8771f19b73dc7ef81a91b.1705232365.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit 920e7522e3bab5ebc2fb0cc1a034f4470c87fa97
Headers show
Series usb: gadget: function: Remove usage of the deprecated ida_simple_xx() API | expand

Commit Message

Christophe JAILLET Jan. 14, 2024, 11:39 a.m. UTC
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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/usb/gadget/function/f_hid.c     | 6 +++---
 drivers/usb/gadget/function/f_printer.c | 6 +++---
 drivers/usb/gadget/function/rndis.c     | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Christophe JAILLET April 14, 2024, 12:09 p.m. UTC | #1
Le 14/01/2024 à 12:39, Christophe JAILLET a écrit :
> 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: Christophe JAILLET <christophe.jaillet-39ZsbGIQGT5GWvitb5QawA@public.gmane.org>
> ---
>   drivers/usb/gadget/function/f_hid.c     | 6 +++---
>   drivers/usb/gadget/function/f_printer.c | 6 +++---
>   drivers/usb/gadget/function/rndis.c     | 4 ++--
>   3 files changed, 8 insertions(+), 8 deletions(-)
> 

Hi,

polite reminder.

CJ


> diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
> index 3c8a9dd585c0..2db01e03bfbf 100644
> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c
> @@ -1029,9 +1029,9 @@ static inline int hidg_get_minor(void)
>   {
>   	int ret;
>   
> -	ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL);
> +	ret = ida_alloc(&hidg_ida, GFP_KERNEL);
>   	if (ret >= HIDG_MINORS) {
> -		ida_simple_remove(&hidg_ida, ret);
> +		ida_free(&hidg_ida, ret);
>   		ret = -ENODEV;
>   	}
>   
> @@ -1176,7 +1176,7 @@ static const struct config_item_type hid_func_type = {
>   
>   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)
> diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
> index 076dd4c1be96..ba7d180cc9e6 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -1312,9 +1312,9 @@ static inline int gprinter_get_minor(void)
>   {
>   	int ret;
>   
> -	ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL);
> +	ret = ida_alloc(&printer_ida, GFP_KERNEL);
>   	if (ret >= PRINTER_MINORS) {
> -		ida_simple_remove(&printer_ida, ret);
> +		ida_free(&printer_ida, ret);
>   		ret = -ENODEV;
>   	}
>   
> @@ -1323,7 +1323,7 @@ static inline int gprinter_get_minor(void)
>   
>   static inline void gprinter_put_minor(int minor)
>   {
> -	ida_simple_remove(&printer_ida, minor);
> +	ida_free(&printer_ida, minor);
>   }
>   
>   static int gprinter_setup(int);
> diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
> index 29bf8664bf58..12c5d9cf450c 100644
> --- a/drivers/usb/gadget/function/rndis.c
> +++ b/drivers/usb/gadget/function/rndis.c
> @@ -869,12 +869,12 @@ EXPORT_SYMBOL_GPL(rndis_msg_parser);
>   
>   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)
>   {
> -	ida_simple_remove(&rndis_ida, nr);
> +	ida_free(&rndis_ida, nr);
>   }
>   
>   struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v)
Greg Kroah-Hartman April 14, 2024, 12:52 p.m. UTC | #2
On Sun, Apr 14, 2024 at 02:09:08PM +0200, Christophe JAILLET wrote:
> Le 14/01/2024 à 12:39, Christophe JAILLET a écrit :
> > 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: Christophe JAILLET <christophe.jaillet-39ZsbGIQGT5GWvitb5QawA@public.gmane.org>
> > ---
> >   drivers/usb/gadget/function/f_hid.c     | 6 +++---
> >   drivers/usb/gadget/function/f_printer.c | 6 +++---
> >   drivers/usb/gadget/function/rndis.c     | 4 ++--
> >   3 files changed, 8 insertions(+), 8 deletions(-)
> > 
> 
> Hi,
> 
> polite reminder.

Odd, this isn't in my review queue anywhere.  Can you rebase and resend?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 3c8a9dd585c0..2db01e03bfbf 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -1029,9 +1029,9 @@  static inline int hidg_get_minor(void)
 {
 	int ret;
 
-	ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL);
+	ret = ida_alloc(&hidg_ida, GFP_KERNEL);
 	if (ret >= HIDG_MINORS) {
-		ida_simple_remove(&hidg_ida, ret);
+		ida_free(&hidg_ida, ret);
 		ret = -ENODEV;
 	}
 
@@ -1176,7 +1176,7 @@  static const struct config_item_type hid_func_type = {
 
 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)
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 076dd4c1be96..ba7d180cc9e6 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1312,9 +1312,9 @@  static inline int gprinter_get_minor(void)
 {
 	int ret;
 
-	ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL);
+	ret = ida_alloc(&printer_ida, GFP_KERNEL);
 	if (ret >= PRINTER_MINORS) {
-		ida_simple_remove(&printer_ida, ret);
+		ida_free(&printer_ida, ret);
 		ret = -ENODEV;
 	}
 
@@ -1323,7 +1323,7 @@  static inline int gprinter_get_minor(void)
 
 static inline void gprinter_put_minor(int minor)
 {
-	ida_simple_remove(&printer_ida, minor);
+	ida_free(&printer_ida, minor);
 }
 
 static int gprinter_setup(int);
diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 29bf8664bf58..12c5d9cf450c 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -869,12 +869,12 @@  EXPORT_SYMBOL_GPL(rndis_msg_parser);
 
 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)
 {
-	ida_simple_remove(&rndis_ida, nr);
+	ida_free(&rndis_ida, nr);
 }
 
 struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v)