diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2022-02-13 22:48:53 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2022-05-17 15:52:59 +0300 |
commit | c0c45238fcf44b05c86f2f7d1dda136df7a83ff9 (patch) | |
tree | 5323385a61716a81096f8a151850e32775d64007 /drivers/hwmon/peci | |
parent | ab9ac6df22527b22fcceb6a16f5035ee778c9688 (diff) | |
download | linux-c0c45238fcf44b05c86f2f7d1dda136df7a83ff9.tar.xz |
hwmon: (peci) Use devm_delayed_work_autocancel() to simplify code
Use devm_delayed_work_autocancel() instead of hand writing it. This is
less verbose and saves a few lines of code.
devm_delayed_work_autocancel() uses devm_add_action() instead of
devm_add_action_or_reset(). This is fine, because if the underlying memory
allocation fails, no work has been scheduled yet. So there is nothing to
undo.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>
Link: https://lore.kernel.org/r/fd277a708ede3882d7df6831f02d2e3c0cb813b8.1644781718.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/peci')
-rw-r--r-- | drivers/hwmon/peci/dimmtemp.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/hwmon/peci/dimmtemp.c b/drivers/hwmon/peci/dimmtemp.c index c8222354c005..96b9919db357 100644 --- a/drivers/hwmon/peci/dimmtemp.c +++ b/drivers/hwmon/peci/dimmtemp.c @@ -4,6 +4,7 @@ #include <linux/auxiliary_bus.h> #include <linux/bitfield.h> #include <linux/bitops.h> +#include <linux/devm-helpers.h> #include <linux/hwmon.h> #include <linux/jiffies.h> #include <linux/module.h> @@ -378,13 +379,6 @@ static void create_dimm_temp_info_delayed(struct work_struct *work) dev_err(priv->dev, "Failed to populate DIMM temp info\n"); } -static void remove_delayed_work(void *_priv) -{ - struct peci_dimmtemp *priv = _priv; - - cancel_delayed_work_sync(&priv->detect_work); -} - static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id) { struct device *dev = &adev->dev; @@ -415,9 +409,8 @@ static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxil "Unexpected PECI revision %#x, some features may be unavailable\n", peci_dev->info.peci_revision); - INIT_DELAYED_WORK(&priv->detect_work, create_dimm_temp_info_delayed); - - ret = devm_add_action_or_reset(priv->dev, remove_delayed_work, priv); + ret = devm_delayed_work_autocancel(priv->dev, &priv->detect_work, + create_dimm_temp_info_delayed); if (ret) return ret; |