All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gnss: Remove usage of the deprecated ida_simple_xxx API
@ 2022-06-16  4:47 Bo Liu
  2022-06-16 19:18 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Bo Liu @ 2022-06-16  4:47 UTC (permalink / raw)
  To: johan; +Cc: linux-kernel, Bo Liu

Use ida_alloc_xxx()/ida_free() instead of
ida_simple_get()/ida_simple_remove().
The latter is deprecated and more verbose.

Signed-off-by: Bo Liu <liubo03@inspur.com>
---
 drivers/gnss/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
index e6f94501cb28..1e82b7967570 100644
--- a/drivers/gnss/core.c
+++ b/drivers/gnss/core.c
@@ -217,7 +217,7 @@ static void gnss_device_release(struct device *dev)
 
 	kfree(gdev->write_buf);
 	kfifo_free(&gdev->read_fifo);
-	ida_simple_remove(&gnss_minors, gdev->id);
+	ida_free(&gnss_minors, gdev->id);
 	kfree(gdev);
 }
 
@@ -232,7 +232,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
 	if (!gdev)
 		return NULL;
 
-	id = ida_simple_get(&gnss_minors, 0, GNSS_MINORS, GFP_KERNEL);
+	id = ida_alloc_max(&gnss_minors, GNSS_MINORS - 1, GFP_KERNEL);
 	if (id < 0) {
 		kfree(gdev);
 		return NULL;
-- 
2.27.0


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

* Re: [PATCH] gnss: Remove usage of the deprecated ida_simple_xxx API
  2022-06-16  4:47 [PATCH] gnss: Remove usage of the deprecated ida_simple_xxx API Bo Liu
@ 2022-06-16 19:18 ` Christophe JAILLET
  2022-06-21  7:34   ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-06-16 19:18 UTC (permalink / raw)
  To: Bo Liu, johan; +Cc: linux-kernel

Le 16/06/2022 à 06:47, Bo Liu a écrit :
> Use ida_alloc_xxx()/ida_free() instead of
> ida_simple_get()/ida_simple_remove().
> The latter is deprecated and more verbose.
> 
> Signed-off-by: Bo Liu <liubo03@inspur.com>

Hi,

even if a more detailed description about the reason of the added -1 
would be welcomed:

Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

> ---
>   drivers/gnss/core.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
> index e6f94501cb28..1e82b7967570 100644
> --- a/drivers/gnss/core.c
> +++ b/drivers/gnss/core.c
> @@ -217,7 +217,7 @@ static void gnss_device_release(struct device *dev)
>   
>   	kfree(gdev->write_buf);
>   	kfifo_free(&gdev->read_fifo);
> -	ida_simple_remove(&gnss_minors, gdev->id);
> +	ida_free(&gnss_minors, gdev->id);
>   	kfree(gdev);
>   }
>   
> @@ -232,7 +232,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
>   	if (!gdev)
>   		return NULL;
>   
> -	id = ida_simple_get(&gnss_minors, 0, GNSS_MINORS, GFP_KERNEL);
> +	id = ida_alloc_max(&gnss_minors, GNSS_MINORS - 1, GFP_KERNEL);
>   	if (id < 0) {
>   		kfree(gdev);
>   		return NULL;


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

* Re: [PATCH] gnss: Remove usage of the deprecated ida_simple_xxx API
  2022-06-16 19:18 ` Christophe JAILLET
@ 2022-06-21  7:34   ` Johan Hovold
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2022-06-21  7:34 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: Bo Liu, linux-kernel

On Thu, Jun 16, 2022 at 09:18:37PM +0200, Christophe JAILLET wrote:
> Le 16/06/2022 à 06:47, Bo Liu a écrit :
> > Use ida_alloc_xxx()/ida_free() instead of
> > ida_simple_get()/ida_simple_remove().
> > The latter is deprecated and more verbose.
> > 
> > Signed-off-by: Bo Liu <liubo03@inspur.com>

> even if a more detailed description about the reason of the added -1 
> would be welcomed:
> 
> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

I agree, that should have been mentioned. And thanks for reviewing.

> > ---
> >   drivers/gnss/core.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
> > index e6f94501cb28..1e82b7967570 100644
> > --- a/drivers/gnss/core.c
> > +++ b/drivers/gnss/core.c
> > @@ -217,7 +217,7 @@ static void gnss_device_release(struct device *dev)
> >   
> >   	kfree(gdev->write_buf);
> >   	kfifo_free(&gdev->read_fifo);
> > -	ida_simple_remove(&gnss_minors, gdev->id);
> > +	ida_free(&gnss_minors, gdev->id);
> >   	kfree(gdev);
> >   }
> >   
> > @@ -232,7 +232,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
> >   	if (!gdev)
> >   		return NULL;
> >   
> > -	id = ida_simple_get(&gnss_minors, 0, GNSS_MINORS, GFP_KERNEL);
> > +	id = ida_alloc_max(&gnss_minors, GNSS_MINORS - 1, GFP_KERNEL);

I'm also not sure about the claim that the new interface is less
verbose.

The above line is exactly as long as the old one, but somewhat harder to
read due to the inclusive upper bound and the various allocator flavors
(ε, max, min, range).

> >   	if (id < 0) {
> >   		kfree(gdev);
> >   		return NULL;

Now applied with an amended commit message:

	https://git.kernel.org/pub/scm/linux/kernel/git/johan/gnss.git/commit/?h=gnss-next&id=c0c725d7350ec8b8453257676a440bb4b2df2422

Johan

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

end of thread, other threads:[~2022-06-21  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16  4:47 [PATCH] gnss: Remove usage of the deprecated ida_simple_xxx API Bo Liu
2022-06-16 19:18 ` Christophe JAILLET
2022-06-21  7:34   ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.