Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp321152lqh; Sat, 4 May 2024 02:48:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1625jFDbcJtWCt24lRUC7zBjxS58t3svt5WSM1L5QOg6SSfICrnRgq+9dYRdG1YtD7OCIB+rn8qUDntXQ/PtXYTMzxqiG2UhjyXOL3Q== X-Google-Smtp-Source: AGHT+IEUDsgKQW1EBFWuffXn+zSD2WTjpoDCUzaeY5mg1D0++PW8K09eVFS4Bcf54EVndC0bbRcD X-Received: by 2002:a17:907:7d8f:b0:a59:9876:1168 with SMTP id oz15-20020a1709077d8f00b00a5998761168mr4072655ejc.45.1714816088017; Sat, 04 May 2024 02:48:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714816088; cv=pass; d=google.com; s=arc-20160816; b=j5C+CRa5eqdRryNINObRZykySiKrxcPj0iQQ+Z1ohTn6aq/7esniyeIANkSHypwB05 9Rnz3zqSwJH7PvdESuVB8cYUMB4lv+k3yf5vv9g9ltmG2YKXXoEICF8Qvnrhi1uGuflW r6jvAmRt6dWhmaUuHEGqttuI2W7DJdsmKNh0No5ImXTtOq/M+vUZ0LLROAxE+2qhPweK qacblCNoiXx1bxBhrcm8XP4B9+NbyUMThhr+3QtDBlz9QBm0RISazupZOTjDeHg/DeRd XWFTycRSOVIZ8994SoiuMhAJmM5IJsHAjrnn7k6pDaSBVaUnTK4KJ++TzEi60MKK8KtT aVdg== 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=+sxsfrfYccN7R5PHA2bf4kljLQPC2B5E2Xz86Gbnl54=; fh=0Ozi8/osBODh25DWKQQEhKViTGRWVTFwTlswQ++kN0I=; b=pxGVtSFqQWqWqc63ZzNPkPxogkK2cNQlgDJH/9Y6mjwlXLu6OLLo7OCnG3rLXvesQZ n4RQhScp7KyQP37zbSdLYiXVuIMaH6d7SGVenv3MKJyor4xPIspk+GdhamNOx6U+xc9X ULW9xzfw3bPl4eEEbiic540wZ1pqZ719q1kKEb/1QUOHOwR3Je0ngxC08EzaLeKaGB4W 09lWF3FMdHba43Tbwll7Kn/Nud+XIsKDnmK0shIWMK/RCWbYub1dFmZgXtHqw1ytFChE BTCmbTd/eo2czMEISxOoDPCfX9EqZ/yeLCSeg5T5tQXq25v6ahUmstknmAPxEZiUhU0J Scdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=qXMsbgQr; 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-168577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id me13-20020a170906aecd00b00a599f7b68d7si1015140ejb.355.2024.05.04.02.48.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 02:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=qXMsbgQr; 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-168577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168577-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 am.mirrors.kernel.org (Postfix) with ESMTPS id BBD3E1F2200C for ; Sat, 4 May 2024 09:48:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09E5D17C7C; Sat, 4 May 2024 09:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="qXMsbgQr" Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) (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 328F45234; Sat, 4 May 2024 09:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.26 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714816074; cv=none; b=HDglfoD/Db2lfA6ziiZMouDiPCZVw4BiW0TPX/SZAl3SXkZha4VNtsjBvz8tgVdn9xDEAW6msNuY6eY+uoHNc7NdKl/7NfcrNGmaxx+4McztgkHtwaOI7jP1g+OF/d28UISXxZ31WYIhR+YnxqFp5V9a5101Z2O05tMvFoAZVMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714816074; c=relaxed/simple; bh=0RAXrA9ddTunKzQ27o/B/H26iN61m5JOjlIACCixexs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EenVVEiJW1UilZBkGoHWdOFrIi/UXwO+u0vtWZKNabIIbi597ERFuJL2WsV0JnI3nfsSuHO0Q7YaQ9nh7099qEgddUGEzEiTgf1C2SxoLe9XISOhR4p+G4qG/aUcVxrPiBAoOy6oMkt2ay9GfzYCSOqW8UzYskCUWJwbivIM1BQ= 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=qXMsbgQr; arc=none smtp.client-ip=80.12.242.26 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 localhost.localdomain ([86.243.17.157]) by smtp.orange.fr with ESMTPA id 3BzasNrmCn00P3BzasC921; Sat, 04 May 2024 11:47:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1714816063; bh=+sxsfrfYccN7R5PHA2bf4kljLQPC2B5E2Xz86Gbnl54=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=qXMsbgQrYWfIaNijqNG3tjPKyVfI1+F11JfJnUUJLhwE4yxS3CcyRmvr0X4GwlSGq UHxO9k4aSt7BUvCHEWiQrt6CUGrj5+OEw5K4aBM4nNYZWqgBTIwx74v3IEYoKwBkZi Y/+PplttYcmno9WfdZKVJPVHf1q39sCfLdPV5+HjLoPER5NWjfbDWWSigG3MzaV216 l0SEntzJt6EqDqxPzo3lbyNxev8urLdyTTTZRi0vWrN9jdfTGNeBFKcgxpz+7Bu1Pq zVW1J7kGjdvxb9hzCWSjzDV9pWkLOrreex3DMyh3AlwXV8VxLNTy579d8NCloIN0+s eJVLebX5kCnLw== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 04 May 2024 11:47:43 +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] usb: core: Remove the useless struct usb_devmap which is just a bitmap Date: Sat, 4 May 2024 11:47:05 +0200 Message-ID: <1d818575ff7a1e8317674aecf761ee23c89fdc84.1714815990.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.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 struct usb_devmap is really just a bitmap. No need to have a dedicated structure for that. Simplify code and use DECLARE_BITMAP() directly instead. Signed-off-by: Christophe JAILLET --- Compile tested only. I've re-used the comment related to struct usb_devmap for the devmap field in struct usb_bus, because it sounds better to me. --- drivers/usb/core/hcd.c | 4 ++-- drivers/usb/core/hub.c | 9 ++++----- include/linux/usb.h | 7 +------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index c0e005670d67..e3366f4d82b9 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -866,7 +866,7 @@ static int usb_rh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) */ static void usb_bus_init (struct usb_bus *bus) { - memset (&bus->devmap, 0, sizeof(struct usb_devmap)); + memset(&bus->devmap, 0, sizeof(bus->devmap)); bus->devnum_next = 1; @@ -962,7 +962,7 @@ static int register_root_hub(struct usb_hcd *hcd) usb_dev->devnum = devnum; usb_dev->bus->devnum_next = devnum + 1; - set_bit (devnum, usb_dev->bus->devmap.devicemap); + set_bit(devnum, usb_dev->bus->devmap); usb_set_device_state(usb_dev, USB_STATE_ADDRESS); mutex_lock(&usb_bus_idr_lock); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 8939f1410644..4b93c0bd1d4b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2207,13 +2207,12 @@ static void choose_devnum(struct usb_device *udev) mutex_lock(&bus->devnum_next_mutex); /* Try to allocate the next devnum beginning at bus->devnum_next. */ - devnum = find_next_zero_bit(bus->devmap.devicemap, 128, - bus->devnum_next); + devnum = find_next_zero_bit(bus->devmap, 128, bus->devnum_next); if (devnum >= 128) - devnum = find_next_zero_bit(bus->devmap.devicemap, 128, 1); + devnum = find_next_zero_bit(bus->devmap, 128, 1); bus->devnum_next = (devnum >= 127 ? 1 : devnum + 1); if (devnum < 128) { - set_bit(devnum, bus->devmap.devicemap); + set_bit(devnum, bus->devmap); udev->devnum = devnum; } mutex_unlock(&bus->devnum_next_mutex); @@ -2222,7 +2221,7 @@ static void choose_devnum(struct usb_device *udev) static void release_devnum(struct usb_device *udev) { if (udev->devnum > 0) { - clear_bit(udev->devnum, udev->bus->devmap.devicemap); + clear_bit(udev->devnum, udev->bus->devmap); udev->devnum = -1; } } diff --git a/include/linux/usb.h b/include/linux/usb.h index 9e52179872a5..1913a13833f2 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -440,11 +440,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, /* ----------------------------------------------------------------------- */ -/* USB device number allocation bitmap */ -struct usb_devmap { - unsigned long devicemap[128 / (8*sizeof(unsigned long))]; -}; - /* * Allocated per bus (tree of devices) we have: */ @@ -472,7 +467,7 @@ struct usb_bus { * round-robin allocation */ struct mutex devnum_next_mutex; /* devnum_next mutex */ - struct usb_devmap devmap; /* device address allocation map */ + DECLARE_BITMAP(devmap, 128); /* USB device number allocation bitmap */ struct usb_device *root_hub; /* Root hub */ struct usb_bus *hs_companion; /* Companion EHCI bus, if any */ -- 2.45.0