diff mbox series

[4/5] hwmon: (d5next) Use devres function

Message ID 20211222020114.3524736-4-liu.yun@linux.dev (mailing list archive)
State Rejected
Headers show
Series [1/5] hwmon: (corsair-cpro) Use devres function | expand

Commit Message

Jackie Liu Dec. 22, 2021, 2:01 a.m. UTC
From: Jackie Liu <liuyun01@kylinos.cn>

Use devm_hwmon_device_register_with_info() and remove hwmon_dev
from d5next_data struct as it is not needed anymore.

Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 drivers/hwmon/aquacomputer_d5next.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
index fb9341a53051..4f6f11169a53 100644
--- a/drivers/hwmon/aquacomputer_d5next.c
+++ b/drivers/hwmon/aquacomputer_d5next.c
@@ -84,7 +84,6 @@  static const char *const label_current[] = {
 
 struct d5next_data {
 	struct hid_device *hdev;
-	struct device *hwmon_dev;
 	struct dentry *debugfs;
 	s32 temp_input;
 	u16 speed_input[2];
@@ -275,6 +274,7 @@  static void d5next_debugfs_init(struct d5next_data *priv)
 static int d5next_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
 	struct d5next_data *priv;
+	struct device *hwmon_dev;
 	int ret;
 
 	priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -298,13 +298,12 @@  static int d5next_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (ret)
 		goto fail_and_stop;
 
-	priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "d5next", priv,
-							  &d5next_chip_info, NULL);
-
-	if (IS_ERR(priv->hwmon_dev)) {
-		ret = PTR_ERR(priv->hwmon_dev);
+	hwmon_dev =
+		devm_hwmon_device_register_with_info(&hdev->dev, "d5next", priv,
+						     &d5next_chip_info, NULL);
+	ret = PTR_ERR_OR_ZERO(hwmon_dev);
+	if (ret)
 		goto fail_and_close;
-	}
 
 	d5next_debugfs_init(priv);
 
@@ -322,7 +321,6 @@  static void d5next_remove(struct hid_device *hdev)
 	struct d5next_data *priv = hid_get_drvdata(hdev);
 
 	debugfs_remove_recursive(priv->debugfs);
-	hwmon_device_unregister(priv->hwmon_dev);
 
 	hid_hw_close(hdev);
 	hid_hw_stop(hdev);