mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: alexandre.belloni@bootlin.com
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/12] rtc: abx80x: use sysfs_emit() instead of sprintf()
Date: Fri, 30 Oct 2026 16:40:56 +0000	[thread overview]
Message-ID: <20261030164056.395340bf@pumpkin> (raw)
In-Reply-To: <20261029132339.925021-6-alexandre.belloni@bootlin.com>

On Thu, 29 Oct 2026 14:23:29 +0100
alexandre.belloni@bootlin.com wrote:

> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
> 
> Use sysfs_emit() instead of sprintf() in sysfs show callbacks
> (autocalibration_show and oscillator_show) to conform to the
> recommended sysfs attribute formatting guidelines in
> Documentation/filesystems/sysfs.rst.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
>  drivers/rtc/rtc-abx80x.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> index 1c69d0e2f940..a0d67818eb58 100644
> --- a/drivers/rtc/rtc-abx80x.c
> +++ b/drivers/rtc/rtc-abx80x.c
> @@ -442,11 +442,11 @@ static ssize_t autocalibration_show(struct device *dev,
>  	autocalibration = abx80x_rtc_get_autocalibration(dev->parent);
>  	if (autocalibration < 0) {
>  		dev_err(dev, "Failed to read RTC autocalibration\n");
> -		sprintf(buf, "0\n");
> +		sysfs_emit(buf, "0\n");
>  		return autocalibration;

That doesn't make sense.
The return value is the length of data in the buffer.
So there is no point calling sprintf/sysfs_emit and then returning
an error.

David

>  	}
>  
> -	return sprintf(buf, "%d\n", autocalibration);
> +	return sysfs_emit(buf, "%d\n", autocalibration);
>  }
>  
>  static DEVICE_ATTR_RW(autocalibration);
> @@ -490,14 +490,14 @@ static ssize_t oscillator_show(struct device *dev,
>  
>  	if (rc_mode < 0) {
>  		dev_err(dev, "Failed to read RTC oscillator selection\n");
> -		sprintf(buf, "\n");
> +		sysfs_emit(buf, "\n");
>  		return rc_mode;
>  	}
>  
>  	if (rc_mode)
> -		return sprintf(buf, "rc\n");
> +		return sysfs_emit(buf, "rc\n");
>  	else
> -		return sprintf(buf, "xtal\n");
> +		return sysfs_emit(buf, "xtal\n");
>  }
>  
>  static DEVICE_ATTR_RW(oscillator);


  reply	other threads:[~2026-10-30 16:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 13:23 [PATCH 01/12] rtc: rv3029: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 02/12] rtc: pcf2127: " alexandre.belloni
2026-10-29 18:20   ` Bruno Thomsen
2026-10-29 13:23 ` [PATCH 03/12] rtc: ep93xx: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 04/12] rtc: bq32k: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 05/12] rtc: x1205: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 06/12] rtc: abx80x: " alexandre.belloni
2026-10-30 16:40   ` David Laight [this message]
2026-10-29 13:23 ` [PATCH 07/12] rtc: rx8025: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 08/12] rtc: ds1343: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 09/12] rtc: ds1685: " alexandre.belloni
2026-10-29 13:49   ` Joshua Kinard
2026-10-29 13:23 ` [PATCH 10/12] rtc: isl1208: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 11/12] rtc: ds1307: " alexandre.belloni
2026-10-29 13:23 ` [PATCH 12/12] rtc: rs5c372: " alexandre.belloni

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=20261030164056.395340bf@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /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®