All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@samsung.com>
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andi Shyti <andi.shyti@samsung.com>,
	Andi Shyti <andi@etezian.org>
Subject: [PATCH 05/15] lirc_dev: simplify goto paths
Date: Wed, 29 Jun 2016 22:20:34 +0900	[thread overview]
Message-ID: <1467206444-9935-6-git-send-email-andi.shyti@samsung.com> (raw)
In-Reply-To: <1467206444-9935-1-git-send-email-andi.shyti@samsung.com>

The code can be rearranged so that some goto paths can be removed

Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
 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;
 }
 
 
-- 
2.8.1

  parent reply	other threads:[~2016-06-29 13:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 13:20 [PATCH 00/15] lirc_dev fixes and beautification Andi Shyti
2016-06-29 13:20 ` [PATCH 01/15] lirc_dev: place buffer allocation on separate function Andi Shyti
2016-06-29 13:20 ` [PATCH 02/15] lirc_dev: allow bufferless driver registration Andi Shyti
2016-06-29 13:20 ` [PATCH 03/15] lirc_dev: remove unnecessary debug prints Andi Shyti
2016-06-29 13:20 ` [PATCH 04/15] lirc_dev: replace printk with pr_* or dev_* Andi Shyti
2016-06-30  0:27   ` Joe Perches
2016-06-29 13:20 ` Andi Shyti [this message]
2016-06-29 13:20 ` [PATCH 06/15] lirc_dev: do not use goto to create loops Andi Shyti
2016-06-29 13:20 ` [PATCH 07/15] lirc_dev: simplify if statement in lirc_add_to_buf Andi Shyti
2016-06-29 13:20 ` [PATCH 08/15] lirc_dev: remove double if ... else statement Andi Shyti
2016-06-29 13:20 ` [PATCH 09/15] lirc_dev: merge three if statements in only one Andi Shyti
2016-06-29 13:20 ` [PATCH 10/15] lirc_dev: remove CONFIG_COMPAT precompiler check Andi Shyti
2016-06-29 13:20 ` [PATCH 11/15] lirc_dev: fix variable constant comparisons Andi Shyti
2016-06-29 13:20 ` [PATCH 12/15] lirc_dev: fix error return value Andi Shyti
2016-06-29 13:20 ` [PATCH 13/15] lirc_dev: extremely trivial comment style fix Andi Shyti
2016-06-29 13:20 ` [PATCH 14/15] lirc_dev: fix potential segfault Andi Shyti
2016-06-29 13:20 ` [PATCH 15/15] include: lirc: add set length and frequency ioctl options Andi Shyti
2016-06-29 22:46   ` Sean Young
2016-06-29 23:35     ` Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467206444-9935-6-git-send-email-andi.shyti@samsung.com \
    --to=andi.shyti@samsung.com \
    --cc=andi@etezian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.