platform/x86: wmi: Initialize ACPI device class
PATCH 1/1 platform/x86: wmi: Initialize ACPI device class
When an ACPI netlink event is received by acpid, the ACPI device class is passed as its first argument. But since the class string is not initialized, an empty string is being passed:
netlink: PNP0C14:01 000000d0 00000000
Fix this by initializing the ACPI device class during probe.
---
Note: This patch is based on commit 3f399b5d7189 ("platform/x86: wmi: Use ACPI device name in netlink event")
--- drivers/platform/x86/wmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/wmi.c +5 -1
@@ -32,6 +32,8 @@#include <linux/wmi.h> #include <linux/fs.h> +#define ACPI_WMI_DEVICE_CLASS "wmi" +MODULE_AUTHOR ("Carlos Corbacho" );MODULE_DESCRIPTION ("ACPI-WMI Mapping Driver" );MODULE_LICENSE ("GPL" );
@@ -1202,7 +1204,7 @@ static int wmi_notify_device(struct device *dev, void *data) wblock->handler (*event, wblock->handler_data); } -acpi_bus_generate_netlink_event (wblock->acpi_device->pnp.device_class, +acpi_bus_generate_netlink_event (acpi_device_class (wblock->acpi_device),acpi_dev_name (wblock->acpi_device), *event,0 );return -EBUSY ;
@@ -1267,6 +1269,8 @@ static int acpi_wmi_probe(struct platform_device *device)return -ENODEV ; } +strscpy (acpi_device_class (acpi_device),ACPI_WMI_DEVICE_CLASS ,sizeof (acpi_device_class)); + wmi_bus_dev =device_create (&wmi_bus_class, &device->dev,MKDEV (0 ,0 ),NULL ,"wmi_bus-%s" ,dev_name (&device->dev));if (IS_ERR (wmi_bus_dev))
--
2.39.2
Hi,
Quoted 38 lines · Armin Wolf
When an ACPI netlink event is received by acpid, the ACPI device class is passed as its first argument. But since the class string is not initialized, an empty string is being passed:
netlink: PNP0C14:01 000000d0 00000000Fix this by initializing the ACPI device class during probe.
Signed-off-by Armin Wolf <[email protected]>---
Note: This patch is based on commit3f399b5d7189("platform/x86: wmi: Use ACPI device name in netlink event")--- drivers/platform/x86/wmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/platform/x86/wmi.c +3
-1@@ -32,6 +32,8 @@#include <linux/wmi.h> #include <linux/fs.h> +#define ACPI_WMI_DEVICE_CLASS "wmi" +MODULE_AUTHOR ("Carlos Corbacho" );MODULE_DESCRIPTION ("ACPI-WMI Mapping Driver" );MODULE_LICENSE ("GPL" );@@ -1202,7 +1204,7 @@ static int wmi_notify_device(struct device *dev, void *data) wblock->handler (*event, wblock->handler_data); } -acpi_bus_generate_netlink_event (wblock->acpi_device->pnp.device_class, +acpi_bus_generate_netlink_event (acpi_device_class (wblock->acpi_device),acpi_dev_name (wblock->acpi_device), *event,0 );return -EBUSY ;
drivers/platform/x86/wmi.c static int acpi_wmi_probe(struct platform_device *device) · line 1273
Quoted 5 lines
drivers/platform/x86/wmi.c +2
-0@@ -1267,6 +1269,8 @@ static int acpi_wmi_probe(struct platform_device *device)return -ENODEV ; } +strscpy (acpi_device_class (acpi_device),ACPI_WMI_DEVICE_CLASS ,sizeof (acpi_device_class)); +
Hmm, I'm not sure if you are supposed to do this when you are not an acpi_driver's add() function.
Rafael, do you have any comments on this ?
Regards,
Hans
Quoted 6 lines
drivers/platform/x86/wmi.c +0
-1wmi_bus_dev =device_create (&wmi_bus_class, &device->dev,MKDEV (0 ,0 ),NULL ,"wmi_bus-%s" ,dev_name (&device->dev));if (IS_ERR (wmi_bus_dev)) --2.39.2
Quoted 45 lines · Hans de Goede
Hi,
Quoted 41 lines · Armin Wolf
When an ACPI netlink event is received by acpid, the ACPI device class is passed as its first argument. But since the class string is not initialized, an empty string is being passed:
netlink: PNP0C14:01 000000d0 00000000Fix this by initializing the ACPI device class during probe.
Signed-off-by Armin Wolf <[email protected]>---
Note: This patch is based on commit3f399b5d7189("platform/x86: wmi: Use ACPI device name in netlink event")--- drivers/platform/x86/wmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/platform/x86/wmi.c +3
-1@@ -32,6 +32,8 @@#include <linux/wmi.h> #include <linux/fs.h> +#define ACPI_WMI_DEVICE_CLASS "wmi" +MODULE_AUTHOR ("Carlos Corbacho" );MODULE_DESCRIPTION ("ACPI-WMI Mapping Driver" );MODULE_LICENSE ("GPL" );@@ -1202,7 +1204,7 @@ static int wmi_notify_device(struct device *dev, void *data) wblock->handler (*event, wblock->handler_data); } -acpi_bus_generate_netlink_event (wblock->acpi_device->pnp.device_class, +acpi_bus_generate_netlink_event (acpi_device_class (wblock->acpi_device),acpi_dev_name (wblock->acpi_device), *event,0 );return -EBUSY ;@@ -1267,6 +1269,8 @@ static int acpi_wmi_probe(struct platform_device *device)return -ENODEV ; }
Quoted 5 lines
drivers/platform/x86/wmi.c static int acpi_wmi_probe(struct platform_device *device) · line 1273
Quoted 2 lines
drivers/platform/x86/wmi.c +2
-0+strscpy (acpi_device_class (acpi_device),ACPI_WMI_DEVICE_CLASS ,sizeof (acpi_device_class)); +Hmm, I'm not sure if you are supposed to do this when you are not an acpi_driver's
add()function.
You aren't.
Quoted 1 line
Rafael, do you have any comments on this ?
I'm not quite sure why this is done here.
Am 29.01.24 um 14:08 schrieb Rafael J. Wysocki:
Quoted 45 lines · Hans de Goede
Quoted 44 lines
Hi,
Quoted 41 lines · Armin Wolf
When an ACPI netlink event is received by acpid, the ACPI device class is passed as its first argument. But since the class string is not initialized, an empty string is being passed:
netlink: PNP0C14:01 000000d0 00000000Fix this by initializing the ACPI device class during probe.
Signed-off-by Armin Wolf <[email protected]>---
Note: This patch is based on commit3f399b5d7189("platform/x86: wmi: Use ACPI device name in netlink event")--- drivers/platform/x86/wmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/platform/x86/wmi.c +3
-1@@ -32,6 +32,8 @@#include <linux/wmi.h> #include <linux/fs.h> +#define ACPI_WMI_DEVICE_CLASS "wmi" +MODULE_AUTHOR ("Carlos Corbacho" );MODULE_DESCRIPTION ("ACPI-WMI Mapping Driver" );MODULE_LICENSE ("GPL" );@@ -1202,7 +1204,7 @@ static int wmi_notify_device(struct device *dev, void *data) wblock->handler (*event, wblock->handler_data); } -acpi_bus_generate_netlink_event (wblock->acpi_device->pnp.device_class, +acpi_bus_generate_netlink_event (acpi_device_class (wblock->acpi_device),acpi_dev_name (wblock->acpi_device), *event,0 );return -EBUSY ;@@ -1267,6 +1269,8 @@ static int acpi_wmi_probe(struct platform_device *device)return -ENODEV ; }
Quoted 5 lines
Quoted 4 lines
drivers/platform/x86/wmi.c static int acpi_wmi_probe(struct platform_device *device) · line 1273
Quoted 2 lines
drivers/platform/x86/wmi.c +2
-0+strscpy (acpi_device_class (acpi_device),ACPI_WMI_DEVICE_CLASS ,sizeof (acpi_device_class)); +Hmm, I'm not sure if you are supposed to do this when you are not an acpi_driver's
add()function.You aren't.
I believed otherwise, as the ACPI AC driver (which is a platform_driver) does the same thing. Seems i was wrong on that.
Quoted 3 lines
Quoted 2 lines
Rafael, do you have any comments on this ?
I'm not quite sure why this is done here.
The initialization of the ACPI device class is being done to access this value later when sending an ACPI netlink event like other ACPI drivers do.
However since you clarified that doing this outside of an acpi_driver's add() function is forbidden i think it would indeed be better to just pass the value directly without touching the ACPI device class.
Thanks,
Armin Wolf
Hi,
Quoted 47 lines · Armin Wolf
Am 29.01.24 um 14:08 schrieb Rafael J. Wysocki:
Quoted 45 lines · Hans de Goede
Quoted 44 lines
Hi,
Quoted 41 lines · Armin Wolf
When an ACPI netlink event is received by acpid, the ACPI device class is passed as its first argument. But since the class string is not initialized, an empty string is being passed:
netlink: PNP0C14:01
000000d000000000Fix this by initializing the ACPI device class during probe.
Signed-off-by Armin Wolf <[email protected]>---
Note: This patch is based on commit3f399b5d7189("platform/x86: wmi: Use ACPI device name in netlink event")
---
drivers/platform/x86/wmi.c| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)drivers/platform/x86/wmi.c +3
-1@@ -32,6 +32,8 @@ #include <linux/wmi.h> #include <linux/fs.h> +#define ACPI_WMI_DEVICE_CLASS "wmi" + MODULE_AUTHOR("Carlos Corbacho"); MODULE_DESCRIPTION("ACPI-WMI Mapping Driver"); MODULE_LICENSE("GPL");@@ -1202,7 +1204,7 @@ static int wmi_notify_device(struct device *dev, void *data) wblock->handler(*event, wblock->handler_data); } - acpi_bus_generate_netlink_event(wblock->acpi_device->pnp.device_class, + acpi_bus_generate_netlink_event(acpi_device_class(wblock->acpi_device), acpi_dev_name(wblock->acpi_device), *event, 0); return -EBUSY;@@ -1267,6 +1269,8 @@ static int acpi_wmi_probe(struct platform_device *device) return -ENODEV; }
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
drivers/platform/x86/wmi.c static int acpi_wmi_probe(struct platform_device *device) · line 1273
Quoted 2 lines
drivers/platform/x86/wmi.c +2
-0+ strscpy(acpi_device_class(acpi_device), ACPI_WMI_DEVICE_CLASS, sizeof(acpi_device_class)); +Hmm, I'm not sure if you are supposed to do this when you are not an acpi_driver's
add()function.You aren't.
I believed otherwise, as the ACPI AC driver (which is a
platform_driver) does the same thing. Seems i was wrong on that.
I'm pretty sure that the ACPI AC driver used to be an acpi_driver and was converted to a platform_driver recently.
AFAIK the plan is to convert all drivers to platform_drivers and completely get rid of the acpi_driver concept.
That does mean that we will indeed have platform_drivers now setting the acpi_device_class. So I guess that maybe this is ok to do for the WMI bus driver too, since that is also not a plain driver.
Quoted 8 lines
Quoted 2 lines
Quoted 1 line
Rafael, do you have any comments on this ?
I'm not quite sure why this is done here.
The initialization of the ACPI device class is being done to access this value later when sending an ACPI netlink event like other ACPI drivers do.
However since you clarified that doing this outside of an acpi_driver's
add()function is forbidden i think it would indeed be better to just pass the value directly without touching the ACPI device class.
Right I was thinking that you could just pass the string directly to acpi_bus_generate_netlink_event() myself too.
Rafael, do you have any preference for how to solve this ?
Regards,
Hans