提交 2c99f1a0 编写于 作者: D Dan Carpenter 提交者: Jonathan Cameron

iio: trigger: clean up viio_trigger_alloc()

1) Reverse the test for kmalloc() failure so we can pull everything
   back one tab.
2) Use gotos for unwinding.
3) Some of the extra line breaks for the 80 character limit are no
   longer needed so we can remove them.
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 99a22f06
...@@ -518,46 +518,45 @@ static void iio_trig_subirqunmask(struct irq_data *d) ...@@ -518,46 +518,45 @@ static void iio_trig_subirqunmask(struct irq_data *d)
static struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs) static struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs)
{ {
struct iio_trigger *trig; struct iio_trigger *trig;
int i;
trig = kzalloc(sizeof *trig, GFP_KERNEL); trig = kzalloc(sizeof *trig, GFP_KERNEL);
if (trig) { if (!trig)
int i; return NULL;
trig->dev.type = &iio_trig_type;
trig->dev.bus = &iio_bus_type;
device_initialize(&trig->dev);
mutex_init(&trig->pool_lock);
trig->subirq_base
= irq_alloc_descs(-1, 0,
CONFIG_IIO_CONSUMERS_PER_TRIGGER,
0);
if (trig->subirq_base < 0) {
kfree(trig);
return NULL;
}
trig->name = kvasprintf(GFP_KERNEL, fmt, vargs); trig->dev.type = &iio_trig_type;
if (trig->name == NULL) { trig->dev.bus = &iio_bus_type;
irq_free_descs(trig->subirq_base, device_initialize(&trig->dev);
CONFIG_IIO_CONSUMERS_PER_TRIGGER);
kfree(trig); mutex_init(&trig->pool_lock);
return NULL; trig->subirq_base = irq_alloc_descs(-1, 0,
} CONFIG_IIO_CONSUMERS_PER_TRIGGER,
trig->subirq_chip.name = trig->name; 0);
trig->subirq_chip.irq_mask = &iio_trig_subirqmask; if (trig->subirq_base < 0)
trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask; goto free_trig;
for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
irq_set_chip(trig->subirq_base + i, trig->name = kvasprintf(GFP_KERNEL, fmt, vargs);
&trig->subirq_chip); if (trig->name == NULL)
irq_set_handler(trig->subirq_base + i, goto free_descs;
&handle_simple_irq);
irq_modify_status(trig->subirq_base + i, trig->subirq_chip.name = trig->name;
IRQ_NOREQUEST | IRQ_NOAUTOEN, trig->subirq_chip.irq_mask = &iio_trig_subirqmask;
IRQ_NOPROBE); trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask;
} for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
get_device(&trig->dev); irq_set_chip(trig->subirq_base + i, &trig->subirq_chip);
irq_set_handler(trig->subirq_base + i, &handle_simple_irq);
irq_modify_status(trig->subirq_base + i,
IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE);
} }
get_device(&trig->dev);
return trig; return trig;
free_descs:
irq_free_descs(trig->subirq_base, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
free_trig:
kfree(trig);
return NULL;
} }
struct iio_trigger *iio_trigger_alloc(const char *fmt, ...) struct iio_trigger *iio_trigger_alloc(const char *fmt, ...)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册