From: Michael Ellerman <mpe@ellerman.id.au>
To: Lukas Wunner <lukas@wunner.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org
Cc: linux-efi@vger.kernel.org, Zhi Wang <zhi.wang.linux@gmail.com>,
linux-pm@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhenyu Wang <zhenyuw@linux.intel.com>,
linux-acpi@vger.kernel.org, Luis Chamberlain <mcgrof@kernel.org>,
Jean Delvare <jdelvare@suse.com>,
linuxppc-dev@lists.ozlabs.org, Ard Biesheuvel <ardb@kernel.org>,
linux-modules@vger.kernel.org
Subject: Re: [PATCH 2/2] treewide: Use sysfs_bin_attr_simple_read() helper
Date: Mon, 08 Apr 2024 21:11:57 +1000 [thread overview]
Message-ID: <87jzl8az2a.fsf@mail.lhotse> (raw)
In-Reply-To: <92ee0a0e83a5a3f3474845db6c8575297698933a.1712410202.git.lukas@wunner.de>
Lukas Wunner <lukas@wunner.de> writes:
> Deduplicate ->read() callbacks of bin_attributes which are backed by a
> simple buffer in memory:
>
> Use the newly introduced sysfs_bin_attr_simple_read() helper instead,
> either by referencing it directly or by declaring such bin_attributes
> with BIN_ATTR_SIMPLE_RO() or BIN_ATTR_SIMPLE_ADMIN_RO().
>
> Aside from a reduction of LoC, this shaves off a few bytes from vmlinux
> (304 bytes on an x86_64 allyesconfig).
>
> No functional change intended.
>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---
> arch/powerpc/platforms/powernv/opal.c | 10 +--------
> drivers/acpi/bgrt.c | 9 +-------
> drivers/firmware/dmi_scan.c | 12 ++--------
> drivers/firmware/efi/rci2-table.c | 10 +--------
> drivers/gpu/drm/i915/gvt/firmware.c | 26 +++++-----------------
> .../intel/int340x_thermal/int3400_thermal.c | 9 +-------
> init/initramfs.c | 10 +--------
> kernel/module/sysfs.c | 13 +----------
> 8 files changed, 14 insertions(+), 85 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index 45dd77e..5d0f35b 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -792,14 +792,6 @@ static int __init opal_sysfs_init(void)
> return 0;
> }
>
> -static ssize_t export_attr_read(struct file *fp, struct kobject *kobj,
> - struct bin_attribute *bin_attr, char *buf,
> - loff_t off, size_t count)
> -{
> - return memory_read_from_buffer(buf, count, &off, bin_attr->private,
> - bin_attr->size);
> -}
> -
> static int opal_add_one_export(struct kobject *parent, const char *export_name,
> struct device_node *np, const char *prop_name)
> {
> @@ -826,7 +818,7 @@ static int opal_add_one_export(struct kobject *parent, const char *export_name,
> sysfs_bin_attr_init(attr);
> attr->attr.name = name;
> attr->attr.mode = 0400;
> - attr->read = export_attr_read;
> + attr->read = sysfs_bin_attr_simple_read;
> attr->private = __va(vals[0]);
> attr->size = vals[1];
I gave it a quick boot and checked I could still read the attributes,
everything seems fine.
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
cheers
next prev parent reply other threads:[~2024-04-08 11:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 13:52 [PATCH 0/2] Deduplicate bin_attribute simple read() callbacks Lukas Wunner
2024-04-06 13:52 ` [PATCH 1/2] sysfs: Add sysfs_bin_attr_simple_read() helper Lukas Wunner
2024-04-11 13:07 ` Greg Kroah-Hartman
2024-04-06 13:52 ` [PATCH 2/2] treewide: Use " Lukas Wunner
2024-04-08 10:42 ` Zhi Wang
2024-04-08 11:11 ` Michael Ellerman [this message]
2024-05-23 2:51 ` Guenter Roeck
2024-05-23 6:51 ` Greg Kroah-Hartman
2024-05-23 11:00 ` [PATCH] sysfs: Unbreak the build around sysfs_bin_attr_simple_read() Lukas Wunner
2024-05-23 11:13 ` Rafael J. Wysocki
2024-05-23 14:23 ` Guenter Roeck
2024-04-08 8:42 ` [PATCH 0/2] Deduplicate bin_attribute simple read() callbacks Ard Biesheuvel
2024-04-08 15:01 ` Rafael J. Wysocki
2024-04-11 13:07 ` Greg Kroah-Hartman
2024-04-11 13:39 ` Lukas Wunner
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=87jzl8az2a.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=ardb@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jdelvare@suse.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lukas@wunner.de \
--cc=mcgrof@kernel.org \
--cc=rafael@kernel.org \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.wang.linux@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).