linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: Remove usage of the deprecated ida_simple_xx() API
@ 2023-12-10 17:36 Christophe JAILLET
  2023-12-13 13:36 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2023-12-10 17:36 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-usb

ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

This is less verbose.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/usb/typec/class.c | 8 ++++----
 drivers/usb/typec/pd.c    | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 16a670828dde..5fe01bf795b9 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -476,7 +476,7 @@ static int altmode_id_get(struct device *dev)
 	else
 		ids = &to_typec_port(dev)->mode_ids;
 
-	return ida_simple_get(ids, 0, 0, GFP_KERNEL);
+	return ida_alloc(ids, GFP_KERNEL);
 }
 
 static void altmode_id_remove(struct device *dev, int id)
@@ -490,7 +490,7 @@ static void altmode_id_remove(struct device *dev, int id)
 	else
 		ids = &to_typec_port(dev)->mode_ids;
 
-	ida_simple_remove(ids, id);
+	ida_free(ids, id);
 }
 
 static void typec_altmode_release(struct device *dev)
@@ -1798,7 +1798,7 @@ static void typec_release(struct device *dev)
 {
 	struct typec_port *port = to_typec_port(dev);
 
-	ida_simple_remove(&typec_index_ida, port->id);
+	ida_free(&typec_index_ida, port->id);
 	ida_destroy(&port->mode_ids);
 	typec_switch_put(port->sw);
 	typec_mux_put(port->mux);
@@ -2297,7 +2297,7 @@ struct typec_port *typec_register_port(struct device *parent,
 	if (!port)
 		return ERR_PTR(-ENOMEM);
 
-	id = ida_simple_get(&typec_index_ida, 0, 0, GFP_KERNEL);
+	id = ida_alloc(&typec_index_ida, GFP_KERNEL);
 	if (id < 0) {
 		kfree(port);
 		return ERR_PTR(id);
diff --git a/drivers/usb/typec/pd.c b/drivers/usb/typec/pd.c
index 85d015cdbe1f..7f3d61f220f2 100644
--- a/drivers/usb/typec/pd.c
+++ b/drivers/usb/typec/pd.c
@@ -571,7 +571,7 @@ static void pd_release(struct device *dev)
 {
 	struct usb_power_delivery *pd = to_usb_power_delivery(dev);
 
-	ida_simple_remove(&pd_ida, pd->id);
+	ida_free(&pd_ida, pd->id);
 	kfree(pd);
 }
 
@@ -616,7 +616,7 @@ usb_power_delivery_register(struct device *parent, struct usb_power_delivery_des
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
-	ret = ida_simple_get(&pd_ida, 0, 0, GFP_KERNEL);
+	ret = ida_alloc(&pd_ida, GFP_KERNEL);
 	if (ret < 0) {
 		kfree(pd);
 		return ERR_PTR(ret);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: typec: Remove usage of the deprecated ida_simple_xx() API
  2023-12-10 17:36 [PATCH] usb: typec: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
@ 2023-12-13 13:36 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2023-12-13 13:36 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors, linux-usb

On Sun, Dec 10, 2023 at 06:36:15PM +0100, Christophe JAILLET wrote:
> ida_alloc() and ida_free() should be preferred to the deprecated
> ida_simple_get() and ida_simple_remove().
> 
> This is less verbose.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/class.c | 8 ++++----
>  drivers/usb/typec/pd.c    | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 16a670828dde..5fe01bf795b9 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -476,7 +476,7 @@ static int altmode_id_get(struct device *dev)
>  	else
>  		ids = &to_typec_port(dev)->mode_ids;
>  
> -	return ida_simple_get(ids, 0, 0, GFP_KERNEL);
> +	return ida_alloc(ids, GFP_KERNEL);
>  }
>  
>  static void altmode_id_remove(struct device *dev, int id)
> @@ -490,7 +490,7 @@ static void altmode_id_remove(struct device *dev, int id)
>  	else
>  		ids = &to_typec_port(dev)->mode_ids;
>  
> -	ida_simple_remove(ids, id);
> +	ida_free(ids, id);
>  }
>  
>  static void typec_altmode_release(struct device *dev)
> @@ -1798,7 +1798,7 @@ static void typec_release(struct device *dev)
>  {
>  	struct typec_port *port = to_typec_port(dev);
>  
> -	ida_simple_remove(&typec_index_ida, port->id);
> +	ida_free(&typec_index_ida, port->id);
>  	ida_destroy(&port->mode_ids);
>  	typec_switch_put(port->sw);
>  	typec_mux_put(port->mux);
> @@ -2297,7 +2297,7 @@ struct typec_port *typec_register_port(struct device *parent,
>  	if (!port)
>  		return ERR_PTR(-ENOMEM);
>  
> -	id = ida_simple_get(&typec_index_ida, 0, 0, GFP_KERNEL);
> +	id = ida_alloc(&typec_index_ida, GFP_KERNEL);
>  	if (id < 0) {
>  		kfree(port);
>  		return ERR_PTR(id);
> diff --git a/drivers/usb/typec/pd.c b/drivers/usb/typec/pd.c
> index 85d015cdbe1f..7f3d61f220f2 100644
> --- a/drivers/usb/typec/pd.c
> +++ b/drivers/usb/typec/pd.c
> @@ -571,7 +571,7 @@ static void pd_release(struct device *dev)
>  {
>  	struct usb_power_delivery *pd = to_usb_power_delivery(dev);
>  
> -	ida_simple_remove(&pd_ida, pd->id);
> +	ida_free(&pd_ida, pd->id);
>  	kfree(pd);
>  }
>  
> @@ -616,7 +616,7 @@ usb_power_delivery_register(struct device *parent, struct usb_power_delivery_des
>  	if (!pd)
>  		return ERR_PTR(-ENOMEM);
>  
> -	ret = ida_simple_get(&pd_ida, 0, 0, GFP_KERNEL);
> +	ret = ida_alloc(&pd_ida, GFP_KERNEL);
>  	if (ret < 0) {
>  		kfree(pd);
>  		return ERR_PTR(ret);
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-13 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-10 17:36 [PATCH] usb: typec: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
2023-12-13 13:36 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).