From: Jackie Liu <liu.yun@linux.dev>
To: linux@roeck-us.net
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org, liu.yun@linux.dev
Subject: [PATCH 5/5] hwmon: (drivetemp) Use devres function
Date: Wed, 22 Dec 2021 10:01:14 +0800 [thread overview]
Message-ID: <20211222020114.3524736-5-liu.yun@linux.dev> (raw)
In-Reply-To: <20211222020114.3524736-1-liu.yun@linux.dev>
From: Jackie Liu <liuyun01@kylinos.cn>
Use devm_hwmon_device_register_with_info() and remove hwmon_dev
from drivetemp_data struct as it is not needed anymore.
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
drivers/hwmon/drivetemp.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c
index 1eb37106a220..1a5a62288c0a 100644
--- a/drivers/hwmon/drivetemp.c
+++ b/drivers/hwmon/drivetemp.c
@@ -113,7 +113,6 @@ struct drivetemp_data {
struct mutex lock; /* protect data buffer accesses */
struct scsi_device *sdev; /* SCSI device */
struct device *dev; /* instantiating device */
- struct device *hwdev; /* hardware monitoring device */
u8 smartdata[ATA_SECT_SIZE]; /* local buffer */
int (*get_temp)(struct drivetemp_data *st, u32 attr, long *val);
bool have_temp_lowest; /* lowest temp in SCT status */
@@ -555,6 +554,7 @@ static int drivetemp_add(struct device *dev, struct class_interface *intf)
{
struct scsi_device *sdev = to_scsi_device(dev->parent);
struct drivetemp_data *st;
+ struct device *hwmon_dev;
int err;
st = kzalloc(sizeof(*st), GFP_KERNEL);
@@ -570,13 +570,13 @@ static int drivetemp_add(struct device *dev, struct class_interface *intf)
goto abort;
}
- st->hwdev = hwmon_device_register_with_info(dev->parent, "drivetemp",
- st, &drivetemp_chip_info,
- NULL);
- if (IS_ERR(st->hwdev)) {
- err = PTR_ERR(st->hwdev);
+ hwmon_dev =
+ devm_hwmon_device_register_with_info(dev->parent, "drivetemp",
+ st, &drivetemp_chip_info,
+ NULL);
+ err = PTR_ERR_OR_ZERO(hwmon_dev);
+ if (err)
goto abort;
- }
list_add(&st->list, &drivetemp_devlist);
return 0;
@@ -593,7 +593,6 @@ static void drivetemp_remove(struct device *dev, struct class_interface *intf)
list_for_each_entry_safe(st, tmp, &drivetemp_devlist, list) {
if (st->dev == dev) {
list_del(&st->list);
- hwmon_device_unregister(st->hwdev);
kfree(st);
break;
}
--
2.25.1
next prev parent reply other threads:[~2021-12-22 2:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 2:01 [PATCH 1/5] hwmon: (corsair-cpro) Use devres function Jackie Liu
2021-12-22 2:01 ` [PATCH 2/5] hwmon: (nzxt-kraken2) " Jackie Liu
2021-12-22 2:01 ` [PATCH 3/5] hwmon: (corsair-psu) " Jackie Liu
2021-12-22 2:01 ` [PATCH 4/5] hwmon: (d5next) " Jackie Liu
2021-12-22 2:01 ` Jackie Liu [this message]
2021-12-22 3:03 ` [PATCH 5/5] hwmon: (drivetemp) " Guenter Roeck
2021-12-22 5:43 ` Jackie Liu
2021-12-22 2:58 ` [PATCH 1/5] hwmon: (corsair-cpro) " Guenter Roeck
2021-12-22 6:13 ` Jackie Liu
2021-12-22 16:10 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211222020114.3524736-5-liu.yun@linux.dev \
--to=liu.yun@linux.dev \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.