diff mbox series

ptp: Remove usage of the deprecated ida_simple_xxx API

Message ID 20220926012744.3363-1-liubo03@inspur.com (mailing list archive)
State Accepted
Commit ab7ea1e73532247217d3e450015dd7ece966dc0e
Delegated to: Netdev Maintainers
Headers show
Series ptp: Remove usage of the deprecated ida_simple_xxx API | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 2 of 2 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Bo Liu Sept. 26, 2022, 1:27 a.m. UTC
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/ptp/ptp_clock.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Richard Cochran Sept. 27, 2022, 3:01 p.m. UTC | #1
On Sun, Sep 25, 2022 at 09:27:44PM -0400, Bo Liu wrote:
> Use ida_alloc_xxx()/ida_free() instead of
> ida_simple_get()/ida_simple_remove().
> The latter is deprecated and more verbose.

I can't say that I am excited about this.  It seems like a way to
create a regression.  I don't see any need to change.  After all,
there are many "deprecated" interfaces in use.

> Signed-off-by: Bo Liu <liubo03@inspur.com>
> ---
>  drivers/ptp/ptp_clock.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index 688cde320bb0..51cae72bb6db 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -174,7 +174,7 @@ static void ptp_clock_release(struct device *dev)
>  	mutex_destroy(&ptp->tsevq_mux);
>  	mutex_destroy(&ptp->pincfg_mux);
>  	mutex_destroy(&ptp->n_vclocks_mux);
> -	ida_simple_remove(&ptp_clocks_map, ptp->index);
> +	ida_free(&ptp_clocks_map, ptp->index);
>  	kfree(ptp);
>  }
>  
> @@ -217,7 +217,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
>  	if (ptp == NULL)
>  		goto no_memory;
>  
> -	index = ida_simple_get(&ptp_clocks_map, 0, MINORMASK + 1, GFP_KERNEL);
> +	index = ida_alloc_max(&ptp_clocks_map, MINORMASK, GFP_KERNEL);

Typo?   You changed the value of the second argument.

Thanks,
Richard



>  	if (index < 0) {
>  		err = index;
>  		goto no_slot;
> @@ -332,7 +332,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
>  	mutex_destroy(&ptp->tsevq_mux);
>  	mutex_destroy(&ptp->pincfg_mux);
>  	mutex_destroy(&ptp->n_vclocks_mux);
> -	ida_simple_remove(&ptp_clocks_map, index);
> +	ida_free(&ptp_clocks_map, index);
>  no_slot:
>  	kfree(ptp);
>  no_memory:
> -- 
> 2.27.0
>
Richard Cochran Sept. 27, 2022, 3:05 p.m. UTC | #2
On Tue, Sep 27, 2022 at 08:01:28AM -0700, Richard Cochran wrote:
> On Sun, Sep 25, 2022 at 09:27:44PM -0400, Bo Liu wrote:
> > Use ida_alloc_xxx()/ida_free() instead of
> > ida_simple_get()/ida_simple_remove().
> > The latter is deprecated and more verbose.
> 
> I can't say that I am excited about this.  It seems like a way to
> create a regression.  I don't see any need to change.  After all,
> there are many "deprecated" interfaces in use.

/git/linux$ git grep ida_simple_get | wc -l
119

~/git/linux$ git grep ida_simple_remove | wc -l
169

Please go take care of the other 100+ users of this API first, then
come bother me again.

Thanks,
Richard
Jakub Kicinski Sept. 27, 2022, 6:32 p.m. UTC | #3
On Tue, 27 Sep 2022 08:05:23 -0700 Richard Cochran wrote:
> On Tue, Sep 27, 2022 at 08:01:28AM -0700, Richard Cochran wrote:
> > On Sun, Sep 25, 2022 at 09:27:44PM -0400, Bo Liu wrote:  
> > > Use ida_alloc_xxx()/ida_free() instead of
> > > ida_simple_get()/ida_simple_remove().
> > > The latter is deprecated and more verbose.  
> > 
> > I can't say that I am excited about this.  It seems like a way to
> > create a regression.  I don't see any need to change.  After all,
> > there are many "deprecated" interfaces in use.  
> 
> /git/linux$ git grep ida_simple_get | wc -l
> 119
> 
> ~/git/linux$ git grep ida_simple_remove | wc -l
> 169
> 
> Please go take care of the other 100+ users of this API first, then
> come bother me again.

It's clearly marked as deprecated and the old API is literally
a define to the new one:

/*
 * ida_simple_get() and ida_simple_remove() are deprecated. Use
 * ida_alloc() and ida_free() instead respectively.
 */
#define ida_simple_get(ida, start, end, gfp)	\
			ida_alloc_range(ida, start, (end) - 1, gfp)
#define ida_simple_remove(ida, id)	ida_free(ida, id)


This transition is happening sooner or later. Do you have an objection
here or just don't want to review this? I can double check the ASM is
identical after applying...
patchwork-bot+netdevbpf@kernel.org Sept. 28, 2022, 12:40 a.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Sun, 25 Sep 2022 21:27:44 -0400 you wrote:
> 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/ptp/ptp_clock.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Here is the summary with links:
  - ptp: Remove usage of the deprecated ida_simple_xxx API
    https://git.kernel.org/netdev/net-next/c/ab7ea1e73532

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 688cde320bb0..51cae72bb6db 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -174,7 +174,7 @@  static void ptp_clock_release(struct device *dev)
 	mutex_destroy(&ptp->tsevq_mux);
 	mutex_destroy(&ptp->pincfg_mux);
 	mutex_destroy(&ptp->n_vclocks_mux);
-	ida_simple_remove(&ptp_clocks_map, ptp->index);
+	ida_free(&ptp_clocks_map, ptp->index);
 	kfree(ptp);
 }
 
@@ -217,7 +217,7 @@  struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
 	if (ptp == NULL)
 		goto no_memory;
 
-	index = ida_simple_get(&ptp_clocks_map, 0, MINORMASK + 1, GFP_KERNEL);
+	index = ida_alloc_max(&ptp_clocks_map, MINORMASK, GFP_KERNEL);
 	if (index < 0) {
 		err = index;
 		goto no_slot;
@@ -332,7 +332,7 @@  struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
 	mutex_destroy(&ptp->tsevq_mux);
 	mutex_destroy(&ptp->pincfg_mux);
 	mutex_destroy(&ptp->n_vclocks_mux);
-	ida_simple_remove(&ptp_clocks_map, index);
+	ida_free(&ptp_clocks_map, index);
 no_slot:
 	kfree(ptp);
 no_memory: