diff options
author | Tian Tao <tiantao6@hisilicon.com> | 2021-04-13 08:53:03 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-04-13 09:53:41 +0200 |
commit | 07ff20cf172f31f0dfbc456662f20339767c69fd (patch) | |
tree | 321f8e8818c3974e18e673a3635b2c155f0201aa /drivers | |
parent | cc444aa522b18069eba204c9b5e3cf5a69de29a5 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/fieldbus/anybuss/host.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c index 549cb7d51af8..c97df91124a4 100644 --- a/drivers/staging/fieldbus/anybuss/host.c +++ b/drivers/staging/fieldbus/anybuss/host.c @@ -1406,32 +1406,26 @@ void anybuss_host_common_remove(struct anybuss_host *host) } 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(*dr); + anybuss_host_common_remove(res); } struct anybuss_host * __must_check devm_anybuss_host_common_probe(struct device *dev, const struct anybuss_ops *ops) { - struct anybuss_host **dr; struct anybuss_host *host; - - dr = devres_alloc(host_release, sizeof(struct anybuss_host *), - GFP_KERNEL); - if (!dr) - return ERR_PTR(-ENOMEM); + int ret; host = anybuss_host_common_probe(dev, ops); - if (IS_ERR(host)) { - devres_free(dr); + if (IS_ERR(host)) return host; - } - *dr = host; - devres_add(dev, dr); + + ret = devm_add_action_or_reset(dev, host_release, host); + if (ret) + return ERR_PTR(ret); + return host; } EXPORT_SYMBOL_GPL(devm_anybuss_host_common_probe); |