Commit e8b6f8c5 authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Greg Kroah-Hartman

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: default avatarMichal Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 481e4929
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
/*-------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
#define FSG_DRIVER_DESC "Mass Storage Function" #define FSG_DRIVER_DESC "Mass Storage Function"
#define FSG_DRIVER_VERSION "20 November 2008" #define FSG_DRIVER_VERSION "20 November 2008"
...@@ -275,6 +275,8 @@ struct fsg_common { ...@@ -275,6 +275,8 @@ struct fsg_common {
unsigned int can_stall:1; unsigned int can_stall:1;
unsigned int free_storage_on_release:1; unsigned int free_storage_on_release:1;
const char *thread_name;
/* Vendor (8 chars), product (16 chars), release (4 /* Vendor (8 chars), product (16 chars), release (4
* hexadecimal digits) and NUL byte */ * hexadecimal digits) and NUL byte */
char inquiry_string[8 + 16 + 4 + 1]; char inquiry_string[8 + 16 + 4 + 1];
...@@ -292,6 +294,9 @@ struct fsg_config { ...@@ -292,6 +294,9 @@ struct fsg_config {
char cdrom; char cdrom;
} luns[FSG_MAX_LUNS]; } luns[FSG_MAX_LUNS];
const char *lun_name_format;
const char *thread_name;
const char *vendor_name; /* 8 characters or less */ const char *vendor_name; /* 8 characters or less */
const char *product_name; /* 16 characters or less */ const char *product_name; /* 16 characters or less */
u16 release; u16 release;
...@@ -2524,8 +2529,11 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, ...@@ -2524,8 +2529,11 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
curlun->dev.parent = &gadget->dev; curlun->dev.parent = &gadget->dev;
/* curlun->dev.driver = &fsg_driver.driver; XXX */ /* curlun->dev.driver = &fsg_driver.driver; XXX */
dev_set_drvdata(&curlun->dev, &common->filesem); dev_set_drvdata(&curlun->dev, &common->filesem);
dev_set_name(&curlun->dev,"%s-lun%d", dev_set_name(&curlun->dev,
dev_name(&gadget->dev), i); cfg->lun_name_format
? cfg->lun_name_format
: "lun%d",
i);
rc = device_register(&curlun->dev); rc = device_register(&curlun->dev);
if (rc) { if (rc) {
...@@ -2590,7 +2598,6 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, ...@@ -2590,7 +2598,6 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
? "File-Stor Gadget" ? "File-Stor Gadget"
: "File-CD Gadget "), : "File-CD Gadget "),
i); i);
#undef OR
/* Some peripheral controllers are known not to be able to /* 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,7 +2608,10 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
!(gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget)); !(gadget_is_sh(fsg->gadget) || gadget_is_at91(fsg->gadget));
common->thread_name = OR(cfg->thread_name, "file-storage");
kref_init(&common->ref); kref_init(&common->ref);
#undef OR
/* Information */ /* Information */
INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); 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,7 +2751,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
fsg->thread_task = kthread_create(fsg_main_thread, fsg, fsg->thread_task = kthread_create(fsg_main_thread, fsg,
"file-storage-gadget"); fsg->common->thread_name);
if (IS_ERR(fsg->thread_task)) { if (IS_ERR(fsg->thread_task)) {
rc = PTR_ERR(fsg->thread_task); rc = PTR_ERR(fsg->thread_task);
goto out; goto out;
...@@ -2884,6 +2894,8 @@ fsg_config_from_params(struct fsg_config *cfg, ...@@ -2884,6 +2894,8 @@ fsg_config_from_params(struct fsg_config *cfg,
} }
/* Let FSG use defaults */ /* Let FSG use defaults */
cfg->lun_name_format = 0;
cfg->thread_name = 0;
cfg->vendor_name = 0; cfg->vendor_name = 0;
cfg->product_name = 0; cfg->product_name = 0;
cfg->release = 0xffff; cfg->release = 0xffff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment