* [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file()
@ 2023-07-30 4:38 Armin Wolf
2023-07-30 4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Armin Wolf @ 2023-07-30 4:38 UTC (permalink / raw
To: hdegoede, markgross; +Cc: platform-driver-x86, linux-kernel
Use device_create_bin_file() instead of sysfs_create_bin_file()
to avoid having to access the device kobject.
Tested on a ASUS PRIME B650-PLUS.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/wmi-bmof.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c
index 80137afb9753..d0516cacfcb5 100644
--- a/drivers/platform/x86/wmi-bmof.c
+++ b/drivers/platform/x86/wmi-bmof.c
@@ -75,7 +75,7 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
priv->bmof_bin_attr.read = read_bmof;
priv->bmof_bin_attr.size = priv->bmofdata->buffer.length;
- ret = sysfs_create_bin_file(&wdev->dev.kobj, &priv->bmof_bin_attr);
+ ret = device_create_bin_file(&wdev->dev, &priv->bmof_bin_attr);
if (ret)
goto err_free;
@@ -90,7 +90,7 @@ static void wmi_bmof_remove(struct wmi_device *wdev)
{
struct bmof_priv *priv = dev_get_drvdata(&wdev->dev);
- sysfs_remove_bin_file(&wdev->dev.kobj, &priv->bmof_bin_attr);
+ device_remove_bin_file(&wdev->dev, &priv->bmof_bin_attr);
kfree(priv->bmofdata);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof()
2023-07-30 4:38 [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Armin Wolf
@ 2023-07-30 4:38 ` Armin Wolf
2023-07-30 7:10 ` Thomas Weißschuh
2023-07-30 7:35 ` Thomas Weißschuh
2023-07-30 4:38 ` [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry Armin Wolf
2023-07-30 7:10 ` [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Thomas Weißschuh
2 siblings, 2 replies; 8+ messages in thread
From: Armin Wolf @ 2023-07-30 4:38 UTC (permalink / raw
To: hdegoede, markgross; +Cc: platform-driver-x86, linux-kernel
Replace offset handling code with a single call
to memory_read_from_buffer() to simplify read_bmof().
Tested on a ASUS PRIME B650-PLUS.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/wmi-bmof.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c
index d0516cacfcb5..644d2fd889c0 100644
--- a/drivers/platform/x86/wmi-bmof.c
+++ b/drivers/platform/x86/wmi-bmof.c
@@ -25,25 +25,13 @@ struct bmof_priv {
struct bin_attribute bmof_bin_attr;
};
-static ssize_t
-read_bmof(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr,
- char *buf, loff_t off, size_t count)
+static ssize_t read_bmof(struct file *filp, struct kobject *kobj, struct bin_attribute *attr,
+ char *buf, loff_t off, size_t count)
{
- struct bmof_priv *priv =
- container_of(attr, struct bmof_priv, bmof_bin_attr);
+ struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr);
- if (off < 0)
- return -EINVAL;
-
- if (off >= priv->bmofdata->buffer.length)
- return 0;
-
- if (count > priv->bmofdata->buffer.length - off)
- count = priv->bmofdata->buffer.length - off;
-
- memcpy(buf, priv->bmofdata->buffer.pointer + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off, priv->bmofdata->buffer.pointer,
+ priv->bmofdata->buffer.length);
}
static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry
2023-07-30 4:38 [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Armin Wolf
2023-07-30 4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
@ 2023-07-30 4:38 ` Armin Wolf
2023-07-30 7:11 ` Thomas Weißschuh
2023-07-30 7:10 ` [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Thomas Weißschuh
2 siblings, 1 reply; 8+ messages in thread
From: Armin Wolf @ 2023-07-30 4:38 UTC (permalink / raw
To: hdegoede, markgross; +Cc: platform-driver-x86, linux-kernel
The WMI Binary MOF driver is important for the development
of modern WMI drivers, i am willing to maintain it.
Also fix the mailing list address.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
MAINTAINERS | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 426d3be71da2..9b871fb34e83 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22954,8 +22954,9 @@ S: Odd fixes
F: drivers/net/wireless/legacy/wl3501*
WMI BINARY MOF DRIVER
-L: platform-drivers-x86@vger.kernel.org
-S: Orphan
+M: Armin Wolf <W_Armin@gmx.de>
+L: platform-driver-x86@vger.kernel.org
+S: Maintained
F: Documentation/ABI/stable/sysfs-platform-wmi-bmof
F: Documentation/wmi/devices/wmi-bmof.rst
F: drivers/platform/x86/wmi-bmof.c
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file()
2023-07-30 4:38 [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Armin Wolf
2023-07-30 4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
2023-07-30 4:38 ` [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry Armin Wolf
@ 2023-07-30 7:10 ` Thomas Weißschuh
2 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2023-07-30 7:10 UTC (permalink / raw
To: Armin Wolf; +Cc: hdegoede, markgross, platform-driver-x86, linux-kernel
On 2023-07-30 06:38:15+0200, Armin Wolf wrote:
> Use device_create_bin_file() instead of sysfs_create_bin_file()
> to avoid having to access the device kobject.
>
> Tested on a ASUS PRIME B650-PLUS.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> drivers/platform/x86/wmi-bmof.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c
> index 80137afb9753..d0516cacfcb5 100644
> --- a/drivers/platform/x86/wmi-bmof.c
> +++ b/drivers/platform/x86/wmi-bmof.c
> @@ -75,7 +75,7 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
> priv->bmof_bin_attr.read = read_bmof;
> priv->bmof_bin_attr.size = priv->bmofdata->buffer.length;
>
> - ret = sysfs_create_bin_file(&wdev->dev.kobj, &priv->bmof_bin_attr);
> + ret = device_create_bin_file(&wdev->dev, &priv->bmof_bin_attr);
> if (ret)
> goto err_free;
>
> @@ -90,7 +90,7 @@ static void wmi_bmof_remove(struct wmi_device *wdev)
> {
> struct bmof_priv *priv = dev_get_drvdata(&wdev->dev);
>
> - sysfs_remove_bin_file(&wdev->dev.kobj, &priv->bmof_bin_attr);
> + device_remove_bin_file(&wdev->dev, &priv->bmof_bin_attr);
> kfree(priv->bmofdata);
> }
>
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof()
2023-07-30 4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
@ 2023-07-30 7:10 ` Thomas Weißschuh
2023-07-30 7:35 ` Thomas Weißschuh
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2023-07-30 7:10 UTC (permalink / raw
To: Armin Wolf; +Cc: hdegoede, markgross, platform-driver-x86, linux-kernel
On 2023-07-30 06:38:16+0200, Armin Wolf wrote:
> Replace offset handling code with a single call
> to memory_read_from_buffer() to simplify read_bmof().
>
> Tested on a ASUS PRIME B650-PLUS.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> drivers/platform/x86/wmi-bmof.c | 22 +++++-----------------
> 1 file changed, 5 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c
> index d0516cacfcb5..644d2fd889c0 100644
> --- a/drivers/platform/x86/wmi-bmof.c
> +++ b/drivers/platform/x86/wmi-bmof.c
> @@ -25,25 +25,13 @@ struct bmof_priv {
> struct bin_attribute bmof_bin_attr;
> };
>
> -static ssize_t
> -read_bmof(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *attr,
> - char *buf, loff_t off, size_t count)
> +static ssize_t read_bmof(struct file *filp, struct kobject *kobj, struct bin_attribute *attr,
> + char *buf, loff_t off, size_t count)
> {
> - struct bmof_priv *priv =
> - container_of(attr, struct bmof_priv, bmof_bin_attr);
> + struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr);
>
> - if (off < 0)
> - return -EINVAL;
> -
> - if (off >= priv->bmofdata->buffer.length)
> - return 0;
> -
> - if (count > priv->bmofdata->buffer.length - off)
> - count = priv->bmofdata->buffer.length - off;
> -
> - memcpy(buf, priv->bmofdata->buffer.pointer + off, count);
> - return count;
> + return memory_read_from_buffer(buf, count, &off, priv->bmofdata->buffer.pointer,
> + priv->bmofdata->buffer.length);
> }
>
> static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry
2023-07-30 4:38 ` [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry Armin Wolf
@ 2023-07-30 7:11 ` Thomas Weißschuh
2023-07-30 20:30 ` Armin Wolf
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2023-07-30 7:11 UTC (permalink / raw
To: Armin Wolf; +Cc: hdegoede, markgross, platform-driver-x86, linux-kernel
On 2023-07-30 06:38:17+0200, Armin Wolf wrote:
> The WMI Binary MOF driver is important for the development
> of modern WMI drivers, i am willing to maintain it.
> Also fix the mailing list address.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> MAINTAINERS | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 426d3be71da2..9b871fb34e83 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -22954,8 +22954,9 @@ S: Odd fixes
> F: drivers/net/wireless/legacy/wl3501*
>
> WMI BINARY MOF DRIVER
> -L: platform-drivers-x86@vger.kernel.org
> -S: Orphan
> +M: Armin Wolf <W_Armin@gmx.de>
> +L: platform-driver-x86@vger.kernel.org
> +S: Maintained
If you want a reviewer or second maintainer I would be volunteering.
> F: Documentation/ABI/stable/sysfs-platform-wmi-bmof
> F: Documentation/wmi/devices/wmi-bmof.rst
> F: drivers/platform/x86/wmi-bmof.c
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof()
2023-07-30 4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
2023-07-30 7:10 ` Thomas Weißschuh
@ 2023-07-30 7:35 ` Thomas Weißschuh
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2023-07-30 7:35 UTC (permalink / raw
To: Armin Wolf; +Cc: hdegoede, markgross, platform-driver-x86, linux-kernel
On 2023-07-30 06:38:16+0200, Armin Wolf wrote:
> Replace offset handling code with a single call
> to memory_read_from_buffer() to simplify read_bmof().
>
> Tested on a ASUS PRIME B650-PLUS.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> drivers/platform/x86/wmi-bmof.c | 22 +++++-----------------
> 1 file changed, 5 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c
> index d0516cacfcb5..644d2fd889c0 100644
> --- a/drivers/platform/x86/wmi-bmof.c
> +++ b/drivers/platform/x86/wmi-bmof.c
> @@ -25,25 +25,13 @@ struct bmof_priv {
> struct bin_attribute bmof_bin_attr;
> };
>
> -static ssize_t
> -read_bmof(struct file *filp, struct kobject *kobj,
> - struct bin_attribute *attr,
> - char *buf, loff_t off, size_t count)
> +static ssize_t read_bmof(struct file *filp, struct kobject *kobj, struct bin_attribute *attr,
> + char *buf, loff_t off, size_t count)
> {
> - struct bmof_priv *priv =
> - container_of(attr, struct bmof_priv, bmof_bin_attr);
> + struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr);
>
> - if (off < 0)
> - return -EINVAL;
> -
> - if (off >= priv->bmofdata->buffer.length)
> - return 0;
> -
> - if (count > priv->bmofdata->buffer.length - off)
> - count = priv->bmofdata->buffer.length - off;
> -
> - memcpy(buf, priv->bmofdata->buffer.pointer + off, count);
> - return count;
> + return memory_read_from_buffer(buf, count, &off, priv->bmofdata->buffer.pointer,
> + priv->bmofdata->buffer.length);
Note: sysfs_kf_bin_read() seems also to be doing most of this validation.
So the invalid input values, expect for negative "off", can't happen anyways.
memory_read_from_buffer() is still nice though.
> }
>
> static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry
2023-07-30 7:11 ` Thomas Weißschuh
@ 2023-07-30 20:30 ` Armin Wolf
0 siblings, 0 replies; 8+ messages in thread
From: Armin Wolf @ 2023-07-30 20:30 UTC (permalink / raw
To: Thomas Weißschuh
Cc: hdegoede, markgross, platform-driver-x86, linux-kernel
Am 30.07.23 um 09:11 schrieb Thomas Weißschuh:
> On 2023-07-30 06:38:17+0200, Armin Wolf wrote:
>> The WMI Binary MOF driver is important for the development
>> of modern WMI drivers, i am willing to maintain it.
>> Also fix the mailing list address.
>>
>> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
>> ---
>> MAINTAINERS | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 426d3be71da2..9b871fb34e83 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -22954,8 +22954,9 @@ S: Odd fixes
>> F: drivers/net/wireless/legacy/wl3501*
>>
>> WMI BINARY MOF DRIVER
>> -L: platform-drivers-x86@vger.kernel.org
>> -S: Orphan
>> +M: Armin Wolf <W_Armin@gmx.de>
>> +L: platform-driver-x86@vger.kernel.org
>> +S: Maintained
> If you want a reviewer or second maintainer I would be volunteering.
Sure, the driver might be quite small, but having an reviewer is always good.
Armin Wolf
>> F: Documentation/ABI/stable/sysfs-platform-wmi-bmof
>> F: Documentation/wmi/devices/wmi-bmof.rst
>> F: drivers/platform/x86/wmi-bmof.c
>> --
>> 2.39.2
>>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-07-30 20:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-30 4:38 [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Armin Wolf
2023-07-30 4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
2023-07-30 7:10 ` Thomas Weißschuh
2023-07-30 7:35 ` Thomas Weißschuh
2023-07-30 4:38 ` [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry Armin Wolf
2023-07-30 7:11 ` Thomas Weißschuh
2023-07-30 20:30 ` Armin Wolf
2023-07-30 7:10 ` [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Thomas Weißschuh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).