Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1925095rdd; Thu, 11 Jan 2024 13:38:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIbKp3u1c7aU0pSpjtmhPuGZ5tSgC2rBCHGW0MeHA3ncwOtQkXcI3tV/DsiBs6n91A3JvR X-Received: by 2002:a17:902:bb16:b0:1d4:e208:9b0 with SMTP id im22-20020a170902bb1600b001d4e20809b0mr350455plb.44.1705009128855; Thu, 11 Jan 2024 13:38:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705009128; cv=none; d=google.com; s=arc-20160816; b=Hl2DJJupbvLtZ4FsYjG9z+Sz8vUbMPr8n4ozKz5oajpTM125NPRT8mdlFVGH8qKXbi rIRsTRkZtlt4WWh6+BX1Jytg81GobIcQmmwuwSQBi5AE1gV1RB+6o5Ke2knSUPgAAyMP wT3x+Xwye+Du7WKDemxcCiOVHUNkrpnMLUmFquec+JGJN5hzFEjV9zbYoNWx2192spiy xwdorojyaTf96faaDOGEzxlE1ytZ+vhxvPv62C+X7RrykK2JO1xqr7KSrqvsxH97m0AK L9m930gsraXTQQ7Y4HEm6aAW3L7I/nlaYOvc7LPVJP7F29mAvWJBF+voqq+PwayVCgwJ lsvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=qNcz+UO2mUsUFAtzyQkwuTcfkJ/hn5W8acDGOdU1jWM=; fh=GT4hJDhN7RLs+aNi5eurg00G5nTnWxz97sSozJl8d4c=; b=Jud5dyfaGBSy2OYNupUJFeu0ZjDr/GMErc6Tg0LYjlhzZSQVh7RgGz0PetLqsITKdY CCgz8veQ7Yal6Sk71Gqa+V9cAip0dWsk7CYsMexxDJ1kVhU9ARA0CkTURawYts6dNxs/ Ck482EgOYVtsBfF4OVod37ySgM5hwnbHoPfZ6XpX2noadtfx1cm18z/uUaHlabHVJiwc tgIOmT5alP3loUIj+UqhWuh51GUkcAq6XA1yzQjaJLuJNMbw318Kllkga2QBh2rjlhmW S0N2f2iyZLMqR+Fp7Qw6XyX7Ox++2HUTD9lMJ9ATBSAaV+UL79+iesoYQI/Z1g+ozDsz TAnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=tRJryxdv; spf=pass (google.com: domain of linux-kernel+bounces-24095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w1-20020a170902a70100b001d4abc233b6si1838202plq.44.2024.01.11.13.38.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 13:38:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=tRJryxdv; spf=pass (google.com: domain of linux-kernel+bounces-24095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C404BB242F9 for ; Thu, 11 Jan 2024 21:38:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 623A158209; Thu, 11 Jan 2024 21:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="tRJryxdv" Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A871B58139 for ; Thu, 11 Jan 2024 21:38:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id O2kvrjK5uEoWxO2kvr1liJ; Thu, 11 Jan 2024 22:38:31 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1705009111; bh=qNcz+UO2mUsUFAtzyQkwuTcfkJ/hn5W8acDGOdU1jWM=; h=From:To:Cc:Subject:Date; b=tRJryxdvfdFID44/dVQIU+QTaPrDzj/4z5TzBszlXQAK4ngnwjPJWkRzBUDGVDSVj EHNLswr4KvA3NmAZyA98L3J4M9spEtqpUbgspTj6bzUGKiz3+q21fLTmYFZqJT0v87 oMj2c7TXrMl2p23szPc1o9S512OXrVZuKDjhIMkaR/+vTGlZqRMoRg1FKC4eurTKpT yoh/MAAJjEw7IyWMQxGBtB7CsHbWEXb9mQO5EtSffokkiyk7CUS2RigGqKfF8OKafW eexYE2FaTX39QBYNBnLFq7/+99PvwCjU0pmi6AkQB7ScoUNeX1coKrpZXmDjNuVNhN 0Ds9cbbPDUErA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 11 Jan 2024 22:38:31 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: Wim Van Sebroeck , Guenter Roeck Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-watchdog@vger.kernel.org Subject: [PATCH] watchdog: core: Remove usage of the deprecated ida_simple_xx() API Date: Thu, 11 Jan 2024 22:38:25 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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); } /** -- 2.34.1