lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8c835412-f78f-570d-30a5-24f4c02a8438@roeck-us.net>
Date:   Thu, 16 Mar 2023 06:22:41 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Phinex Hung <phinex@...ltek.com>,
        "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 00:48, Phinex Hung wrote:
> 
> 
> 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;
> +

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ