Linux-Watchdog Archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: core: Remove usage of the deprecated ida_simple_xx() API
Date: Thu, 11 Jan 2024 14:59:40 -0800	[thread overview]
Message-ID: <ba33d050-223a-459d-adee-534bcd8873c3@roeck-us.net> (raw)
In-Reply-To: <bc5b82db59ccac69f2612ba104e2f5100401a862.1705009009.git.christophe.jaillet@wanadoo.fr>

On 1/11/24 13:38, Christophe JAILLET wrote:
> 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_range()/ida_alloc_max() is inclusive. So a -1 has been added when
> needed.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>


> ---
>   drivers/watchdog/watchdog_core.c | 17 +++++++++--------
>   1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
> index 5b55ccae06d4..aff2c3912ead 100644
> --- a/drivers/watchdog/watchdog_core.c
> +++ b/drivers/watchdog/watchdog_core.c
> @@ -260,12 +260,12 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
>   	if (wdd->parent) {
>   		ret = of_alias_get_id(wdd->parent->of_node, "watchdog");
>   		if (ret >= 0)
> -			id = ida_simple_get(&watchdog_ida, ret,
> -					    ret + 1, GFP_KERNEL);
> +			id = ida_alloc_range(&watchdog_ida, ret, ret,
> +					     GFP_KERNEL);
>   	}
>   
>   	if (id < 0)
> -		id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL);
> +		id = ida_alloc_max(&watchdog_ida, MAX_DOGS - 1, GFP_KERNEL);
>   
>   	if (id < 0)
>   		return id;
> @@ -273,19 +273,20 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
>   
>   	ret = watchdog_dev_register(wdd);
>   	if (ret) {
> -		ida_simple_remove(&watchdog_ida, id);
> +		ida_free(&watchdog_ida, id);
>   		if (!(id == 0 && ret == -EBUSY))
>   			return ret;
>   
>   		/* Retry in case a legacy watchdog module exists */
> -		id = ida_simple_get(&watchdog_ida, 1, MAX_DOGS, GFP_KERNEL);
> +		id = ida_alloc_range(&watchdog_ida, 1, MAX_DOGS - 1,
> +				     GFP_KERNEL);
>   		if (id < 0)
>   			return id;
>   		wdd->id = id;
>   
>   		ret = watchdog_dev_register(wdd);
>   		if (ret) {
> -			ida_simple_remove(&watchdog_ida, id);
> +			ida_free(&watchdog_ida, id);
>   			return ret;
>   		}
>   	}
> @@ -309,7 +310,7 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
>   				pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
>   					wdd->id, ret);
>   				watchdog_dev_unregister(wdd);
> -				ida_simple_remove(&watchdog_ida, id);
> +				ida_free(&watchdog_ida, id);
>   				return ret;
>   			}
>   		}
> @@ -382,7 +383,7 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
>   		unregister_reboot_notifier(&wdd->reboot_nb);
>   
>   	watchdog_dev_unregister(wdd);
> -	ida_simple_remove(&watchdog_ida, wdd->id);
> +	ida_free(&watchdog_ida, wdd->id);
>   }
>   
>   /**


      reply	other threads:[~2024-01-11 22:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 21:38 [PATCH] watchdog: core: Remove usage of the deprecated ida_simple_xx() API Christophe JAILLET
2024-01-11 22:59 ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba33d050-223a-459d-adee-534bcd8873c3@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).