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

USB: gadget: file_storage: serial parameter even if not test mode

Moved the serial parameter handling code out of "#ifdef
CONFIG_USB_FILE_STORAGE_TEST".

This modifies Yann Cantin's commit "USB: Add a serial number
parameter to g_file_storage" module as per Alan Stern's request.
Signed-off-by: default avatarMichal Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Tested-by: default avatarAnand Gadiyar <gadiyar@ti.com>
Cc: David Brownell <david-b@pacbell.net>
Cc: Yann Cantin <yann.cantin@laposte.net>
parent 9a4b7c3b
...@@ -321,7 +321,7 @@ static struct { ...@@ -321,7 +321,7 @@ static struct {
unsigned short vendor; unsigned short vendor;
unsigned short product; unsigned short product;
unsigned short release; unsigned short release;
char *serial_parm; char *serial;
unsigned int buflen; unsigned int buflen;
int transport_type; int transport_type;
...@@ -365,6 +365,8 @@ MODULE_PARM_DESC(stall, "false to prevent bulk stalls"); ...@@ -365,6 +365,8 @@ MODULE_PARM_DESC(stall, "false to prevent bulk stalls");
module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO); module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk"); MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");
module_param_named(serial, mod_data.serial, charp, S_IRUGO);
MODULE_PARM_DESC(serial, "USB serial number");
/* In the non-TEST version, only the module parameters listed above /* In the non-TEST version, only the module parameters listed above
* are available. */ * are available. */
...@@ -386,9 +388,6 @@ MODULE_PARM_DESC(product, "USB Product ID"); ...@@ -386,9 +388,6 @@ MODULE_PARM_DESC(product, "USB Product ID");
module_param_named(release, mod_data.release, ushort, S_IRUGO); module_param_named(release, mod_data.release, ushort, S_IRUGO);
MODULE_PARM_DESC(release, "USB release number"); MODULE_PARM_DESC(release, "USB release number");
module_param_named(serial, mod_data.serial_parm, charp, S_IRUGO);
MODULE_PARM_DESC(serial, "USB serial number");
module_param_named(buflen, mod_data.buflen, uint, S_IRUGO); module_param_named(buflen, mod_data.buflen, uint, S_IRUGO);
MODULE_PARM_DESC(buflen, "I/O buffer size"); MODULE_PARM_DESC(buflen, "I/O buffer size");
...@@ -3291,10 +3290,12 @@ static int __init check_parameters(struct fsg_dev *fsg) ...@@ -3291,10 +3290,12 @@ static int __init check_parameters(struct fsg_dev *fsg)
return -ETOOSMALL; return -ETOOSMALL;
} }
#endif /* CONFIG_USB_FILE_STORAGE_TEST */
/* Serial string handling. /* Serial string handling.
* On a real device, the serial string would be loaded * On a real device, the serial string would be loaded
* from permanent storage. */ * from permanent storage. */
if (mod_data.serial_parm) { if (mod_data.serial) {
const char *ch; const char *ch;
unsigned len = 0; unsigned len = 0;
...@@ -3303,7 +3304,7 @@ static int __init check_parameters(struct fsg_dev *fsg) ...@@ -3303,7 +3304,7 @@ static int __init check_parameters(struct fsg_dev *fsg)
* 12 uppercase hexadecimal characters. * 12 uppercase hexadecimal characters.
* BBB need at least 12 uppercase hexadecimal characters, * BBB need at least 12 uppercase hexadecimal characters,
* with a maximum of 126. */ * with a maximum of 126. */
for (ch = mod_data.serial_parm; *ch; ++ch) { for (ch = mod_data.serial; *ch; ++ch) {
++len; ++len;
if ((*ch < '0' || *ch > '9') && if ((*ch < '0' || *ch > '9') &&
(*ch < 'A' || *ch > 'F')) { /* not uppercase hex */ (*ch < 'A' || *ch > 'F')) { /* not uppercase hex */
...@@ -3322,8 +3323,11 @@ static int __init check_parameters(struct fsg_dev *fsg) ...@@ -3322,8 +3323,11 @@ static int __init check_parameters(struct fsg_dev *fsg)
"Failing back to default\n"); "Failing back to default\n");
goto fill_serial; goto fill_serial;
} }
fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial_parm; fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial;
} else { } else {
WARNING(fsg,
"Userspace failed to provide serial number; "
"Failing back to default\n");
fill_serial: fill_serial:
/* Serial number not specified or invalid, make our own. /* Serial number not specified or invalid, make our own.
* We just encode it from the driver version string, * We just encode it from the driver version string,
...@@ -3339,8 +3343,6 @@ static int __init check_parameters(struct fsg_dev *fsg) ...@@ -3339,8 +3343,6 @@ static int __init check_parameters(struct fsg_dev *fsg)
} }
} }
#endif /* CONFIG_USB_FILE_STORAGE_TEST */
return 0; return 0;
} }
......
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