From patchwork Wed Dec 3 17:59:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 5432681 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 65C399F319 for ; Wed, 3 Dec 2014 18:00:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85C232028D for ; Wed, 3 Dec 2014 18:00:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6188A2012D for ; Wed, 3 Dec 2014 18:00:22 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5311F2604F8; Wed, 3 Dec 2014 19:00:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5DC622604A3; Wed, 3 Dec 2014 19:00:06 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 30D442604DF; Wed, 3 Dec 2014 19:00:05 +0100 (CET) Received: from smtprelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by alsa0.perex.cz (Postfix) with ESMTP id B890626049C for ; Wed, 3 Dec 2014 18:59:35 +0100 (CET) Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 488B829DE09; Wed, 3 Dec 2014 17:59:34 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: scene77_53586b8e69949 X-Filterd-Recvd-Size: 4611 Received: from joe-X200MA.home (pool-71-103-235-196.lsanca.fios.verizon.net [71.103.235.196]) (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA; Wed, 3 Dec 2014 17:59:32 +0000 (UTC) Message-ID: <1417629571.2902.16.camel@perches.com> From: Joe Perches To: Takashi Iwai Date: Wed, 03 Dec 2014 09:59:31 -0800 In-Reply-To: References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <547E2612.6010304@users.sourceforge.net> <547EF64B.1080403@users.sourceforge.net> <1417626888.2902.13.camel@perches.com> X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, LKML , Julia Lawall , SF Markus Elfring Subject: [alsa-devel] [PATCH] ALSA: ctxfi: Neaten get_daio_rsc X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Move the pointer declarations into the blocks that use them. Neaten the kfree calls when the _init functions fail. Trivially reduces object size (defconfig x86-64) $ size sound/pci/ctxfi/ctdaio.o.* text data bss dec hex filename 5287 224 0 5511 1587 sound/pci/ctxfi/ctdaio.o.new 5319 224 0 5543 15a7 sound/pci/ctxfi/ctdaio.o.old Signed-off-by: Joe Perches Noticed-by: Markus Elfring --- On Wed, 2014-12-03 at 18:30 +0100, Takashi Iwai wrote: > At Wed, 03 Dec 2014 09:14:48 -0800, Joe Perches wrote: > > On Wed, 2014-12-03 at 13:41 +0100, Takashi Iwai wrote: > > Takashi, what did you think of this? > > https://lkml.org/lkml/2014/12/2/771 > > > > Just unnecessary? > > Well, this one looks more consistent. But honestly speaking, it's > rather a matter of taste. So I'm not so much inclined to merge the > stuff, too, sorry. If it's proven to reduce the compiled size, etc, > I'll happily apply it, though. sound/pci/ctxfi/ctdaio.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index c1c3f88..9b87dd2 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -528,8 +528,6 @@ static int get_daio_rsc(struct daio_mgr *mgr, struct daio **rdaio) { int err; - struct dai *dai = NULL; - struct dao *dao = NULL; unsigned long flags; *rdaio = NULL; @@ -544,27 +542,30 @@ static int get_daio_rsc(struct daio_mgr *mgr, return err; } + err = -ENOMEM; /* Allocate mem for daio resource */ if (desc->type <= DAIO_OUT_MAX) { - dao = kzalloc(sizeof(*dao), GFP_KERNEL); - if (!dao) { - err = -ENOMEM; + struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL); + if (!dao) goto error; - } + err = dao_rsc_init(dao, desc, mgr); - if (err) + if (err) { + kfree(dao); goto error; + } *rdaio = &dao->daio; } else { - dai = kzalloc(sizeof(*dai), GFP_KERNEL); - if (!dai) { - err = -ENOMEM; + struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL); + if (!dai) goto error; - } + err = dai_rsc_init(dai, desc, mgr); - if (err) + if (err) { + kfree(dai); goto error; + } *rdaio = &dai->daio; } @@ -575,11 +576,6 @@ static int get_daio_rsc(struct daio_mgr *mgr, return 0; error: - if (dao) - kfree(dao); - else if (dai) - kfree(dai); - spin_lock_irqsave(&mgr->mgr_lock, flags); daio_mgr_put_rsc(&mgr->mgr, desc->type); spin_unlock_irqrestore(&mgr->mgr_lock, flags);