From patchwork Sun Jun 8 23:33:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 894901 Received: from mx.treblig.org (mx.treblig.org [46.235.229.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D6D3209F56; Sun, 8 Jun 2025 23:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.229.95 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749425624; cv=none; b=GSvDuc7UNSwB0pMFbIjJgvDXVTe9d8zNjpLzop6ziisyn1MKlR6XBHUb4h6bw1KA5ch1kVNsJkPqmDX0hL5qw6j/nlLpTq9rhj0gJXjeA4fZKW/QblJ/A1eoT6qYhFKAAaotFoCSonPshdHxj/h7VFc0CxJKhza4VQYc4NGrSn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749425624; c=relaxed/simple; bh=/cvVKyHzhQoI48LJcgkMrdv6qtdw4CLFdD26xKbOEl8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZUs2q9nxW9f5p8LrFQxeMgde0bj4VLxZCL74tk9OuHKO+imQrtVbt1K1d3MyW4N/oTkG+F8FN/PDw2fEjulULm9FuRlN2imiKmvZ4WOOiZdUy4ueOj4Qr2opcELldLnxqzAOFR9+Nhjd0CssRFvKoHxeyXeEgSBe70umbqrtkgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org; spf=pass smtp.mailfrom=treblig.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b=qxPC5wev; arc=none smtp.client-ip=46.235.229.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=treblig.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b="qxPC5wev" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=treblig.org ; s=bytemarkmx; h=MIME-Version:Message-ID:Date:Subject:From:Content-Type:From :Subject; bh=P1RZtMesjHHey3Igxou9b7mtw18agArL8q30UcPKfGU=; b=qxPC5wevDeeW6+N8 ihWwDIk+yKwxKP1b39etRXnRrAHqoTwSuvlgyaaLbopvXQbill4R1Pn2I9F9BvhCizxnMv+qRZMzN R4bXkFH2hXO3LmnuznJ/N+or4BNMrOmlI79vK8p7rdzK75AMcPYoaBkUEE8kkn9qEoYZiTEklblOO f5CkN1lTOyrDsw6H5nt0m9tgf+JsVx+brb1FwHjgnhLNN/v7nVkSs8TNwqlpjlymUpOFZZGFTklHT +atfG3sC0cPlzTaMPgUrxifL0mtiytPnQPL3m6ei4adZBlZlQQnUbPVVdfF8YYigd4JxDIXV3G/Kb hqNHt/UuMMMcr3pGrA==; Received: from localhost ([127.0.0.1] helo=dalek.home.treblig.org) by mx.treblig.org with esmtp (Exim 4.96) (envelope-from ) id 1uOPWF-008IvT-23; Sun, 08 Jun 2025 23:33:39 +0000 From: linux@treblig.org To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Dr. David Alan Gilbert" Subject: [PATCH 1/2] usb: gadget: config: Remove unused usb_gadget_config_buf Date: Mon, 9 Jun 2025 00:33:37 +0100 Message-ID: <20250608233338.179894-2-linux@treblig.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250608233338.179894-1-linux@treblig.org> References: <20250608233338.179894-1-linux@treblig.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Dr. David Alan Gilbert" usb_gadget_config_buf() has been unused since 2012's commit fa06920a3ece ("usb: gadget: Remove File-backed Storage Gadget (g_file_storage).") Remove it. Signed-off-by: Dr. David Alan Gilbert --- drivers/usb/gadget/config.c | 53 ------------------------------------- include/linux/usb/gadget.h | 4 --- 2 files changed, 57 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 95f144a54ed9..256364d4b941 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -53,59 +53,6 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen, } EXPORT_SYMBOL_GPL(usb_descriptor_fillbuf); -/** - * usb_gadget_config_buf - builts a complete configuration descriptor - * @config: Header for the descriptor, including characteristics such - * as power requirements and number of interfaces. - * @buf: Buffer for the resulting configuration descriptor. - * @length: Length of buffer. If this is not big enough to hold the - * entire configuration descriptor, an error code will be returned. - * @desc: Null-terminated vector of pointers to the descriptors (interface, - * endpoint, etc) defining all functions in this device configuration. - * - * This copies descriptors into the response buffer, building a descriptor - * for that configuration. It returns the buffer length or a negative - * status code. The config.wTotalLength field is set to match the length - * of the result, but other descriptor fields (including power usage and - * interface count) must be set by the caller. - * - * Gadget drivers could use this when constructing a config descriptor - * in response to USB_REQ_GET_DESCRIPTOR. They will need to patch the - * resulting bDescriptorType value if USB_DT_OTHER_SPEED_CONFIG is needed. - */ -int usb_gadget_config_buf( - const struct usb_config_descriptor *config, - void *buf, - unsigned length, - const struct usb_descriptor_header **desc -) -{ - struct usb_config_descriptor *cp = buf; - int len; - - /* config descriptor first */ - if (length < USB_DT_CONFIG_SIZE || !desc) - return -EINVAL; - *cp = *config; - - /* then interface/endpoint/class/vendor/... */ - len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf, - length - USB_DT_CONFIG_SIZE, desc); - if (len < 0) - return len; - len += USB_DT_CONFIG_SIZE; - if (len > 0xffff) - return -EINVAL; - - /* patch up the config descriptor */ - cp->bLength = USB_DT_CONFIG_SIZE; - cp->bDescriptorType = USB_DT_CONFIG; - cp->wTotalLength = cpu_to_le16(len); - cp->bmAttributes |= USB_CONFIG_ATT_ONE; - return len; -} -EXPORT_SYMBOL_GPL(usb_gadget_config_buf); - /** * usb_copy_descriptors - copy a vector of USB descriptors * @src: null-terminated vector to copy diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index df33333650a0..0f28c5512fcb 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -860,10 +860,6 @@ container_of(str_item, struct gadget_string, item) int usb_descriptor_fillbuf(void *, unsigned, const struct usb_descriptor_header **); -/* build config descriptor from single descriptor vector */ -int usb_gadget_config_buf(const struct usb_config_descriptor *config, - void *buf, unsigned buflen, const struct usb_descriptor_header **desc); - /* copy a NULL-terminated vector of descriptors */ struct usb_descriptor_header **usb_copy_descriptors( struct usb_descriptor_header **); From patchwork Sun Jun 8 23:33:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 895135 Received: from mx.treblig.org (mx.treblig.org [46.235.229.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D73C20E70F; Sun, 8 Jun 2025 23:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.229.95 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749425624; cv=none; b=LYmETMBDzKw++d/P+arY7JIRVQ1s13tAVJWnu5nDQZp0vzuZ2mN+5ljk5FDHrU9PpYA7iYIZLWfxNPzewwmRgJO+mViGy9Vm7skqJs0s/g4t9FDF8GmGELwKfr8t9e2eftUZTfo2XtkNWT0ZjOKVhzXCka+uic7KavUQ5K+xvF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749425624; c=relaxed/simple; bh=fdJpR3rWa/UemXi06y7bkqEwa2B8YYtR9GzbGqGYv+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YFOfwxmiavhdUktCr0jKIoJ1zWR49EhOnf7CyBxQvAz4QJGY+LZMZqO2K3S8PMMHUZ8GQ5bQCnMhQMf5LzBH6fzBEDULMEY4gznMHx2LSSLoaFtNYf/dHcjhKCaEcqKi7G3zZF1IwMmz2g1hMamwAe+iuSB5NfzvFWtbePp0A3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org; spf=pass smtp.mailfrom=treblig.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b=tHXymT0w; arc=none smtp.client-ip=46.235.229.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=treblig.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=treblig.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=treblig.org header.i=@treblig.org header.b="tHXymT0w" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=treblig.org ; s=bytemarkmx; h=MIME-Version:Message-ID:Date:Subject:From:Content-Type:From :Subject; bh=D097UiPOxZuavhBgTPj4Ae2cNRR5wuLKQGWNgI1WFz8=; b=tHXymT0wV7HGciSm iuRg0MfPLTWWC0KjWyvkZzAQZMKnhTI5MGdTNGcstLbbjhsWBc6en8YrnOjf6aw07mICuCO78DjSU 5LC7v/d7yWOX7re3kgVWm7/DQ4uUC01yV6R2aOuVArekSwZE77jld2E6NXWPPHADAD9rjzg+XJssY IAe9UquXetLHEzNTIy7PZ2UGtLaur3n7sD1QELYE9z/OISXAmHF9H9ZxzzsAeMwZZE9S3iHoqvq/d k9/ujny1VIzkfLkzI5/VEMHxdO/0bHCxWaofeZkaZlxVFxlEPi2MF45jdM669FTF4WOLZUtnNNu0+ j/UK0nOem/hwcN3xsg==; Received: from localhost ([127.0.0.1] helo=dalek.home.treblig.org) by mx.treblig.org with esmtp (Exim 4.96) (envelope-from ) id 1uOPWG-008IvT-0N; Sun, 08 Jun 2025 23:33:40 +0000 From: linux@treblig.org To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Dr. David Alan Gilbert" Subject: [PATCH 2/2] usb: gadget: Remove unused usb_remove_config Date: Mon, 9 Jun 2025 00:33:38 +0100 Message-ID: <20250608233338.179894-3-linux@treblig.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250608233338.179894-1-linux@treblig.org> References: <20250608233338.179894-1-linux@treblig.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: "Dr. David Alan Gilbert" usb_remove_config() was added in 2012's commit Fixes: 51cce6fc155c ("usb: gadget: composite: Add usb_remove_config") but has remained unused. I see there was a use in drivers/staging/cch that was removed by commit 515e6dd20b3f ("Staging: ccg: delete it from the tree") but it had it's own copy of usb_remove_config() Remove it. Signed-off-by: Dr. David Alan Gilbert --- drivers/usb/gadget/composite.c | 24 ------------------------ include/linux/usb/composite.h | 3 --- 2 files changed, 27 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 8dbc132a505e..a0353a322704 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1194,30 +1194,6 @@ static void remove_config(struct usb_composite_dev *cdev, } } -/** - * usb_remove_config() - remove a configuration from a device. - * @cdev: wraps the USB gadget - * @config: the configuration - * - * Drivers must call usb_gadget_disconnect before calling this function - * to disconnect the device from the host and make sure the host will not - * try to enumerate the device while we are changing the config list. - */ -void usb_remove_config(struct usb_composite_dev *cdev, - struct usb_configuration *config) -{ - unsigned long flags; - - spin_lock_irqsave(&cdev->lock, flags); - - if (cdev->config == config) - reset_config(cdev); - - spin_unlock_irqrestore(&cdev->lock, flags); - - remove_config(cdev, config); -} - /*-------------------------------------------------------------------------*/ /* We support strings in multiple languages ... string descriptor zero diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index d8c4e9f73839..c18041fafa52 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -339,9 +339,6 @@ int usb_add_config(struct usb_composite_dev *, struct usb_configuration *, int (*)(struct usb_configuration *)); -void usb_remove_config(struct usb_composite_dev *, - struct usb_configuration *); - /* predefined index for usb_composite_driver */ enum { USB_GADGET_MANUFACTURER_IDX = 0,