From patchwork Wed Jun 29 13:20:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9205111 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 0819A607D8 for ; Wed, 29 Jun 2016 13:24:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE66E285BA for ; Wed, 29 Jun 2016 13:24:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E325228655; Wed, 29 Jun 2016 13:24:16 +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 8B86F285BA for ; Wed, 29 Jun 2016 13:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721AbcF2NXn (ORCPT ); Wed, 29 Jun 2016 09:23:43 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:56899 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752537AbcF2NVD (ORCPT ); Wed, 29 Jun 2016 09:21:03 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9J00GRZBQWA220@mailout4.samsung.com>; Wed, 29 Jun 2016 22:20:56 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 2F.5E.05161.83BC3775; Wed, 29 Jun 2016 22:20:56 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-1c-5773cb386b7d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 22.6D.04429.83BC3775; Wed, 29 Jun 2016 06:20:56 -0700 (MST) Received: from samsunx.samsung ([10.113.63.54]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9J0087XBQTVM50@mmp1.samsung.com>; Wed, 29 Jun 2016 22:20:56 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH 05/15] lirc_dev: simplify goto paths Date: Wed, 29 Jun 2016 22:20:34 +0900 Message-id: <1467206444-9935-6-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467206444-9935-1-git-send-email-andi.shyti@samsung.com> References: <1467206444-9935-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsWyRsSkUNfidHG4wYTFhhbbjzxjtVj84zmT xeVdc9gsejZsZbVY/azCgdXj+pJPzB5b+u+ye/RtWcXo8XmTXABLFJdNSmpOZllqkb5dAlfG 6a1HGQtWiVUcarjO1MDYJdjFyMkhIWAi0TX3DxuELSZx4d56MFtIYAWjxMtfwTA1N7Z/Ze5i 5AKKL2WU+P2ugxXC+cgoMenUd7AONgFNiabbP4BsDg4RAWOJcz/UQcLMAs2MEruvG4HYwkCD Ts75zAxiswioSlza2wJm8wq4SqxedYcVYpmcxOXpD8BGcgq4SSw/f5Md4iBXidan/xlB9koI NLNLLH86mx1ikIDEt8mHWED2SgjISmw6wAwxR1Li4IobLBMYhRcwMqxiFE0tSC4oTkovMtYr TswtLs1L10vOz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HC9/yG0/vN684W244oVYh5+iBnk2G35fGtl2o0JbVn37zolgRr+7ks5d15JP3 TGafsWixYfK52Sue1U+8Kix2QImlOCPRUIu5qDgRACa5Z3irAgAA 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 b11ab5c..400ab80 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -241,52 +241,44 @@ static int lirc_allocate_driver(struct lirc_driver *d) if (!d) { pr_err("lirc_dev: driver pointer must be not NULL!\n"); - err = -EBADRQC; - goto out; + return -EBADRQC; } if (!d->dev) { pr_err("%s: dev pointer not filled in!\n", __func__); - 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; } } @@ -364,7 +356,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; } @@ -793,9 +785,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("lirc_dev: class_create failed\n"); - goto error; + return PTR_ERR(lirc_class); } retval = alloc_chrdev_region(&lirc_base_dev, 0, MAX_IRCTL_DEVICES, @@ -803,15 +794,14 @@ static int __init lirc_dev_init(void) if (retval) { class_destroy(lirc_class); pr_err("lirc_dev: alloc_chrdev_region failed\n"); - goto error; + return retval; } pr_info("lirc_dev: IR Remote Control driver registered, major %d\n", MAJOR(lirc_base_dev)); -error: - return retval; + return 0; }