staging: fieldbus: simplify devm_anybuss_host_common_probe
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: Tian Tao <tiantao6@hisilicon.com> Link: https://lore.kernel.org/r/1618275183-56792-1-git-send-email-tiantao6@hisilicon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
cc444aa522
Коммит
07ff20cf17
|
@ -1406,32 +1406,26 @@ void anybuss_host_common_remove(struct anybuss_host *host)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(anybuss_host_common_remove);
|
EXPORT_SYMBOL_GPL(anybuss_host_common_remove);
|
||||||
|
|
||||||
static void host_release(struct device *dev, void *res)
|
static void host_release(void *res)
|
||||||
{
|
{
|
||||||
struct anybuss_host **dr = res;
|
anybuss_host_common_remove(res);
|
||||||
|
|
||||||
anybuss_host_common_remove(*dr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct anybuss_host * __must_check
|
struct anybuss_host * __must_check
|
||||||
devm_anybuss_host_common_probe(struct device *dev,
|
devm_anybuss_host_common_probe(struct device *dev,
|
||||||
const struct anybuss_ops *ops)
|
const struct anybuss_ops *ops)
|
||||||
{
|
{
|
||||||
struct anybuss_host **dr;
|
|
||||||
struct anybuss_host *host;
|
struct anybuss_host *host;
|
||||||
|
int ret;
|
||||||
dr = devres_alloc(host_release, sizeof(struct anybuss_host *),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!dr)
|
|
||||||
return ERR_PTR(-ENOMEM);
|
|
||||||
|
|
||||||
host = anybuss_host_common_probe(dev, ops);
|
host = anybuss_host_common_probe(dev, ops);
|
||||||
if (IS_ERR(host)) {
|
if (IS_ERR(host))
|
||||||
devres_free(dr);
|
|
||||||
return host;
|
return host;
|
||||||
}
|
|
||||||
*dr = host;
|
ret = devm_add_action_or_reset(dev, host_release, host);
|
||||||
devres_add(dev, dr);
|
if (ret)
|
||||||
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(devm_anybuss_host_common_probe);
|
EXPORT_SYMBOL_GPL(devm_anybuss_host_common_probe);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче