From: "Luck, Tony" <tony.luck@intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Zaid Alali <zaidal@os.amperecomputing.com>,
rafael@kernel.org, lenb@kernel.org, james.morse@arm.com,
bp@alien8.de, kees@kernel.org, gustavoars@kernel.org,
Jonathan.Cameron@huawei.com, sudeep.holla@arm.com,
jonathanh@nvidia.com, u.kleine-koenig@baylibre.com,
viro@zeniv.linux.org.uk, ira.weiny@intel.com,
alison.schofield@intel.com, dan.j.williams@intel.com,
gregkh@linuxfoundation.org, peterz@infradead.org,
dave.jiang@intel.com, Benjamin.Cheatham@amd.com,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v9 5/7] ACPI: APEI: EINJ: Create debugfs files to enter device id and syndrome
Date: Wed, 18 Jun 2025 08:30:10 -0700 [thread overview]
Message-ID: <aFLbgkhB5Q4ZbAZl@agluck-desk3> (raw)
In-Reply-To: <3a143d53-8731-4afc-9117-bac49ea96db1@suswa.mountain>
On Wed, Jun 18, 2025 at 06:21:39PM +0300, Dan Carpenter wrote:
> On Thu, Jun 12, 2025 at 04:13:25PM -0700, Zaid Alali wrote:
> > +static ssize_t u128_read(struct file *f, char __user *buf, size_t count, loff_t *off)
> > +{
> > + char output[2 * COMPONENT_LEN + 1];
> > + u8 *data = f->f_inode->i_private;
> > + int i;
> > +
> > + if (*off >= sizeof(output))
> > + return 0;
>
> No need for this check. simple_read_from_buffer() will do the
> right thing.
True. But why waste cycles populating the output buffer
when it will be ignored? The normal flow here is that
a user will likely try to read a <stdio.h> sized buffer
and get back 33 bytes. Then read again to find EOF. That
second read doesn't need to do all the "sprintf()"s.
> regards,
> dan carpenter
>
> > +
> > + for (i = 0; i < COMPONENT_LEN; i++)
> > + sprintf(output + 2 * i, "%.02x", data[COMPONENT_LEN - i - 1]);
> > + output[2 * COMPONENT_LEN] = '\n';
> > +
> > + return simple_read_from_buffer(buf, count, off, output, sizeof(output));
> > +}
-Tony
next prev parent reply other threads:[~2025-06-18 15:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 23:13 [PATCH v9 0/7 RESEND] Enable EINJv2 Support Zaid Alali
2025-06-12 23:13 ` [PATCH v9 1/7] ACPI: APEI: EINJ: Fix kernel test sparse warnings Zaid Alali
2025-06-12 23:13 ` [PATCH v9 2/7] ACPI: APEI: EINJ: Enable the discovery of EINJv2 capabilities Zaid Alali
2025-06-13 16:45 ` Ira Weiny
2025-06-12 23:13 ` [PATCH v9 3/7] ACPI: APEI: EINJ: Add einjv2 extension struct Zaid Alali
2025-06-12 23:13 ` [PATCH v9 4/7] ACPI: APEI: EINJ: Discover EINJv2 parameters Zaid Alali
2025-06-13 16:57 ` Ira Weiny
2025-06-12 23:13 ` [PATCH v9 5/7] ACPI: APEI: EINJ: Create debugfs files to enter device id and syndrome Zaid Alali
2025-06-13 17:21 ` Ira Weiny
2025-06-18 15:21 ` Dan Carpenter
2025-06-18 15:30 ` Luck, Tony [this message]
2025-06-18 15:51 ` Dan Carpenter
2025-06-12 23:13 ` [PATCH v9 6/7] ACPI: APEI: EINJ: Enable EINJv2 error injections Zaid Alali
2025-06-13 17:37 ` Ira Weiny
2025-06-16 18:32 ` Zaid Alali
2025-06-12 23:13 ` [PATCH v9 7/7] ACPI: APEI: EINJ: Update the documentation for EINJv2 support Zaid Alali
2025-06-13 17:40 ` Ira Weiny
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=aFLbgkhB5Q4ZbAZl@agluck-desk3 \
--to=tony.luck@intel.com \
--cc=Benjamin.Cheatham@amd.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bp@alien8.de \
--cc=dan.carpenter@linaro.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=ira.weiny@intel.com \
--cc=james.morse@arm.com \
--cc=jonathanh@nvidia.com \
--cc=kees@kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zaidal@os.amperecomputing.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