mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Woithe <jwoithe@just42.net>
To: Szilard Fabian <szfabian@bluemarch.art>
Cc: linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, hdegoede@redhat.com,
	ilpo.jarvinen@linux.intel.com
Subject: Re: [PATCH] platform/x86/fujitsu-laptop: Replace sprintf() with sysfs_emit()
Date: Mon, 29 Apr 2024 10:30:02 +0930	[thread overview]
Message-ID: <Zi7xEp5Gs4qtzB5p@marvin.atrad.com.au> (raw)
In-Reply-To: <20240428192548.113261-1-szfabian@bluemarch.art>

On Sun, Apr 28, 2024 at 07:26:33PM +0000, Szilard Fabian wrote:
> As suggested by Documentation/filesystems/sysfs.rst sysfs_emit() should be
> used when formatting the value to be returned to user space.
> 
> Signed-off-by: Szilard Fabian <szfabian@bluemarch.art>

This seems entirely reasonable.

Acked-by: Jonathan Woithe <jwoithe@just42.net>

> ---
>  drivers/platform/x86/fujitsu-laptop.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 94480af49467..968fc91bd5e4 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -386,11 +386,11 @@ static ssize_t lid_show(struct device *dev, struct device_attribute *attr,
>  	struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>  
>  	if (!(priv->flags_supported & FLAG_LID))
> -		return sprintf(buf, "unknown\n");
> +		return sysfs_emit(buf, "unknown\n");
>  	if (priv->flags_state & FLAG_LID)
> -		return sprintf(buf, "open\n");
> +		return sysfs_emit(buf, "open\n");
>  	else
> -		return sprintf(buf, "closed\n");
> +		return sysfs_emit(buf, "closed\n");
>  }
>  
>  static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
> @@ -399,11 +399,11 @@ static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
>  	struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>  
>  	if (!(priv->flags_supported & FLAG_DOCK))
> -		return sprintf(buf, "unknown\n");
> +		return sysfs_emit(buf, "unknown\n");
>  	if (priv->flags_state & FLAG_DOCK)
> -		return sprintf(buf, "docked\n");
> +		return sysfs_emit(buf, "docked\n");
>  	else
> -		return sprintf(buf, "undocked\n");
> +		return sysfs_emit(buf, "undocked\n");
>  }
>  
>  static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
> @@ -412,11 +412,11 @@ static ssize_t radios_show(struct device *dev, struct device_attribute *attr,
>  	struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>  
>  	if (!(priv->flags_supported & FLAG_RFKILL))
> -		return sprintf(buf, "unknown\n");
> +		return sysfs_emit(buf, "unknown\n");
>  	if (priv->flags_state & FLAG_RFKILL)
> -		return sprintf(buf, "on\n");
> +		return sysfs_emit(buf, "on\n");
>  	else
> -		return sprintf(buf, "killed\n");
> +		return sysfs_emit(buf, "killed\n");
>  }
>  
>  static DEVICE_ATTR_RO(lid);
> -- 
> 2.44.0
> 
> 

  reply	other threads:[~2024-04-29  1:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-28 19:26 Szilard Fabian
2024-04-29  1:00 ` Jonathan Woithe [this message]
2024-04-29  3:17 ` Kuppuswamy Sathyanarayanan

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=Zi7xEp5Gs4qtzB5p@marvin.atrad.com.au \
    --to=jwoithe@just42.net \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=szfabian@bluemarch.art \
    /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®