aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorMichal Nazarewicz <m.nazarewicz@samsung.com>2009-11-09 08:15:22 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 14:55:22 -0500
commite8b6f8c5aa001235423878ef70bda919652e10be (patch)
treecf61f66cd4b0fe886e1aa4a73c47a065af513a39 /drivers/usb/gadget
parent481e49296ae6979891af30c9858511d4347a5393 (diff)
USB: g_mass_storage: lun_name_format and thread_name added
A two fsg_config fields were added: * lun_name_format which lets one specify format of a name used when registering LUN devices. It is useful if there would be ever need for two MSFs to be used in a single composite gadget (as opposed to single MSF in two configuration); and * thread_name which lets one specify the name of a kernel thread used by MSF. This is not required since two or more threads can have the same name but nevertheless it's here for consistency. Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/f_mass_storage.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index e7c9f0ce86b6..837aab624a46 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -233,7 +233,7 @@
233 233
234 234
235 235
236/*-------------------------------------------------------------------------*/ 236/*------------------------------------------------------------------------*/
237 237
238#define FSG_DRIVER_DESC "Mass Storage Function" 238#define FSG_DRIVER_DESC "Mass Storage Function"
239#define FSG_DRIVER_VERSION "20 November 2008" 239#define FSG_DRIVER_VERSION "20 November 2008"
@@ -275,6 +275,8 @@ struct fsg_common {
275 unsigned int can_stall:1; 275 unsigned int can_stall:1;
276 unsigned int free_storage_on_release:1; 276 unsigned int free_storage_on_release:1;
277 277
278 const char *thread_name;
279
278 /* Vendor (8 chars), product (16 chars), release (4 280 /* Vendor (8 chars), product (16 chars), release (4
279 * hexadecimal digits) and NUL byte */ 281 * hexadecimal digits) and NUL byte */
280 char inquiry_string[8 + 16 + 4 + 1]; 282 char inquiry_string[8 + 16 + 4 + 1];
@@ -292,6 +294,9 @@ struct fsg_config {
292 char cdrom; 294 char cdrom;
293 } luns[FSG_MAX_LUNS]; 295 } luns[FSG_MAX_LUNS];
294 296
297 const char *lun_name_format;
298 const char *thread_name;
299
295 const char *vendor_name; /* 8 characters or less */ 300 const char *vendor_name; /* 8 characters or less */
296 const char *product_name; /* 16 characters or less */ 301 const char *product_name; /* 16 characters or less */
297 u16 release; 302 u16 release;
@@ -2524,8 +2529,11 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
2524 curlun->dev.parent = &gadget->dev; 2529 curlun->dev.parent = &gadget->dev;
2525 /* curlun->dev.driver = &fsg_driver.driver; XXX */ 2530 /* curlun->dev.driver = &fsg_driver.driver; XXX */
2526 dev_set_drvdata(&curlun->dev, &common->filesem); 2531 dev_set_drvdata(&curlun->dev, &common->filesem);
2527 dev_set_name(&curlun->dev,"%s-lun%d", 2532 dev_set_name(&curlun->dev,
2528 dev_name(&gadget->dev), i); 2533 cfg->lun_name_format
2534 ? cfg->lun_name_format
2535 : "lun%d",
2536 i);
2529 2537
2530 rc = device_register(&curlun->dev); 2538 rc = device_register(&curlun->dev);
2531 if (rc) { 2539 if (rc) {
@@ -2590,7 +2598,6 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
2590 ? "File-Stor Gadget" 2598 ? "File-Stor Gadget"
2591 : "File-CD Gadget "), 2599 : "File-CD Gadget "),
2592 i); 2600 i);
2593#undef OR
2594 2601
2595 2602
2596 /* Some peripheral controllers are known not to be able to 2603 /* Some peripheral controllers are known not to be able to
@@ -2601,7 +2608,10 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
2601 !(gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget)); 2608 !(gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget));
2602 2609
2603 2610
2611 common->thread_name = OR(cfg->thread_name, "file-storage");
2604 kref_init(&common->ref); 2612 kref_init(&common->ref);
2613#undef OR
2614
2605 2615
2606 /* Information */ 2616 /* Information */
2607 INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); 2617 INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n");
@@ -2741,7 +2751,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2741 2751
2742 2752
2743 fsg->thread_task = kthread_create(fsg_main_thread, fsg, 2753 fsg->thread_task = kthread_create(fsg_main_thread, fsg,
2744 "file-storage-gadget"); 2754 fsg->common->thread_name);
2745 if (IS_ERR(fsg->thread_task)) { 2755 if (IS_ERR(fsg->thread_task)) {
2746 rc = PTR_ERR(fsg->thread_task); 2756 rc = PTR_ERR(fsg->thread_task);
2747 goto out; 2757 goto out;
@@ -2884,6 +2894,8 @@ fsg_config_from_params(struct fsg_config *cfg,
2884 } 2894 }
2885 2895
2886 /* Let FSG use defaults */ 2896 /* Let FSG use defaults */
2897 cfg->lun_name_format = 0;
2898 cfg->thread_name = 0;
2887 cfg->vendor_name = 0; 2899 cfg->vendor_name = 0;
2888 cfg->product_name = 0; 2900 cfg->product_name = 0;
2889 cfg->release = 0xffff; 2901 cfg->release = 0xffff;