[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A6DF8FB3-6318-40CD-A364-603A3E581511@realtek.com>
Date: Thu, 16 Mar 2023 07:48:08 +0000
From: Phinex Hung <phinex@...ltek.com>
To: Guenter Roeck <linux@...ck-us.net>,
"jdelvare@...e.com" <jdelvare@...e.com>
CC: "linux-hwmon@...r.kernel.org" <linux-hwmon@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1] hwmon: drivetemp: support to be a platform driver for thermal_of
On 3/16/23 15:35 "Phinex Hung" <phinex@...ltek.com <mailto:phinex@...ltek.com> wrote:
>Not sure whether this is the difference, but use the following patch can solve this issue.
>@@ -540,9 +531,9 @@ 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);
>+ st->hwdev = hwmon_device_register_with_info(
>+ dev->parent->parent->parent->parent->parent, "drivetemp", st,
>+ &drivetemp_chip_info, NULL);
A more generic patch works in my case, listed below:
diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c
index 1cf4f9015316..a4cddfea8d22 100644
--- a/drivers/hwmon/drivetemp.c
+++ b/drivers/hwmon/drivetemp.c
@@ -525,6 +525,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 *tdev = dev->parent;
int err;
st = kzalloc(sizeof(*st), GFP_KERNEL);
@@ -540,8 +541,11 @@ 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,
+ while(!tdev->of_node)
+ tdev = tdev->parent;
+
+ st->hwdev = hwmon_device_register_with_info(tdev, "drivetemp", st,
+ &drivetemp_chip_info,
NULL);
if (IS_ERR(st->hwdev)) {
err = PTR_ERR(st->hwdev);
Thanks
Regards,
Phinex
Powered by blists - more mailing lists