Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1437607
| From | Andi Shyti <andi.shyti@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 05/15] [media] lirc_dev: simplify goto paths |
| Date | 2016-07-06 11:50 +0200 |
| Message-ID | <rRRCX-7w1-45@gated-at.bofh.it> (permalink) |
| References | <rRRCW-7w1-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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 59f4c93..b11d026 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;
}
@@ -790,9 +782,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,
@@ -800,15 +791,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;
}
--
2.8.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 00/15] lirc_dev fixes and beautification Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 10/15] [media] lirc_dev: remove compat_ioctl assignment Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 11/15] [media] lirc_dev: fix variable constant comparisons Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 07/15] [media] lirc_dev: simplify if statement in lirc_add_to_buf Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 03/15] [media] lirc_dev: remove unnecessary debug prints Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 02/15] [media] lirc_dev: allow bufferless driver registration Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 15/15] [media] lirc_dev: use LIRC_CAN_REC() define to check if the device can receive Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 06/15] [media] lirc_dev: do not use goto to create loops Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 12/15] [media] lirc_dev: fix error return value Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 04/15] [media] lirc_dev: replace printk with pr_* or dev_* Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 01/15] [media] lirc_dev: place buffer allocation on separate function Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 05/15] [media] lirc_dev: simplify goto paths Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 08/15] [media] lirc_dev: remove double if ... else statement Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200 [PATCH v3 09/15] [media] lirc_dev: merge three if statements in only one Andi Shyti <andi.shyti@samsung.com> - 2016-07-06 11:50 +0200
csiph-web