* Patch: applesmc.c - update handling
@ 2025-11-19 23:46 Jared Mauch
2025-11-19 23:54 ` Armin Wolf
2025-11-20 2:39 ` Guenter Roeck
0 siblings, 2 replies; 5+ messages in thread
From: Jared Mauch @ 2025-11-19 23:46 UTC (permalink / raw)
To: rydberg; +Cc: linux-hwmon
[-- Attachment #1: Type: text/plain, Size: 617 bytes --]
Updates code from hwmon_device_register to hwmon_device_register_with_info
Signed-off-by: Jared Mauch <jared@puck.nether.net>
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index fc6d6a9053ce..984dfbf40233 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1362,7 +1362,7 @@ static int __init applesmc_init(void)
if (ret)
goto out_light_sysfs;
- hwmon_dev = hwmon_device_register(&pdev->dev);
+ hwmon_dev = hwmon_device_register_with_info(&pdev->dev, "applesmc", NULL, NULL, NULL);
if (IS_ERR(hwmon_dev)) {
ret = PTR_ERR(hwmon_dev);
goto out_light_ledclass;
[-- Attachment #2: applesmc.c.patch --]
[-- Type: text/plain, Size: 487 bytes --]
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index fc6d6a9053ce..984dfbf40233 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1362,7 +1362,7 @@ static int __init applesmc_init(void)
if (ret)
goto out_light_sysfs;
- hwmon_dev = hwmon_device_register(&pdev->dev);
+ hwmon_dev = hwmon_device_register_with_info(&pdev->dev, "applesmc", NULL, NULL, NULL);
if (IS_ERR(hwmon_dev)) {
ret = PTR_ERR(hwmon_dev);
goto out_light_ledclass;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: Patch: applesmc.c - update handling
2025-11-19 23:46 Patch: applesmc.c - update handling Jared Mauch
@ 2025-11-19 23:54 ` Armin Wolf
2025-11-20 2:03 ` Jared Mauch
2025-11-20 2:39 ` Guenter Roeck
1 sibling, 1 reply; 5+ messages in thread
From: Armin Wolf @ 2025-11-19 23:54 UTC (permalink / raw)
To: Jared Mauch, rydberg; +Cc: linux-hwmon
Am 20.11.25 um 00:46 schrieb Jared Mauch:
> Updates code from hwmon_device_register to hwmon_device_register_with_info
>
> Signed-off-by: Jared Mauch <jared@puck.nether.net>
>
> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
> index fc6d6a9053ce..984dfbf40233 100644
> --- a/drivers/hwmon/applesmc.c
> +++ b/drivers/hwmon/applesmc.c
> @@ -1362,7 +1362,7 @@ static int __init applesmc_init(void)
> if (ret)
> goto out_light_sysfs;
>
> - hwmon_dev = hwmon_device_register(&pdev->dev);
> + hwmon_dev = hwmon_device_register_with_info(&pdev->dev, "applesmc", NULL, NULL, NULL);
That is not how you migrate a driver from hwmon_device_register() to hwmon_device_register_with_info().
You are expected to also move the sysfs-centric attribute handling to struct hwmon_chip_info.
Thanks,
Armin Wolf
> if (IS_ERR(hwmon_dev)) {
> ret = PTR_ERR(hwmon_dev);
> goto out_light_ledclass;
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Patch: applesmc.c - update handling
2025-11-19 23:54 ` Armin Wolf
@ 2025-11-20 2:03 ` Jared Mauch
2025-11-20 2:39 ` Armin Wolf
0 siblings, 1 reply; 5+ messages in thread
From: Jared Mauch @ 2025-11-20 2:03 UTC (permalink / raw)
To: Armin Wolf; +Cc: Jared Mauch, rydberg, linux-hwmon
[-- Attachment #1: Type: text/plain, Size: 277 bytes --]
oops, wrong attachment.
On Thu, Nov 20, 2025 at 12:54:24AM +0100, Armin Wolf wrote:
> Am 20.11.25 um 00:46 schrieb Jared Mauch:
>
> > Updates code from hwmon_device_register to hwmon_device_register_with_info
> >
> > Signed-off-by: Jared Mauch <jared@puck.nether.net>
> >
[-- Attachment #2: hwmon.diff --]
[-- Type: text/plain, Size: 2460 bytes --]
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index fc6d6a9053ce..10d1bfc6bf7b 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1123,7 +1123,7 @@ static void applesmc_destroy_nodes(struct applesmc_node_group *groups)
for (grp = groups; grp->nodes; grp++) {
for (node = grp->nodes; node->sda.dev_attr.attr.name; node++)
- sysfs_remove_file(&pdev->dev.kobj,
+ sysfs_remove_file(&hwmon_dev->kobj,
&node->sda.dev_attr.attr);
kfree(grp->nodes);
grp->nodes = NULL;
@@ -1157,7 +1157,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
sysfs_attr_init(attr);
attr->name = node->name;
attr->mode = 0444 | (grp->store ? 0200 : 0);
- ret = sysfs_create_file(&pdev->dev.kobj, attr);
+ ret = sysfs_create_file(&hwmon_dev->kobj, attr);
if (ret) {
attr->name = NULL;
goto out;
@@ -1338,9 +1338,16 @@ static int __init applesmc_init(void)
if (ret)
goto out_device;
+ /* Register hwmon device early so we can create sysfs files on it */
+ hwmon_dev = hwmon_device_register_with_info(&pdev->dev, "applesmc", NULL, NULL, NULL);
+ if (IS_ERR(hwmon_dev)) {
+ ret = PTR_ERR(hwmon_dev);
+ goto out_smcreg;
+ }
+
ret = applesmc_create_nodes(info_group, 1);
if (ret)
- goto out_smcreg;
+ goto out_hwmon;
ret = applesmc_create_nodes(fan_group, smcreg.fan_count);
if (ret)
@@ -1362,17 +1369,10 @@ static int __init applesmc_init(void)
if (ret)
goto out_light_sysfs;
- hwmon_dev = hwmon_device_register(&pdev->dev);
- if (IS_ERR(hwmon_dev)) {
- ret = PTR_ERR(hwmon_dev);
- goto out_light_ledclass;
- }
-
return 0;
-out_light_ledclass:
- applesmc_release_key_backlight();
out_light_sysfs:
+ applesmc_release_key_backlight();
applesmc_release_light_sensor();
out_accelerometer:
applesmc_release_accelerometer();
@@ -1382,6 +1382,9 @@ static int __init applesmc_init(void)
applesmc_destroy_nodes(fan_group);
out_info:
applesmc_destroy_nodes(info_group);
+out_hwmon:
+ if (!IS_ERR_OR_NULL(hwmon_dev))
+ hwmon_device_unregister(hwmon_dev);
out_smcreg:
applesmc_destroy_smcreg();
out_device:
@@ -1397,7 +1400,8 @@ static int __init applesmc_init(void)
static void __exit applesmc_exit(void)
{
- hwmon_device_unregister(hwmon_dev);
+ if (!IS_ERR_OR_NULL(hwmon_dev))
+ hwmon_device_unregister(hwmon_dev);
applesmc_release_key_backlight();
applesmc_release_light_sensor();
applesmc_release_accelerometer();
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: Patch: applesmc.c - update handling
2025-11-20 2:03 ` Jared Mauch
@ 2025-11-20 2:39 ` Armin Wolf
0 siblings, 0 replies; 5+ messages in thread
From: Armin Wolf @ 2025-11-20 2:39 UTC (permalink / raw)
To: Jared Mauch; +Cc: rydberg, linux-hwmon
Am 20.11.25 um 03:03 schrieb Jared Mauch:
> oops, wrong attachment.
- Please do not top post
- Please resend your patch if you make significant changes to it
- Please do not send patches as attachments (use git send-email for example)
- The attached patch still does not use struct hwmon_chip_info
Thanks,
Armin Wolf
> On Thu, Nov 20, 2025 at 12:54:24AM +0100, Armin Wolf wrote:
>> Am 20.11.25 um 00:46 schrieb Jared Mauch:
>>
>>> Updates code from hwmon_device_register to hwmon_device_register_with_info
>>>
>>> Signed-off-by: Jared Mauch <jared@puck.nether.net>
>>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Patch: applesmc.c - update handling
2025-11-19 23:46 Patch: applesmc.c - update handling Jared Mauch
2025-11-19 23:54 ` Armin Wolf
@ 2025-11-20 2:39 ` Guenter Roeck
1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2025-11-20 2:39 UTC (permalink / raw)
To: Jared Mauch, rydberg; +Cc: linux-hwmon
On 11/19/25 15:46, Jared Mauch wrote:
> Updates code from hwmon_device_register to hwmon_device_register_with_info
>
> Signed-off-by: Jared Mauch <jared@puck.nether.net>
>
NACK
> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
> index fc6d6a9053ce..984dfbf40233 100644
> --- a/drivers/hwmon/applesmc.c
> +++ b/drivers/hwmon/applesmc.c
> @@ -1362,7 +1362,7 @@ static int __init applesmc_init(void)
> if (ret)
> goto out_light_sysfs;
>
> - hwmon_dev = hwmon_device_register(&pdev->dev);
> + hwmon_dev = hwmon_device_register_with_info(&pdev->dev, "applesmc", NULL, NULL, NULL);
> if (IS_ERR(hwmon_dev)) {
> ret = PTR_ERR(hwmon_dev);
> goto out_light_ledclass;
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-20 2:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 23:46 Patch: applesmc.c - update handling Jared Mauch
2025-11-19 23:54 ` Armin Wolf
2025-11-20 2:03 ` Jared Mauch
2025-11-20 2:39 ` Armin Wolf
2025-11-20 2:39 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox