From patchwork Fri Jul 1 08:01:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9209463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AE9660221 for ; Fri, 1 Jul 2016 08:19:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CBE92868E for ; Fri, 1 Jul 2016 08:19:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8175228695; Fri, 1 Jul 2016 08:19:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A5012868E for ; Fri, 1 Jul 2016 08:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752612AbcGAIKT (ORCPT ); Fri, 1 Jul 2016 04:10:19 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:53665 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbcGAIE2 (ORCPT ); Fri, 1 Jul 2016 04:04:28 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9M027M8MAZ67A0@mailout3.samsung.com>; Fri, 01 Jul 2016 17:01:47 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 0E.13.05160.B6326775; Fri, 1 Jul 2016 17:01:47 +0900 (KST) X-AuditID: cbfee68e-f79266d000001428-af-5776236b130b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 60.19.04429.B6326775; Fri, 1 Jul 2016 01:01:47 -0700 (MST) Received: from samsunx.samsung ([10.113.63.54]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9M00G9YMAVFJA0@mmp2.samsung.com>; Fri, 01 Jul 2016 17:01:46 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: Joe Perches , Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v2 05/15] [media] lirc_dev: simplify goto paths Date: Fri, 01 Jul 2016 17:01:28 +0900 Message-id: <1467360098-12539-6-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467360098-12539-1-git-send-email-andi.shyti@samsung.com> References: <1467360098-12539-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsWyRsSkUDdbuSzcoK9J2GL7kWesFot/PGey mH3/MYvF5V1z2Cx6NmxltVj9rMJi4dPvLA7sHteXfGL2WPLG2mNL/112jy+rrjF79G1Zxejx eZNcAFsUl01Kak5mWWqRvl0CV0bLv6lsBZ9FK6ackWhgvCXQxcjJISFgInFqZxMzhC0mceHe erYuRi4OIYEVjBJ7H91lgyn69OIFI0RiFqPEyUuzWSGcj4wS6+7vYgepYhPQlGi6/QOog4ND RMBY4twPdZAws8ABRonebhcQW1jAXuLola1g21gEVCU63z1jAbF5Bdwkvj3sZYVYJidxefoD sMWcAu4Sd9/tYgSxhYBq5u66xw6yV0JgGbtEw5oZbBCDBCS+TT7EArJXQkBWYtMBqG8kJQ6u u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za8++u/zmhvbdvrZ3ervjSscnh3InL 8SLpjOs3WEQ7LK3/fmbRHEc3XY5w1h3/hBe1NF1hFjs66bnC/dgannf35mSxhmjLxgvxtVh/ uZA649GvH6GpvkUOE9JFzjaWRjjM8pwSyLkuznzPFQtHo4TFewJyt3orsRRnJBpqMRcVJwIA zuuGcb0CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The code can be rearranged so that some goto paths can be removed Signed-off-by: Andi Shyti --- drivers/media/rc/lirc_dev.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 212ea77..0d988c9 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -243,52 +243,44 @@ static int lirc_allocate_driver(struct lirc_driver *d) if (!d) { pr_err("driver pointer must be not NULL!\n"); - err = -EBADRQC; - goto out; + return -EBADRQC; } if (!d->dev) { pr_err("dev pointer not filled in!\n"); - err = -EINVAL; - goto out; + return -EINVAL; } if (MAX_IRCTL_DEVICES <= d->minor) { dev_err(d->dev, "minor must be between 0 and %d!\n", MAX_IRCTL_DEVICES - 1); - err = -EBADRQC; - goto out; + return -EBADRQC; } if (1 > d->code_length || (BUFLEN * 8) < d->code_length) { dev_err(d->dev, "code length must be less than %d bits\n", BUFLEN * 8); - err = -EBADRQC; - goto out; + return -EBADRQC; } if (d->sample_rate) { if (2 > d->sample_rate || HZ < d->sample_rate) { dev_err(d->dev, "invalid %d sample rate\n", d->sample_rate); - err = -EBADRQC; - goto out; + return -EBADRQC; } if (!d->add_to_buf) { dev_err(d->dev, "add_to_buf not set\n"); - err = -EBADRQC; - goto out; + return -EBADRQC; } } else if (!(d->fops && d->fops->read) && !d->rbuf) { dev_err(d->dev, "fops->read and rbuf are NULL!\n"); - err = -EBADRQC; - goto out; + return -EBADRQC; } else if (!d->rbuf) { if (!(d->fops && d->fops->read && d->fops->poll && d->fops->unlocked_ioctl)) { dev_err(d->dev, "undefined read, poll, ioctl\n"); - err = -EBADRQC; - goto out; + return -EBADRQC; } } @@ -366,7 +358,7 @@ out_sysfs: device_destroy(lirc_class, MKDEV(MAJOR(lirc_base_dev), ir->d.minor)); out_lock: mutex_unlock(&lirc_dev_lock); -out: + return err; } @@ -794,9 +786,8 @@ static int __init lirc_dev_init(void) lirc_class = class_create(THIS_MODULE, "lirc"); if (IS_ERR(lirc_class)) { - retval = PTR_ERR(lirc_class); pr_err("class_create failed\n"); - goto error; + return PTR_ERR(lirc_class); } retval = alloc_chrdev_region(&lirc_base_dev, 0, MAX_IRCTL_DEVICES, @@ -804,15 +795,14 @@ static int __init lirc_dev_init(void) if (retval) { class_destroy(lirc_class); pr_err("alloc_chrdev_region failed\n"); - goto error; + return retval; } pr_info("IR Remote Control driver registered, major %d\n", MAJOR(lirc_base_dev)); -error: - return retval; + return 0; }