Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757931Ab0FBMpA (ORCPT ); Wed, 2 Jun 2010 08:45:00 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:57176 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756264Ab0FBMo4 (ORCPT ); Wed, 2 Jun 2010 08:44:56 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Date: Wed, 02 Jun 2010 14:45:22 +0200 From: Michal Nazarewicz Subject: [PATCHv3 01/11] USB: gadget: g_mass_storage: static data instead of dynamic allocation In-reply-to: To: linux-usb@vger.kernel.org Cc: David Brownell , Kyungmin Park , Marek Szyprowski , linux-kernel@vger.kernel.org Message-id: <5e151207bced1e418bcfed136a871d2da47e417e.1275481997.git.mina86@mina86.com> X-Mailer: git-send-email 1.7.1 References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1620 Lines: 50 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 Signed-off-by: Kyungmin Park --- drivers/usb/gadget/mass_storage.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 705cc1f..a3349f2 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -143,7 +143,7 @@ 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, *retp; struct fsg_config config; int ret; @@ -154,12 +154,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; } -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/