Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp63476rdb; Mon, 15 Jan 2024 12:13:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5Sq152p+Ug0RGvHUeLevcX5rKN7Fs4Z9XcY6BkWl0qShRw+/y1uZ1MMhJRDA5ca5hrI3C X-Received: by 2002:a17:902:d512:b0:1d4:3b72:b294 with SMTP id b18-20020a170902d51200b001d43b72b294mr8169321plg.88.1705349597001; Mon, 15 Jan 2024 12:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705349596; cv=none; d=google.com; s=arc-20160816; b=nJ8SxQfJ6fAndM8T3YQaoagnP/Dn6tgA4mp3ErqQYmyRzo4Kt2p/m8cF7xIKjntpbP HFV8Yqx7hErWc38V7Sb1Ye01O0NY+lAb3EaU68yP0V16S7HyHrgflGx1/PIjFrg8ivbQ fKLPCiCClprE4AFhMzrpo2Ef8tqs3WZXbQy4JiHs2pBmwLGZar/j+2j3KKiUNOfoxW4A SQ2pQ0ATRJXjLxHk8UafJ93sNbYx4yE1uyLB8ibkV9NbMnFqXALE6lH0fFcY0bGMf4yH rtB6h/UXR+tTMi4H3mnZtvemGU+iFY8iVSeSidh+vhqDDKkUwHhX8SFIt14Im0I5chcb oWDw== 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=Zag1tyR6DZ8o6qntEb3YzGjDPt9iK1tzSJavyfJS+3c=; fh=Wqmzufl+6sb1KRM8MXGS7IWcRyzhbhjQr6r9LTWM5rc=; b=YFLz0acoNA7IrP8D4BS8Sql2+hX/X/btSvM0jgTCD0CKXufZZDhRuuPddwucROjs9j vJ+I0adsOdm/LkIeo9MMXHjtSlPaNJ32M93fpfmMlOANE4VnFf8cx3WuyfOGXjvP/93e StiHFCaEW+xz/e0J7qwPS14s9w5Daus/lftxcsOIJAcZKzOrcEQhggNMRT08V89EdvN3 cVBa7AElqatjJ46SxctR0RH/HYLl1GK4u8hTh9tphAO8wGN0cwhHv6wU5a9mZTGJwJol j9xNYHHyURyZs/pKdetYuW5Xl0+4FLvUQu7ehfMLwuapAYL0boYNEgzM9nPCjskrnFbK JZUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="Fvt/V/E3"; spf=pass (google.com: domain of linux-kernel+bounces-26468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26468-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id kj6-20020a17090306c600b001d3554bb52bsi9614799plb.519.2024.01.15.12.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 12:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="Fvt/V/E3"; spf=pass (google.com: domain of linux-kernel+bounces-26468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26468-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AA44C283745 for ; Mon, 15 Jan 2024 20:13:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 587991A28F; Mon, 15 Jan 2024 20:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="Fvt/V/E3" Received: from smtp.smtpout.orange.fr (smtp-20.smtpout.orange.fr [80.12.242.20]) (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 E0A7619BCE for ; Mon, 15 Jan 2024 20:12:31 +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 fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id PTJsreNfxZ1tSPTJsr3DED; Mon, 15 Jan 2024 21:12:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1705349550; bh=Zag1tyR6DZ8o6qntEb3YzGjDPt9iK1tzSJavyfJS+3c=; h=From:To:Cc:Subject:Date; b=Fvt/V/E3sZtxVJf+mQhWHRGR9UNENrZh+TtJZiiT94FKJKCLoKfIhOWzFRNOlOL6S 2ANyEWnTwBUJwHzg7yqtS8/Xj28GYXpAbsuMBZ4KvDMCExUgkmLwovLs5DAyNJQEV/ a1/OQUCeh+xlIvp7U8OCVkTZn45UOszSqr4K7PpP48W1IC618W+VxNlTKP/S5qw3rk kI9zZtbWY1rK3KDRybgAhVZEZp4l59LGeF3AtEKkLVHe3oT8CcURsphSxQ5v/fscFG rWyhFzmmaGJrXZ6lGL4yimXGK0QUDdGGRI5LZH8xIuWkj1kH6Hs0KMCO4rr5velLWT VD28KI6E4UjJA== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 15 Jan 2024 21:12:30 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-bluetooth@vger.kernel.org Subject: [PATCH] Bluetooth: Remove usage of the deprecated ida_simple_xx() API Date: Mon, 15 Jan 2024 21:12:19 +0100 Message-ID: <3b3523b475d0f5cadf81b3131bb1a38b7476b020.1705349526.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.0 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_max() is inclusive. So a -1 has been added when needed. Signed-off-by: Christophe JAILLET --- I've not been able to find the rational for the HCI_MAX_ID value (i.e. 10000) is the BT spec I've found. Instead of having these HCI_MAX_ID-1 in the code, we could also change the value of HCI_MAX_ID to 9999. I don't know what makes the more sense. --- net/bluetooth/hci_core.c | 9 +++++---- net/bluetooth/hci_sock.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index e5cb618fa6d3..41d2d1956527 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2639,10 +2639,11 @@ int hci_register_dev(struct hci_dev *hdev) */ switch (hdev->dev_type) { case HCI_PRIMARY: - id = ida_simple_get(&hci_index_ida, 0, HCI_MAX_ID, GFP_KERNEL); + id = ida_alloc_max(&hci_index_ida, HCI_MAX_ID - 1, GFP_KERNEL); break; case HCI_AMP: - id = ida_simple_get(&hci_index_ida, 1, HCI_MAX_ID, GFP_KERNEL); + id = ida_alloc_range(&hci_index_ida, 1, HCI_MAX_ID - 1, + GFP_KERNEL); break; default: return -EINVAL; @@ -2741,7 +2742,7 @@ int hci_register_dev(struct hci_dev *hdev) destroy_workqueue(hdev->workqueue); destroy_workqueue(hdev->req_workqueue); err: - ida_simple_remove(&hci_index_ida, hdev->id); + ida_free(&hci_index_ida, hdev->id); return error; } @@ -2824,7 +2825,7 @@ void hci_release_dev(struct hci_dev *hdev) hci_dev_unlock(hdev); ida_destroy(&hdev->unset_handle_ida); - ida_simple_remove(&hci_index_ida, hdev->id); + ida_free(&hci_index_ida, hdev->id); kfree_skb(hdev->sent_cmd); kfree_skb(hdev->recv_event); kfree(hdev); diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 3e7cd330d731..4ee1b976678b 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -101,7 +101,7 @@ static bool hci_sock_gen_cookie(struct sock *sk) int id = hci_pi(sk)->cookie; if (!id) { - id = ida_simple_get(&sock_cookie_ida, 1, 0, GFP_KERNEL); + id = ida_alloc_min(&sock_cookie_ida, 1, GFP_KERNEL); if (id < 0) id = 0xffffffff; @@ -119,7 +119,7 @@ static void hci_sock_free_cookie(struct sock *sk) if (id) { hci_pi(sk)->cookie = 0xffffffff; - ida_simple_remove(&sock_cookie_ida, id); + ida_free(&sock_cookie_ida, id); } } -- 2.43.0