Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp980646lqp; Sun, 14 Apr 2024 08:20:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8jfVA0PurvYnK3ikoo7TUZFK3ZCyMm0gOtKfP7tjx9Sh8gIdXiD30GfP+hASdwIA9mEk6JVHnA6/N2dhLuM7dPE4/HIoPmk9bAk/ueg== X-Google-Smtp-Source: AGHT+IElYnHA+AAYzws8YuHNdFVsbTUekhT4ULq0tSmAB9o4l2+u7ALes5+1BkUbb5NZb5+GfiRE X-Received: by 2002:a17:902:dad2:b0:1e5:e664:9c12 with SMTP id q18-20020a170902dad200b001e5e6649c12mr6149498plx.0.1713108000615; Sun, 14 Apr 2024 08:20:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713108000; cv=pass; d=google.com; s=arc-20160816; b=AT1t9UiQz4CdTaJO4LVcyZ2zbk1237EnSfFF3Ur5ApJBT1RvceYobNnL1V+7zHXI51 KKbo93tOBArzblqmy+C3jEUENCPdt+PbPbe8XaVpYcYo6Zcj0aagsvwDgtnCPfRXR2SZ sCxdoTx2e2w2MEQG+ZFJQhe9xi1nCiG2+R+MMr9PL5GHFda2QI1IFiSS3cx4Ms+7NE7L MPvTcPWj9hHuepta1em9DdwZcVzvt1XvI6xeCrJ5w9weZ1mi77vGtTcmvd19NfY+ZQV7 ti+ztjR+rvhXHxQaSHy/DrsUZCXkv5apXATXQ5YxgRLLvLFdXATqWu70V68LL7vxK42t gcdQ== ARC-Message-Signature: i=2; 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=Nm3qAcz/7tgumGMFtfqWwUqrYtPUagtaxDFSUXaCGTc=; fh=0Ozi8/osBODh25DWKQQEhKViTGRWVTFwTlswQ++kN0I=; b=ERMtezVzSF+p+RVBlN1DUOZgfmROhLXS+tef2Qw+uS6adbB1/aO0Mr7yEQe0ssZIbk i7XVmB23vSOPqf41xplBW5cJcRslQNBHEhzyeQ6y4jLd2dJ8jESSR/6SjMtOGFtjwYdB nFeQbUDx90TZeEb3cmoXTGKtURzY820vWHO3QbypT4qxb6fhs59hc5VEAFIc7tOx0f9S m3UwX9vd4jDxC187MnjFnI9nn5k2ycd8NgfIblfekrAJBGQN6OvUZTP0FrYdxnd56Rgf b3TdcDIGc+vl2iu5+vT8VUVj6X8vTfiGmztVYqnUelhF+3ZC7IlmacNNEhq7fDojLCjI IZKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=gQbHnlW1; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-144222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE 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 j3-20020a17090276c300b001e4391978f9si6237058plt.228.2024.04.14.08.20.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 08:20:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144222-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=gQbHnlW1; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-144222-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144222-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE 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 AB9C428161A for ; Sun, 14 Apr 2024 15:19:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97523134CDB; Sun, 14 Apr 2024 15:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="gQbHnlW1" Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) (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 CCE85134738; Sun, 14 Apr 2024 15:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713107988; cv=none; b=DDoNpZVZ/NMu55xbUojGnYx32Nybt1kH0OKX6ZYs18ObRaPRhIl0tUXnZ8vt24Bi5FqBacJ7kZpgcHRUqFKQxyM6pMJOLoFjt2dE15ei4MFyi7EPQcf+T6MVQf8P1yRjSK6F9uZ3iZ3zzjqRvXtPF2J6RPuqKQMbG5GbsbQUtz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713107988; c=relaxed/simple; bh=0mnkyrFHoV4fX2BneLK5oI9FnLKxWrdQ7m57axoBjiQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RqhUscOLvar2HYjqhPqvhcHBFe+LQIfSybGXwKZTs4+S8nRilfZaw9AR9/poAE5nYneVHk+aKuesLcb1PtYaeVCcucds6KtNchYoSRcWtABRrxoFv5mT3IaWaooCyg69teOTczgOvbGSgSfDdNVZH1D/kQKF9BMJU+3Lx0hPiG4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=gQbHnlW1; arc=none smtp.client-ip=80.12.242.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from fedora.home ([86.243.17.157]) by smtp.orange.fr with ESMTPA id w1V9rhxJkdtohw1VArM9Qg; Sun, 14 Apr 2024 17:10:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1713107441; bh=Nm3qAcz/7tgumGMFtfqWwUqrYtPUagtaxDFSUXaCGTc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=gQbHnlW1CGbB2GoEihKOSDKiiyGeu4dca9LmB49x4WuW66VUx8CA7IO7V3WR9vyNd Vuq99p/Y06LwKGaz8UKv46aDLFJSnNI7eM1+OnrjijPPY8AUypnpKOR6KLHrBT3GJw pPnzzPCQnJ/AqSPp8FXKFs0Rp3yb3zEskut3n2AZ/fdPLyMF0AlkjE/V/l6mQmt6n2 XQaZxGZtHmxzZ1sqbGShO5RqP31Jzw379syL178HBuGwrtCMNVlKCfgCmT/UJgF78E XotzvGxyfza4cmOC1+c6eqYZjO+MJwEs6AL4SgvEeaXQiFqOaDT0yzJ5RgsuRf5irt SXOCLb3kiRoTA== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 14 Apr 2024 17:10:41 +0200 X-ME-IP: 86.243.17.157 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 v2] usb: gadget: function: Remove usage of the deprecated ida_simple_xx() API Date: Sun, 14 Apr 2024 17:10:32 +0200 Message-ID: <7cd361e2b377a5373968fa7deee4169229992a1e.1713107386.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.44.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 --- Changes in V2: - rebased against -next-20240412 V1: https://lore.kernel.org/all/fb14757b434ebbad82c8771f19b73dc7ef81a91b.1705232365.git.christophe.jaillet@wanadoo.fr/ --- 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.44.0