mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-22 00:40:03 +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);
|
||||
}
|
||||
|
||||
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,
|
||||
size_t sizeof_priv)
|
||||
{
|
||||
struct adi_axi_adc_conv **ptr, *conv;
|
||||
|
||||
ptr = devres_alloc(devm_adi_axi_adc_conv_release, sizeof(*ptr),
|
||||
GFP_KERNEL);
|
||||
if (!ptr)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
struct adi_axi_adc_conv *conv;
|
||||
int ret;
|
||||
|
||||
conv = adi_axi_adc_conv_register(dev, sizeof_priv);
|
||||
if (IS_ERR(conv)) {
|
||||
devres_free(ptr);
|
||||
return ERR_CAST(conv);
|
||||
}
|
||||
if (IS_ERR(conv))
|
||||
return conv;
|
||||
|
||||
*ptr = conv;
|
||||
devres_add(dev, ptr);
|
||||
ret = devm_add_action_or_reset(dev, devm_adi_axi_adc_conv_release,
|
||||
conv);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
return conv;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue