mirror of https://gitee.com/openkylin/linux.git
iio:trigger: Introduce the use of devm_kzalloc
This patch introduces the use of the managed version of kzalloc and removes the kfrees in the probe and remove functions. More return paths are added and the labels are renamed to order them. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
744966d6dc
commit
f64c3052b6
|
@ -182,45 +182,40 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
|
||||||
unsigned int config;
|
unsigned int config;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
st = kzalloc(sizeof(*st), GFP_KERNEL);
|
st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
|
||||||
if (st == NULL) {
|
if (st == NULL)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
st->irq = platform_get_irq(pdev, 0);
|
st->irq = platform_get_irq(pdev, 0);
|
||||||
if (!st->irq) {
|
if (!st->irq) {
|
||||||
dev_err(&pdev->dev, "No IRQs specified");
|
dev_err(&pdev->dev, "No IRQs specified");
|
||||||
ret = -ENODEV;
|
return -ENODEV;
|
||||||
goto out1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = iio_bfin_tmr_get_number(st->irq);
|
ret = iio_bfin_tmr_get_number(st->irq);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out1;
|
return ret;
|
||||||
|
|
||||||
st->timer_num = ret;
|
st->timer_num = ret;
|
||||||
st->t = &iio_bfin_timer_code[st->timer_num];
|
st->t = &iio_bfin_timer_code[st->timer_num];
|
||||||
|
|
||||||
st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
|
st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
|
||||||
if (!st->trig) {
|
if (!st->trig)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out1;
|
|
||||||
}
|
|
||||||
|
|
||||||
st->trig->ops = &iio_bfin_tmr_trigger_ops;
|
st->trig->ops = &iio_bfin_tmr_trigger_ops;
|
||||||
st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
|
st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
|
||||||
iio_trigger_set_drvdata(st->trig, st);
|
iio_trigger_set_drvdata(st->trig, st);
|
||||||
ret = iio_trigger_register(st->trig);
|
ret = iio_trigger_register(st->trig);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out2;
|
goto out;
|
||||||
|
|
||||||
ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
|
ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
|
||||||
0, st->trig->name, st);
|
0, st->trig->name, st);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"request IRQ-%d failed", st->irq);
|
"request IRQ-%d failed", st->irq);
|
||||||
goto out4;
|
goto out1;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = PWM_OUT | PERIOD_CNT | IRQ_ENA;
|
config = PWM_OUT | PERIOD_CNT | IRQ_ENA;
|
||||||
|
@ -260,13 +255,10 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
out_free_irq:
|
out_free_irq:
|
||||||
free_irq(st->irq, st);
|
free_irq(st->irq, st);
|
||||||
out4:
|
|
||||||
iio_trigger_unregister(st->trig);
|
|
||||||
out2:
|
|
||||||
iio_trigger_put(st->trig);
|
|
||||||
out1:
|
out1:
|
||||||
kfree(st);
|
iio_trigger_unregister(st->trig);
|
||||||
out:
|
out:
|
||||||
|
iio_trigger_put(st->trig);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +272,6 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
|
||||||
free_irq(st->irq, st);
|
free_irq(st->irq, st);
|
||||||
iio_trigger_unregister(st->trig);
|
iio_trigger_unregister(st->trig);
|
||||||
iio_trigger_put(st->trig);
|
iio_trigger_put(st->trig);
|
||||||
kfree(st);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue