Message ID | 20241205-sysfs-const-bin_attr-simple-v1-2-4a4e4ced71e3@weissschuh.net (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | sysfs: constify bin_attribute argument of sysfs_bin_attr_simple_read() | expand |
Am 05.12.24 um 18:35 schrieb Thomas Weißschuh: > The generic function from the sysfs core can replace the custom one. Sorry for taking quite a bit to respond, i totally overlooked this patch. This patch is superseded by a patch of mine: https://lore.kernel.org/platform-driver-x86/20241206215650.2977-1-W_Armin@gmx.de/ This reworks the binary attribute handling inside the driver to use the new .bin_size() callback. This allows the driver to have a static binary attribute which does not need a memory allocation. Because i think we cannot use sysfs_bin_attr_simple_read() anymore. So maybe you can just drop this patch? Thanks, Armin Wolf > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > --- > drivers/platform/x86/wmi-bmof.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c > index df6f0ae6e6c7904f97c125297a21166f56d0b1f0..e6c217d70086a2896dc70cf8ac1c27dafb501a95 100644 > --- a/drivers/platform/x86/wmi-bmof.c > +++ b/drivers/platform/x86/wmi-bmof.c > @@ -25,15 +25,6 @@ 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) > -{ > - struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr); > - > - 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) > { > struct bmof_priv *priv; > @@ -60,7 +51,8 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context) > sysfs_bin_attr_init(&priv->bmof_bin_attr); > priv->bmof_bin_attr.attr.name = "bmof"; > priv->bmof_bin_attr.attr.mode = 0400; > - priv->bmof_bin_attr.read = read_bmof; > + priv->bmof_bin_attr.read_new = sysfs_bin_attr_simple_read; > + priv->bmof_bin_attr.private = priv->bmofdata->buffer.pointer; > priv->bmof_bin_attr.size = priv->bmofdata->buffer.length; > > ret = device_create_bin_file(&wdev->dev, &priv->bmof_bin_attr); >
Hi Armin, On 2024-12-13 01:21:37+0100, Armin Wolf wrote: > Am 05.12.24 um 18:35 schrieb Thomas Weißschuh: > > > The generic function from the sysfs core can replace the custom one. > > Sorry for taking quite a bit to respond, i totally overlooked this patch. > > This patch is superseded by a patch of mine: https://lore.kernel.org/platform-driver-x86/20241206215650.2977-1-W_Armin@gmx.de/ > > This reworks the binary attribute handling inside the driver to use the new .bin_size() callback. This allows the > driver to have a static binary attribute which does not need a memory allocation. > > Because i think we cannot use sysfs_bin_attr_simple_read() anymore. So maybe you can just drop this patch? Works for me, thanks! Thomas > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > --- > > drivers/platform/x86/wmi-bmof.c | 12 ++---------- > > 1 file changed, 2 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c > > index df6f0ae6e6c7904f97c125297a21166f56d0b1f0..e6c217d70086a2896dc70cf8ac1c27dafb501a95 100644 > > --- a/drivers/platform/x86/wmi-bmof.c > > +++ b/drivers/platform/x86/wmi-bmof.c > > @@ -25,15 +25,6 @@ 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) > > -{ > > - struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr); > > - > > - 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) > > { > > struct bmof_priv *priv; > > @@ -60,7 +51,8 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context) > > sysfs_bin_attr_init(&priv->bmof_bin_attr); > > priv->bmof_bin_attr.attr.name = "bmof"; > > priv->bmof_bin_attr.attr.mode = 0400; > > - priv->bmof_bin_attr.read = read_bmof; > > + priv->bmof_bin_attr.read_new = sysfs_bin_attr_simple_read; > > + priv->bmof_bin_attr.private = priv->bmofdata->buffer.pointer; > > priv->bmof_bin_attr.size = priv->bmofdata->buffer.length; > > > > ret = device_create_bin_file(&wdev->dev, &priv->bmof_bin_attr); > >
diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c index df6f0ae6e6c7904f97c125297a21166f56d0b1f0..e6c217d70086a2896dc70cf8ac1c27dafb501a95 100644 --- a/drivers/platform/x86/wmi-bmof.c +++ b/drivers/platform/x86/wmi-bmof.c @@ -25,15 +25,6 @@ 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) -{ - struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr); - - 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) { struct bmof_priv *priv; @@ -60,7 +51,8 @@ static int wmi_bmof_probe(struct wmi_device *wdev, const void *context) sysfs_bin_attr_init(&priv->bmof_bin_attr); priv->bmof_bin_attr.attr.name = "bmof"; priv->bmof_bin_attr.attr.mode = 0400; - priv->bmof_bin_attr.read = read_bmof; + priv->bmof_bin_attr.read_new = sysfs_bin_attr_simple_read; + priv->bmof_bin_attr.private = priv->bmofdata->buffer.pointer; priv->bmof_bin_attr.size = priv->bmofdata->buffer.length; ret = device_create_bin_file(&wdev->dev, &priv->bmof_bin_attr);
The generic function from the sysfs core can replace the custom one. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> --- drivers/platform/x86/wmi-bmof.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)