diff mbox series

[3/5] hwmon: (corsair-psu) Use devres function

Message ID 20211222020114.3524736-3-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 corsairpsu_data struct as it is not needed anymore.

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

Patch

diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c
index 14389fd7afb8..1a40cde246aa 100644
--- a/drivers/hwmon/corsair-psu.c
+++ b/drivers/hwmon/corsair-psu.c
@@ -115,7 +115,6 @@  static const char *const label_amps[] = {
 
 struct corsairpsu_data {
 	struct hid_device *hdev;
-	struct device *hwmon_dev;
 	struct dentry *debugfs;
 	struct completion wait_completion;
 	struct mutex lock; /* for locking access to cmd_buffer */
@@ -684,6 +683,7 @@  static void corsairpsu_debugfs_init(struct corsairpsu_data *priv)
 static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
 	struct corsairpsu_data *priv;
+	struct device *hwmon_dev;
 	int ret;
 
 	priv = devm_kzalloc(&hdev->dev, sizeof(struct corsairpsu_data), GFP_KERNEL);
@@ -728,13 +728,13 @@  static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id
 	corsairpsu_get_criticals(priv);
 	corsairpsu_check_cmd_support(priv);
 
-	priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsairpsu", priv,
-							  &corsairpsu_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, "corsairpsu",
+						     priv, &corsairpsu_chip_info,
+						     NULL);
+	ret = PTR_ERR_OR_ZERO(hwmon_dev);
+	if (ret)
 		goto fail_and_close;
-	}
 
 	corsairpsu_debugfs_init(priv);
 
@@ -752,7 +752,6 @@  static void corsairpsu_remove(struct hid_device *hdev)
 	struct corsairpsu_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);
 }