2024-04-02 15:02:39

by Armin Wolf

[permalink] [raw]
Subject: [PATCH v2 1/4] platform/x86: wmi: Mark simple WMI drivers as legacy-free

The inspur_platform_profile driver and the xiaomi-wmi driver both
meet the requirements for modern WMI drivers, as they both do not
use the legacy GUID-based interface and can be safely instantiated
multiple times.

Mark them both as legacy-free using the no_singleton flag.

Compile-tested only.

Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Signed-off-by: Armin Wolf <[email protected]>
---
Changes since v1:
- add Reviewed-by tag
---
drivers/platform/x86/inspur_platform_profile.c | 1 +
drivers/platform/x86/xiaomi-wmi.c | 1 +
2 files changed, 2 insertions(+)

diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
index 743705bddda3..8440defa6788 100644
--- a/drivers/platform/x86/inspur_platform_profile.c
+++ b/drivers/platform/x86/inspur_platform_profile.c
@@ -207,6 +207,7 @@ static struct wmi_driver inspur_wmi_driver = {
.id_table = inspur_wmi_id_table,
.probe = inspur_wmi_probe,
.remove = inspur_wmi_remove,
+ .no_singleton = true,
};

module_wmi_driver(inspur_wmi_driver);
diff --git a/drivers/platform/x86/xiaomi-wmi.c b/drivers/platform/x86/xiaomi-wmi.c
index 54a2546bb93b..1f5f108d87c0 100644
--- a/drivers/platform/x86/xiaomi-wmi.c
+++ b/drivers/platform/x86/xiaomi-wmi.c
@@ -83,6 +83,7 @@ static struct wmi_driver xiaomi_wmi_driver = {
.id_table = xiaomi_wmi_id_table,
.probe = xiaomi_wmi_probe,
.notify = xiaomi_wmi_notify,
+ .no_singleton = true,
};
module_wmi_driver(xiaomi_wmi_driver);

--
2.39.2



2024-04-02 15:03:37

by Armin Wolf

[permalink] [raw]
Subject: [PATCH v2 3/4] platform/x86: xiaomi-wmi: Drop unnecessary NULL checks

The WMI driver core already makes sure that:

- a valid WMI device is passed to each callback
- the notify() callback runs after the probe() callback succeeds

Remove the unnecessary NULL checks.

Compile-tested only.

Signed-off-by: Armin Wolf <[email protected]>
---
drivers/platform/x86/xiaomi-wmi.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/xiaomi-wmi.c b/drivers/platform/x86/xiaomi-wmi.c
index 7efbdc111803..cbed29ca502a 100644
--- a/drivers/platform/x86/xiaomi-wmi.c
+++ b/drivers/platform/x86/xiaomi-wmi.c
@@ -38,7 +38,7 @@ static int xiaomi_wmi_probe(struct wmi_device *wdev, const void *context)
struct xiaomi_wmi *data;
int ret;

- if (wdev == NULL || context == NULL)
+ if (!context)
return -EINVAL;

data = devm_kzalloc(&wdev->dev, sizeof(struct xiaomi_wmi), GFP_KERNEL);
@@ -66,14 +66,7 @@ static int xiaomi_wmi_probe(struct wmi_device *wdev, const void *context)

static void xiaomi_wmi_notify(struct wmi_device *wdev, union acpi_object *dummy)
{
- struct xiaomi_wmi *data;
-
- if (wdev == NULL)
- return;
-
- data = dev_get_drvdata(&wdev->dev);
- if (data == NULL)
- return;
+ struct xiaomi_wmi *data = dev_get_drvdata(&wdev->dev);

mutex_lock(&data->key_lock);
input_report_key(data->input_dev, data->key_code, 1);
--
2.39.2


Subject: Re: [PATCH v2 3/4] platform/x86: xiaomi-wmi: Drop unnecessary NULL checks


On 4/2/24 7:30 AM, Armin Wolf wrote:
> The WMI driver core already makes sure that:
>
> - a valid WMI device is passed to each callback
> - the notify() callback runs after the probe() callback succeeds
>
> Remove the unnecessary NULL checks.
>
> Compile-tested only.
>
> Signed-off-by: Armin Wolf <[email protected]>
> ---

LGTM

Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>

> drivers/platform/x86/xiaomi-wmi.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/xiaomi-wmi.c b/drivers/platform/x86/xiaomi-wmi.c
> index 7efbdc111803..cbed29ca502a 100644
> --- a/drivers/platform/x86/xiaomi-wmi.c
> +++ b/drivers/platform/x86/xiaomi-wmi.c
> @@ -38,7 +38,7 @@ static int xiaomi_wmi_probe(struct wmi_device *wdev, const void *context)
> struct xiaomi_wmi *data;
> int ret;
>
> - if (wdev == NULL || context == NULL)
> + if (!context)
> return -EINVAL;
>
> data = devm_kzalloc(&wdev->dev, sizeof(struct xiaomi_wmi), GFP_KERNEL);
> @@ -66,14 +66,7 @@ static int xiaomi_wmi_probe(struct wmi_device *wdev, const void *context)
>
> static void xiaomi_wmi_notify(struct wmi_device *wdev, union acpi_object *dummy)
> {
> - struct xiaomi_wmi *data;
> -
> - if (wdev == NULL)
> - return;
> -
> - data = dev_get_drvdata(&wdev->dev);
> - if (data == NULL)
> - return;
> + struct xiaomi_wmi *data = dev_get_drvdata(&wdev->dev);
>
> mutex_lock(&data->key_lock);
> input_report_key(data->input_dev, data->key_code, 1);
> --
> 2.39.2
>
>
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


2024-04-08 15:40:58

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] platform/x86: wmi: Mark simple WMI drivers as legacy-free

Hi,

On 4/2/24 4:30 PM, Armin Wolf wrote:
> The inspur_platform_profile driver and the xiaomi-wmi driver both
> meet the requirements for modern WMI drivers, as they both do not
> use the legacy GUID-based interface and can be safely instantiated
> multiple times.
>
> Mark them both as legacy-free using the no_singleton flag.
>
> Compile-tested only.
>
> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
> Signed-off-by: Armin Wolf <[email protected]>

Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans




> ---
> Changes since v1:
> - add Reviewed-by tag
> ---
> drivers/platform/x86/inspur_platform_profile.c | 1 +
> drivers/platform/x86/xiaomi-wmi.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
> index 743705bddda3..8440defa6788 100644
> --- a/drivers/platform/x86/inspur_platform_profile.c
> +++ b/drivers/platform/x86/inspur_platform_profile.c
> @@ -207,6 +207,7 @@ static struct wmi_driver inspur_wmi_driver = {
> .id_table = inspur_wmi_id_table,
> .probe = inspur_wmi_probe,
> .remove = inspur_wmi_remove,
> + .no_singleton = true,
> };
>
> module_wmi_driver(inspur_wmi_driver);
> diff --git a/drivers/platform/x86/xiaomi-wmi.c b/drivers/platform/x86/xiaomi-wmi.c
> index 54a2546bb93b..1f5f108d87c0 100644
> --- a/drivers/platform/x86/xiaomi-wmi.c
> +++ b/drivers/platform/x86/xiaomi-wmi.c
> @@ -83,6 +83,7 @@ static struct wmi_driver xiaomi_wmi_driver = {
> .id_table = xiaomi_wmi_id_table,
> .probe = xiaomi_wmi_probe,
> .notify = xiaomi_wmi_notify,
> + .no_singleton = true,
> };
> module_wmi_driver(xiaomi_wmi_driver);
>
> --
> 2.39.2
>