* [PATCH 0/2] usb: gadget: A couple of dead functions
@ 2025-06-08 23:33 linux
2025-06-08 23:33 ` [PATCH 1/2] usb: gadget: config: Remove unused usb_gadget_config_buf linux
2025-06-08 23:33 ` [PATCH 2/2] usb: gadget: Remove unused usb_remove_config linux
0 siblings, 2 replies; 3+ messages in thread
From: linux @ 2025-06-08 23:33 UTC (permalink / raw)
To: gregkh, linux-usb; +Cc: linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
This removed a couple of long dead functions in the gadget code.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Dr. David Alan Gilbert (2):
usb: gadget: config: Remove unused usb_gadget_config_buf
usb: gadget: Remove unused usb_remove_config
drivers/usb/gadget/composite.c | 24 ---------------
drivers/usb/gadget/config.c | 53 ----------------------------------
include/linux/usb/composite.h | 3 --
include/linux/usb/gadget.h | 4 ---
4 files changed, 84 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] usb: gadget: config: Remove unused usb_gadget_config_buf
2025-06-08 23:33 [PATCH 0/2] usb: gadget: A couple of dead functions linux
@ 2025-06-08 23:33 ` linux
2025-06-08 23:33 ` [PATCH 2/2] usb: gadget: Remove unused usb_remove_config linux
1 sibling, 0 replies; 3+ messages in thread
From: linux @ 2025-06-08 23:33 UTC (permalink / raw)
To: gregkh, linux-usb; +Cc: linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
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 <linux@treblig.org>
---
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 **);
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] usb: gadget: Remove unused usb_remove_config
2025-06-08 23:33 [PATCH 0/2] usb: gadget: A couple of dead functions linux
2025-06-08 23:33 ` [PATCH 1/2] usb: gadget: config: Remove unused usb_gadget_config_buf linux
@ 2025-06-08 23:33 ` linux
1 sibling, 0 replies; 3+ messages in thread
From: linux @ 2025-06-08 23:33 UTC (permalink / raw)
To: gregkh, linux-usb; +Cc: linux-kernel, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <linux@treblig.org>
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 <linux@treblig.org>
---
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,
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-08 23:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-08 23:33 [PATCH 0/2] usb: gadget: A couple of dead functions linux
2025-06-08 23:33 ` [PATCH 1/2] usb: gadget: config: Remove unused usb_gadget_config_buf linux
2025-06-08 23:33 ` [PATCH 2/2] usb: gadget: Remove unused usb_remove_config linux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).