Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp3284926rdd; Sun, 14 Jan 2024 03:40:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHg8zjwImz/kFs5ZPg1uYm4p1fiyJ1mHxr7ZXKcYbwwMoyoeQK0vNQYDZpvoH1YWZki0+px X-Received: by 2002:aa7:983c:0:b0:6d9:f3b6:691d with SMTP id q28-20020aa7983c000000b006d9f3b6691dmr4613934pfl.67.1705232406645; Sun, 14 Jan 2024 03:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705232406; cv=none; d=google.com; s=arc-20160816; b=Mgidp2Dstk1i/9HuRYdAhdeSOm+EPX0WtM633GzhGoLsGDPpU+dRTdepUxjYRn7tD6 AAK+OxvWaIsrxoR7ZlGNKDev7t3n8JtH2rCeSxhEtdSFqbAXG4unTBK6XrzpPU+aEZAW 3lMEHwGP30JOh8SJRxnjc7l9JSgjRSBuC9Yw7MLYHclgeHFWvJDnPZUuZsGJuF/Xvzv1 V4KAkuHaWQZBxbZoLFRSJy7el267i7SRJDdD+u62nlcDHOHERVQLU58ytbbjKhvNV86g Rumu66DnWZCFQvH+hXdTl4ml0Fa1D9muQDCqgzl+AZO6u8ywEClvBoMdz1MWvhoKIbD9 qKDw== 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=pN4Jy9EVplvAgZaMm38XN0QrbVUC0QBZSfuqvWe8FUs=; fh=0Ozi8/osBODh25DWKQQEhKViTGRWVTFwTlswQ++kN0I=; b=XcEesizv4meoVY6Nswkb9PWIbdnMhK4TH8JQc5+w6lMfaX+h/Osn3MF751s9jXmtcn e7nbPObN35mDKsKN34qP4xH+9cDzkWV9AKaAtlTLZnPranrs4hqws+dpk5aacnFAw6FT 5FC8DgcB6/zp51491NuEAUacCzZTcJjZ8t3RcBTAbWsRMJkGOO/q9xvcX1yo6vx4tY/j e/fjt2seLblr7ymP2fZtY7dacIVgwBRoavUjZnujEiEPlyLzfrDTU58bAZiHvIRwMDhY AqU4h4c2Kb4gj+Gq2u/eS1MlwgTQcC3KcbUFwCRZmId3p6+QdBvXlA1RuXC+7Id3J6V+ aEMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="WEu/RUZr"; spf=pass (google.com: domain of linux-kernel+bounces-25451-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25451-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. [139.178.88.99]) by mx.google.com with ESMTPS id ka19-20020a056a00939300b006d999f59a98si7040579pfb.24.2024.01.14.03.40.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 03:40:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25451-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="WEu/RUZr"; spf=pass (google.com: domain of linux-kernel+bounces-25451-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25451-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 EF9A02829EF for ; Sun, 14 Jan 2024 11:40:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B2A023BE; Sun, 14 Jan 2024 11:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="WEu/RUZr" Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) (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 93E831FC4 for ; Sun, 14 Jan 2024 11:39:49 +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 Oyq5rSAEopwjUOyq5rhuvf; Sun, 14 Jan 2024 12:39:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1705232382; bh=pN4Jy9EVplvAgZaMm38XN0QrbVUC0QBZSfuqvWe8FUs=; h=From:To:Cc:Subject:Date; b=WEu/RUZrX3uP2CA8YpuzxoTICzP9Wfn/YBStVVjqjxgyXzFN6fB1osZ7PfbWF6yS7 sMftXX0lWCgl/MKHf8dE2FOYkX//kyh1U2rgTjQt85B5pInJ4y7Xb7uFbvGQ0YyLVa JIXPVSPaLLSzseQx1IDxbH+DNfkmql5XbQr+PVU06QpHuZvGM7xvg8GYi0H5gEZbjf ANoVYntIf4PnSmHQGVLoWgH3ZPeFLSu6m69cjV8jcgh4yNApSR7klWvi2YizlJU7ZC 1XXYEBvw/OPam869FWylcrX5l7pbxD9ly73gkNv/24T95SUs5tqCsmFGFqadYdKBJh m2wuiRKbQVjOw== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 14 Jan 2024 12:39:42 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-usb@vger.kernel.org Subject: [PATCH] usb: gadget: function: Remove usage of the deprecated ida_simple_xx() API Date: Sun, 14 Jan 2024 12:39:37 +0100 Message-ID: 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 --- drivers/usb/gadget/function/f_hid.c | 6 +++--- drivers/usb/gadget/function/f_printer.c | 6 +++--- drivers/usb/gadget/function/rndis.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index 3c8a9dd585c0..2db01e03bfbf 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -1029,9 +1029,9 @@ static inline int hidg_get_minor(void) { int ret; - ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL); + ret = ida_alloc(&hidg_ida, GFP_KERNEL); if (ret >= HIDG_MINORS) { - ida_simple_remove(&hidg_ida, ret); + ida_free(&hidg_ida, ret); ret = -ENODEV; } @@ -1176,7 +1176,7 @@ static const struct config_item_type hid_func_type = { static inline void hidg_put_minor(int minor) { - ida_simple_remove(&hidg_ida, minor); + ida_free(&hidg_ida, minor); } static void hidg_free_inst(struct usb_function_instance *f) diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index 076dd4c1be96..ba7d180cc9e6 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c @@ -1312,9 +1312,9 @@ static inline int gprinter_get_minor(void) { int ret; - ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL); + ret = ida_alloc(&printer_ida, GFP_KERNEL); if (ret >= PRINTER_MINORS) { - ida_simple_remove(&printer_ida, ret); + ida_free(&printer_ida, ret); ret = -ENODEV; } @@ -1323,7 +1323,7 @@ static inline int gprinter_get_minor(void) static inline void gprinter_put_minor(int minor) { - ida_simple_remove(&printer_ida, minor); + ida_free(&printer_ida, minor); } static int gprinter_setup(int); diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c index 29bf8664bf58..12c5d9cf450c 100644 --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -869,12 +869,12 @@ EXPORT_SYMBOL_GPL(rndis_msg_parser); static inline int rndis_get_nr(void) { - return ida_simple_get(&rndis_ida, 0, 1000, GFP_KERNEL); + return ida_alloc_max(&rndis_ida, 999, GFP_KERNEL); } static inline void rndis_put_nr(int nr) { - ida_simple_remove(&rndis_ida, nr); + ida_free(&rndis_ida, nr); } struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v) -- 2.43.0