mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Geoff Levand <geoff@infradead.org>
To: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>,
	mpe@ellerman.id.au, npiggin@gmail.com,
	christophe.leroy@csgroup.eu, naveen@kernel.org,
	maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] powerpc/ps3: replace open-coded sysfs_emit function
Date: Mon, 21 Oct 2024 17:49:49 +0900	[thread overview]
Message-ID: <85eefbd5-bc90-4cb8-807f-6d1ee195e7f4@infradead.org> (raw)
In-Reply-To: <ZxMV3YvSulJFZ8rk@mail.google.com>

Hi Paulo,

On 10/19/24 11:13, Paulo Miguel Almeida wrote:
> sysfs_emit() helper function should be used when formatting the value
> to be returned to user space.
> 
> This patch replaces open-coded sysfs_emit() in sysfs .show() callbacks
> 
> Link: https://github.com/KSPP/linux/issues/105
> Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
> ---
>  arch/powerpc/platforms/ps3/system-bus.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
> index b9a7d9bae687..afbaabf182d0 100644
> --- a/arch/powerpc/platforms/ps3/system-bus.c
> +++ b/arch/powerpc/platforms/ps3/system-bus.c
> @@ -453,10 +453,9 @@ static ssize_t modalias_show(struct device *_dev, struct device_attribute *a,
>  	char *buf)
>  {
>  	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
> -	int len = snprintf(buf, PAGE_SIZE, "ps3:%d:%d\n", dev->match_id,
> -			   dev->match_sub_id);
>  
> -	return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
> +	return sysfs_emit(buf, "ps3:%d:%d\n", dev->match_id,
> +			  dev->match_sub_id);
>  }
>  static DEVICE_ATTR_RO(modalias);

I tested this on PS3 and it seems to work OK.
Thanks for your contribution.

Acked-by: Geoff Levand <geoff@infradead.org>



  parent reply	other threads:[~2024-10-21  8:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19  2:13 Paulo Miguel Almeida
2024-10-21  7:31 ` Geert Uytterhoeven
2024-10-21  8:49 ` Geoff Levand [this message]
2024-11-17 12:09 ` Michael Ellerman

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=85eefbd5-bc90-4cb8-807f-6d1ee195e7f4@infradead.org \
    --to=geoff@infradead.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=naveen@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=paulo.miguel.almeida.rodenas@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

all inboxes | Powered by JetHome®