Commit 8e39d472 authored by Yicong Yang's avatar Yicong Yang Committed by Jonathan Cameron

iio: triggered-buffer: simplify devm_iio_triggered_buffer_setup_ext()

Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.
Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
Reviewed-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Reviewed-by: default avatarNuno Sa <nuno.sa@analog.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-5-git-send-email-yangyicong@hisilicon.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent bfc1807a
...@@ -96,9 +96,9 @@ void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev) ...@@ -96,9 +96,9 @@ void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev)
} }
EXPORT_SYMBOL(iio_triggered_buffer_cleanup); EXPORT_SYMBOL(iio_triggered_buffer_cleanup);
static void devm_iio_triggered_buffer_clean(struct device *dev, void *res) static void devm_iio_triggered_buffer_clean(void *indio_dev)
{ {
iio_triggered_buffer_cleanup(*(struct iio_dev **)res); iio_triggered_buffer_cleanup(indio_dev);
} }
int devm_iio_triggered_buffer_setup_ext(struct device *dev, int devm_iio_triggered_buffer_setup_ext(struct device *dev,
...@@ -108,24 +108,15 @@ int devm_iio_triggered_buffer_setup_ext(struct device *dev, ...@@ -108,24 +108,15 @@ int devm_iio_triggered_buffer_setup_ext(struct device *dev,
const struct iio_buffer_setup_ops *ops, const struct iio_buffer_setup_ops *ops,
const struct attribute **buffer_attrs) const struct attribute **buffer_attrs)
{ {
struct iio_dev **ptr;
int ret; int ret;
ptr = devres_alloc(devm_iio_triggered_buffer_clean, sizeof(*ptr),
GFP_KERNEL);
if (!ptr)
return -ENOMEM;
*ptr = indio_dev;
ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, ops, ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, ops,
buffer_attrs); buffer_attrs);
if (!ret) if (ret)
devres_add(dev, ptr); return ret;
else
devres_free(ptr);
return ret; return devm_add_action_or_reset(dev, devm_iio_triggered_buffer_clean,
indio_dev);
} }
EXPORT_SYMBOL_GPL(devm_iio_triggered_buffer_setup_ext); EXPORT_SYMBOL_GPL(devm_iio_triggered_buffer_setup_ext);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment