aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/composite.h
diff options
context:
space:
mode:
authorMichal Nazarewicz <m.nazarewicz@samsung.com>2010-08-12 11:43:46 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:21:23 -0400
commitad1a8102f957f4d25fc58cdc10736c5ade7557e1 (patch)
treea9bb1ee6b26a2171e43edc77dc51fdb839135d90 /include/linux/usb/composite.h
parentfc19de61ef5c17b6e19766052c6ac85cf31de876 (diff)
USB: gadget: composite: Better string override handling
The iManufatcurer, iProduct and iSerialNumber composite module parameters were only used when the gadget driver registers strings for manufacturer, product and serial number. If the gadget never bothered to set corresponding fields in USB device descriptors those module parameters are ignored. This commit makes the parameters work even if the strings ID have not been assigned. It also changes the way IDs are overridden -- what IDs are overridden is now saved in usb_composite_dev structure -- which makes it unnecessary to modify the string tables the way previous code did. The commit also adds a iProduct and iManufatcurer fields to the usb_composite_device structure. If they are set, appropriate strings are reserved and added to device descriptor. This makes it unnecessary for gadget drivers to maintain code for setting those. If iProduct is not set it defaults to usb_composite_device::name; if iManufatcurer is not set a default "<system> <release> with <gadget-name>" is used. The last thing is that if needs_serial field of usb_composite_device is set and user failed to provided iSerialNumber parameter a warning is issued. Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/usb/composite.h')
-rw-r--r--include/linux/usb/composite.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 617068134ae..a78e813d27e 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -237,10 +237,17 @@ int usb_add_config(struct usb_composite_dev *,
237/** 237/**
238 * struct usb_composite_driver - groups configurations into a gadget 238 * struct usb_composite_driver - groups configurations into a gadget
239 * @name: For diagnostics, identifies the driver. 239 * @name: For diagnostics, identifies the driver.
240 * @iProduct: Used as iProduct override if @dev->iProduct is not set.
241 * If NULL value of @name is taken.
242 * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
243 * not set. If NULL a default "<system> <release> with <udc>" value
244 * will be used.
240 * @dev: Template descriptor for the device, including default device 245 * @dev: Template descriptor for the device, including default device
241 * identifiers. 246 * identifiers.
242 * @strings: tables of strings, keyed by identifiers assigned during bind() 247 * @strings: tables of strings, keyed by identifiers assigned during bind()
243 * and language IDs provided in control requests 248 * and language IDs provided in control requests
249 * @needs_serial: set to 1 if the gadget needs userspace to provide
250 * a serial number. If one is not provided, warning will be printed.
244 * @bind: (REQUIRED) Used to allocate resources that are shared across the 251 * @bind: (REQUIRED) Used to allocate resources that are shared across the
245 * whole device, such as string IDs, and add its configurations using 252 * whole device, such as string IDs, and add its configurations using
246 * @usb_add_config(). This may fail by returning a negative errno 253 * @usb_add_config(). This may fail by returning a negative errno
@@ -266,8 +273,11 @@ int usb_add_config(struct usb_composite_dev *,
266 */ 273 */
267struct usb_composite_driver { 274struct usb_composite_driver {
268 const char *name; 275 const char *name;
276 const char *iProduct;
277 const char *iManufacturer;
269 const struct usb_device_descriptor *dev; 278 const struct usb_device_descriptor *dev;
270 struct usb_gadget_strings **strings; 279 struct usb_gadget_strings **strings;
280 unsigned needs_serial:1;
271 281
272 /* REVISIT: bind() functions can be marked __init, which 282 /* REVISIT: bind() functions can be marked __init, which
273 * makes trouble for section mismatch analysis. See if 283 * makes trouble for section mismatch analysis. See if
@@ -334,6 +344,9 @@ struct usb_composite_dev {
334 struct list_head configs; 344 struct list_head configs;
335 struct usb_composite_driver *driver; 345 struct usb_composite_driver *driver;
336 u8 next_string_id; 346 u8 next_string_id;
347 u8 manufacturer_override;
348 u8 product_override;
349 u8 serial_override;
337 350
338 /* the gadget driver won't enable the data pullup 351 /* the gadget driver won't enable the data pullup
339 * while the deactivation count is nonzero. 352 * while the deactivation count is nonzero.