Re: [PATCH 1/1] hwmon: (applesmc) Convert to hwmon_device_register_with_info
From: Shih-Yuan Lee (FourDollars)
Date: Fri Jul 10 2026 - 22:53:23 EST
Hi Guenter, Armin,
Thank you for the detailed feedback and suggestions.
I do have access to a real Intel-based MacBook8,1 for hardware testing. I agree
that converting the driver properly and renaming the non-standard attributes
(fanX_output -> fanX_target, fanX_manual -> pwmX_enable) to match the HWMON ABI
is the right way forward.
I will start working on a full refactoring of the fan and temperature attributes
using dynamic hwmon_channel_info allocation, and test the resulting module
on the hardware.
I will send a v2 patch series once the implementation is complete and tested.
Best regards,
Shih-Yuan Lee
On Sat, Jul 11, 2026 at 6:28 AM Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
>
> On 7/10/26 14:10, Armin Wolf wrote:
> > Am 10.07.26 um 16:01 schrieb Guenter Roeck:
> >
> >> On 7/10/26 05:32, Shih-Yuan Lee wrote:
> >>> The legacy hwmon_device_register() function is deprecated and triggers a
> >>> warning in dmesg during driver initialization:
> >>>
> >>> [ 24.706091] applesmc: key=620 fan=0 temp=37 index=36 acc=0 lux=2 kbd=0
> >>> [ 24.706270] applesmc applesmc.768: hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info().
> >>>
> >>> To silence this warning, convert the driver to use the modern
> >>> hwmon_device_register_with_info() API.
> >>>
> >>> Because the driver creates all its sysfs attributes dynamically on the platform
> >>> device, we define a minimal struct hwmon_chip_info with a single temperature
> >>> channel and implement a visibility callback that returns 0 (hidden) for it.
> >>> This satisfies the new API requirements while keeping all existing sysfs paths
> >>> and attributes completely unchanged, ensuring backwards compatibility.
> >>>
> >>
> >> Novel, but that would completely defeat the purpose of the new API.
> >> NACK.
> >>
> >> Guenter
> >
> > Agree, this deprecation warning should not be silenced by using cheap tricks.
> >
> > Lee, i think instead of abusing the hwmon_device_register_with_info() to emulate the
> > behavior of the old API, i suggest that you use the new API to replace these two calls
> > to applesmc_create_nodes():
> >
> > ret = applesmc_create_nodes(fan_group, smcreg.fan_count);
> > if (ret)
> > goto out_info;
> >
> > ret = applesmc_create_nodes(temp_group, smcreg.index_count);
> > if (ret)
> > oto out_fans;
> >
> > Basically, you need to dynamically allocate a struct hwmon_channel_info each for the fan
> > and temperature sensors. Then you basically use the new API to create the standard attributes
> > for you, while the non-standard attributes are still created manually and passed using the
> > extra_groups parameter.
> >
> > The non-standard attributes are:
> > - fanX_safe
> > - fanX_output (should be renamed to fanX_target to comply with the standard sysfs ABI)
> > - fanX_manual (should be renamed to pwmX_enable to comply with the standard sysfs ABI)
> >
> > This changes are not exactly trivial and should be tested on real hardware. You should
> > only attempt this if you have access to a compatible device for testing.
> >
>
> Exactly. Other drivers, such as the asus-ec-sensors driver, use the same approach.
>
> Thanks,
> Guenter
>