]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
USB: gadget: g_mass_storage: static data instead of dynamic allocation
authorMichal Nazarewicz <m.nazarewicz@samsung.com>
Wed, 16 Jun 2010 10:07:56 +0000 (12:07 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 10 Aug 2010 21:35:36 +0000 (14:35 -0700)
This patch changes msg_do_config() function so that it uses
a static object for a fsg_common structure instead of dynamically
allocated.  This is a micro-optimisation.

Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/mass_storage.c

index 705cc1f76327c6cc953f4b2efcc6788a77ef760d..e68c00e0876596c6fa47bd470e6ca1fb74b6a36a 100644 (file)
@@ -143,7 +143,9 @@ static int msg_thread_exits(struct fsg_common *common)
 
 static int __init msg_do_config(struct usb_configuration *c)
 {
-       struct fsg_common *common;
+       static struct fsg_common common;
+
+       struct fsg_common *retp;
        struct fsg_config config;
        int ret;
 
@@ -154,12 +156,13 @@ static int __init msg_do_config(struct usb_configuration *c)
 
        fsg_config_from_params(&config, &mod_data);
        config.thread_exits = msg_thread_exits;
-       common = fsg_common_init(0, c->cdev, &config);
-       if (IS_ERR(common))
-               return PTR_ERR(common);
 
-       ret = fsg_add(c->cdev, c, common);
-       fsg_common_put(common);
+       retp = fsg_common_init(&common, c->cdev, &config);
+       if (IS_ERR(retp))
+               return PTR_ERR(retp);
+
+       ret = fsg_add(c->cdev, c, &common);
+       fsg_common_put(&common);
        return ret;
 }