lkml.org 
[lkml]   [2023]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1] hwmon: drivetemp: support to be a platform driver for thermal_of
On 3/16/23 00:48, Phinex Hung wrote:
>
>
> On 3/16/23 15:35 "Phinex Hung" <phinex@realtek.com <mailto:phinex@realtek.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;
> +

That needs to be in the hwmon core. We can not change the device pointer
passed to hwmon_device_register_with_info() because that determines the
lifetime of the hwmon device.

Guenter

> + 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
>
>
>
>

\
 
 \ /
  Last update: 2023-03-27 01:04    [W:0.061 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site