Commit 171a70af authored by Yicong Yang's avatar Yicong Yang Committed by Jonathan Cameron

iio: trigger: simplify __devm_iio_trigger_register

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-7-git-send-email-yangyicong@hisilicon.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent cf5724e9
...@@ -634,9 +634,9 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, const char *fm ...@@ -634,9 +634,9 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, const char *fm
} }
EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc); EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc);
static void devm_iio_trigger_unreg(struct device *dev, void *res) static void devm_iio_trigger_unreg(void *trigger_info)
{ {
iio_trigger_unregister(*(struct iio_trigger **)res); iio_trigger_unregister(trigger_info);
} }
/** /**
...@@ -657,21 +657,13 @@ int __devm_iio_trigger_register(struct device *dev, ...@@ -657,21 +657,13 @@ int __devm_iio_trigger_register(struct device *dev,
struct iio_trigger *trig_info, struct iio_trigger *trig_info,
struct module *this_mod) struct module *this_mod)
{ {
struct iio_trigger **ptr;
int ret; int ret;
ptr = devres_alloc(devm_iio_trigger_unreg, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return -ENOMEM;
*ptr = trig_info;
ret = __iio_trigger_register(trig_info, this_mod); ret = __iio_trigger_register(trig_info, this_mod);
if (!ret) if (ret)
devres_add(dev, ptr);
else
devres_free(ptr);
return ret; return ret;
return devm_add_action_or_reset(dev, devm_iio_trigger_unreg, trig_info);
} }
EXPORT_SYMBOL_GPL(__devm_iio_trigger_register); EXPORT_SYMBOL_GPL(__devm_iio_trigger_register);
......
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