summaryrefslogtreecommitdiff
path: root/drivers/staging/line6/driver.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-23 16:09:56 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-23 16:09:56 -0700
commitc46b8a6567fb6e0119cb22819aa65faf8d101a2f (patch)
tree83d1d93347ec655c02a3d5152be748e798c44eda /drivers/staging/line6/driver.c
parent305b8766a9833491b388ac98d57ce38a8106a1e0 (diff)
Staging: line6: only allocate a buffer if it is needed
Only allocate the version request buffer if it is needed, not when the module starts up. This will let us make the module_init path much smaller. CC: Markus Grabner <grabner@icg.tugraz.at> CC: Stefan Hajnoczi <stefanha@gmail.com> CC: Julia Lawall <julia@diku.dk> CC: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/line6/driver.c')
-rw-r--r--drivers/staging/line6/driver.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c
index 312905afe5e6..351e8606db3d 100644
--- a/drivers/staging/line6/driver.c
+++ b/drivers/staging/line6/driver.c
@@ -92,15 +92,10 @@ const unsigned char line6_midi_id[] = {
Code to request version of POD, Variax interface
(and maybe other devices).
*/
-static const char line6_request_version0[] = {
+static const char line6_request_version[] = {
0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
};
-/*
- Copy of version request code with GFP_KERNEL flag for use in URB.
-*/
-static const char *line6_request_version;
-
struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
/**
@@ -336,8 +331,21 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
*/
int line6_version_request_async(struct usb_line6 *line6)
{
- return line6_send_raw_message_async(line6, line6_request_version,
- sizeof(line6_request_version0));
+ char *buffer;
+ int retval;
+
+ buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC);
+ if (buffer == NULL) {
+ dev_err(line6->ifcdev, "Out of memory");
+ return -ENOMEM;
+ }
+
+ memcpy(buffer, line6_request_version, sizeof(line6_request_version));
+
+ retval = line6_send_raw_message_async(line6, buffer,
+ sizeof(line6_request_version));
+ kfree(buffer);
+ return retval;
}
/*
@@ -1297,29 +1305,9 @@ static struct usb_driver line6_driver = {
*/
static int __init line6_init(void)
{
- int retval;
-
printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION);
- retval = usb_register(&line6_driver);
-
- if (retval) {
- err("usb_register failed. Error number %d", retval);
- return retval;
- }
-
- line6_request_version = kmalloc(sizeof(line6_request_version0),
- GFP_KERNEL);
-
- if (line6_request_version == NULL) {
- err("Out of memory");
- return -ENOMEM;
- }
-
- memcpy((char *)line6_request_version, line6_request_version0,
- sizeof(line6_request_version0));
-
- return retval;
+ return usb_register(&line6_driver);
}
/*
@@ -1347,7 +1335,6 @@ static void __exit line6_exit(void)
}
usb_deregister(&line6_driver);
- kfree(line6_request_version);
}
module_init(line6_init);