aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-12-03 12:59:31 -0500
committerTakashi Iwai <tiwai@suse.de>2014-12-03 14:30:04 -0500
commit5395103dcc709d87f08edaecb786fc37781f3b22 (patch)
tree7d4d65a2d84b215579a0ec72cbc694bef355e696
parent103884a351a221553095c509a1dbbbf7d4fd9b05 (diff)
ALSA: ctxfi: Neaten get_daio_rsc
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 <joe@perches.com> Noticed-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/ctxfi/ctdaio.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index c1c3f8816fff..9b87dd28de83 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,
528 struct daio **rdaio) 528 struct daio **rdaio)
529{ 529{
530 int err; 530 int err;
531 struct dai *dai = NULL;
532 struct dao *dao = NULL;
533 unsigned long flags; 531 unsigned long flags;
534 532
535 *rdaio = NULL; 533 *rdaio = NULL;
@@ -544,27 +542,30 @@ static int get_daio_rsc(struct daio_mgr *mgr,
544 return err; 542 return err;
545 } 543 }
546 544
545 err = -ENOMEM;
547 /* Allocate mem for daio resource */ 546 /* Allocate mem for daio resource */
548 if (desc->type <= DAIO_OUT_MAX) { 547 if (desc->type <= DAIO_OUT_MAX) {
549 dao = kzalloc(sizeof(*dao), GFP_KERNEL); 548 struct dao *dao = kzalloc(sizeof(*dao), GFP_KERNEL);
550 if (!dao) { 549 if (!dao)
551 err = -ENOMEM;
552 goto error; 550 goto error;
553 } 551
554 err = dao_rsc_init(dao, desc, mgr); 552 err = dao_rsc_init(dao, desc, mgr);
555 if (err) 553 if (err) {
554 kfree(dao);
556 goto error; 555 goto error;
556 }
557 557
558 *rdaio = &dao->daio; 558 *rdaio = &dao->daio;
559 } else { 559 } else {
560 dai = kzalloc(sizeof(*dai), GFP_KERNEL); 560 struct dai *dai = kzalloc(sizeof(*dai), GFP_KERNEL);
561 if (!dai) { 561 if (!dai)
562 err = -ENOMEM;
563 goto error; 562 goto error;
564 } 563
565 err = dai_rsc_init(dai, desc, mgr); 564 err = dai_rsc_init(dai, desc, mgr);
566 if (err) 565 if (err) {
566 kfree(dai);
567 goto error; 567 goto error;
568 }
568 569
569 *rdaio = &dai->daio; 570 *rdaio = &dai->daio;
570 } 571 }
@@ -575,11 +576,6 @@ static int get_daio_rsc(struct daio_mgr *mgr,
575 return 0; 576 return 0;
576 577
577error: 578error:
578 if (dao)
579 kfree(dao);
580 else if (dai)
581 kfree(dai);
582
583 spin_lock_irqsave(&mgr->mgr_lock, flags); 579 spin_lock_irqsave(&mgr->mgr_lock, flags);
584 daio_mgr_put_rsc(&mgr->mgr, desc->type); 580 daio_mgr_put_rsc(&mgr->mgr, desc->type);
585 spin_unlock_irqrestore(&mgr->mgr_lock, flags); 581 spin_unlock_irqrestore(&mgr->mgr_lock, flags);