mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
iio: adc: adi-axi-adc: simplify devm_adi_axi_adc_conv_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: Yicong Yang <yangyicong@hisilicon.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/1617881896-3164-2-git-send-email-yangyicong@hisilicon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
afa2b78f1e
commit
4e023c4dcf
1 changed files with 10 additions and 14 deletions
|
@ -202,29 +202,25 @@ static void adi_axi_adc_conv_unregister(struct adi_axi_adc_conv *conv)
|
||||||
kfree(cl);
|
kfree(cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void devm_adi_axi_adc_conv_release(struct device *dev, void *res)
|
static void devm_adi_axi_adc_conv_release(void *conv)
|
||||||
{
|
{
|
||||||
adi_axi_adc_conv_unregister(*(struct adi_axi_adc_conv **)res);
|
adi_axi_adc_conv_unregister(conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct adi_axi_adc_conv *devm_adi_axi_adc_conv_register(struct device *dev,
|
struct adi_axi_adc_conv *devm_adi_axi_adc_conv_register(struct device *dev,
|
||||||
size_t sizeof_priv)
|
size_t sizeof_priv)
|
||||||
{
|
{
|
||||||
struct adi_axi_adc_conv **ptr, *conv;
|
struct adi_axi_adc_conv *conv;
|
||||||
|
int ret;
|
||||||
ptr = devres_alloc(devm_adi_axi_adc_conv_release, sizeof(*ptr),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!ptr)
|
|
||||||
return ERR_PTR(-ENOMEM);
|
|
||||||
|
|
||||||
conv = adi_axi_adc_conv_register(dev, sizeof_priv);
|
conv = adi_axi_adc_conv_register(dev, sizeof_priv);
|
||||||
if (IS_ERR(conv)) {
|
if (IS_ERR(conv))
|
||||||
devres_free(ptr);
|
return conv;
|
||||||
return ERR_CAST(conv);
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptr = conv;
|
ret = devm_add_action_or_reset(dev, devm_adi_axi_adc_conv_release,
|
||||||
devres_add(dev, ptr);
|
conv);
|
||||||
|
if (ret)
|
||||||
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
return conv;
|
return conv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue