aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-23 19:09:56 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-23 19:09:56 -0400
commitc46b8a6567fb6e0119cb22819aa65faf8d101a2f (patch)
tree83d1d93347ec655c02a3d5152be748e798c44eda
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>
-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[] = {
92 Code to request version of POD, Variax interface 92 Code to request version of POD, Variax interface
93 (and maybe other devices). 93 (and maybe other devices).
94*/ 94*/
95static const char line6_request_version0[] = { 95static const char line6_request_version[] = {
96 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7 96 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
97}; 97};
98 98
99/*
100 Copy of version request code with GFP_KERNEL flag for use in URB.
101*/
102static const char *line6_request_version;
103
104struct usb_line6 *line6_devices[LINE6_MAX_DEVICES]; 99struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
105 100
106/** 101/**
@@ -336,8 +331,21 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
336*/ 331*/
337int line6_version_request_async(struct usb_line6 *line6) 332int line6_version_request_async(struct usb_line6 *line6)
338{ 333{
339 return line6_send_raw_message_async(line6, line6_request_version, 334 char *buffer;
340 sizeof(line6_request_version0)); 335 int retval;
336
337 buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC);
338 if (buffer == NULL) {
339 dev_err(line6->ifcdev, "Out of memory");
340 return -ENOMEM;
341 }
342
343 memcpy(buffer, line6_request_version, sizeof(line6_request_version));
344
345 retval = line6_send_raw_message_async(line6, buffer,
346 sizeof(line6_request_version));
347 kfree(buffer);
348 return retval;
341} 349}
342 350
343/* 351/*
@@ -1297,29 +1305,9 @@ static struct usb_driver line6_driver = {
1297*/ 1305*/
1298static int __init line6_init(void) 1306static int __init line6_init(void)
1299{ 1307{
1300 int retval;
1301
1302 printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION); 1308 printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION);
1303 1309
1304 retval = usb_register(&line6_driver); 1310 return usb_register(&line6_driver);
1305
1306 if (retval) {
1307 err("usb_register failed. Error number %d", retval);
1308 return retval;
1309 }
1310
1311 line6_request_version = kmalloc(sizeof(line6_request_version0),
1312 GFP_KERNEL);
1313
1314 if (line6_request_version == NULL) {
1315 err("Out of memory");
1316 return -ENOMEM;
1317 }
1318
1319 memcpy((char *)line6_request_version, line6_request_version0,
1320 sizeof(line6_request_version0));
1321
1322 return retval;
1323} 1311}
1324 1312
1325/* 1313/*
@@ -1347,7 +1335,6 @@ static void __exit line6_exit(void)
1347 } 1335 }
1348 1336
1349 usb_deregister(&line6_driver); 1337 usb_deregister(&line6_driver);
1350 kfree(line6_request_version);
1351} 1338}
1352 1339
1353module_init(line6_init); 1340module_init(line6_init);