mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Armin Wolf <W_Armin@gmx.de>, "Rafael J. Wysocki" <rafael@kernel.org>
Cc: ilpo.jarvinen@linux.intel.com,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: wmi: Initialize ACPI device class
Date: Tue, 30 Jan 2024 10:17:02 +0100	[thread overview]
Message-ID: <c09ecd6a-7b1e-42a3-84fa-ba7dbeba2851@redhat.com> (raw)
In-Reply-To: <62a9942f-97b2-4237-b99f-131535368c68@gmx.de>

Hi,

On 1/30/24 03:10, Armin Wolf wrote:
> Am 29.01.24 um 14:08 schrieb Rafael J. Wysocki:
> 
>> On Mon, Jan 29, 2024 at 1:51 PM Hans de Goede <hdegoede@redhat.com> wrote:
>>> Hi,
>>>
>>> On 1/24/24 20:07, Armin Wolf wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
>>>> ---
>>>> 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(-)
>>>>
>>>> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
>>>> index 7ef1e82dc61c..b92425c30a50 100644
>>>> --- a/drivers/platform/x86/wmi.c
>>>> +++ b/drivers/platform/x86/wmi.c
>>>> @@ -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));
>>>> +
>>> 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.

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


      reply	other threads:[~2024-01-30  9:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 19:07 Armin Wolf
2024-01-29 12:51 ` Hans de Goede
2024-01-29 13:08   ` Rafael J. Wysocki
2024-01-30  2:10     ` Armin Wolf
2024-01-30  9:17       ` Hans de Goede [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c09ecd6a-7b1e-42a3-84fa-ba7dbeba2851@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=W_Armin@gmx.de \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®