[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <472008b94f4b20915425db4714fdb505cb0cbe5a.camel@perches.com>
Date: Sat, 03 Oct 2020 14:43:09 -0700
From: Joe Perches <joe@...ches.com>
To: Sebastian Reichel <sre@...nel.org>,
Xiongfeng Wang <wangxiongfeng2@...wei.com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] test_power: add missing newlines when printing
parameters by sysfs
On Sat, 2020-10-03 at 23:23 +0200, Sebastian Reichel wrote:
> Hi,
>
> On Fri, Sep 04, 2020 at 02:09:58PM +0800, Xiongfeng Wang wrote:
> > When I cat some module parameters by sysfs, it displays as follows.
> > It's better to add a newline for easy reading.
[]
> > root@...kaller:~# cd /sys/module/test_power/parameters/
> > root@...kaller:/sys/module/test_power/parameters# cat ac_online
> > onroot@...kaller:/sys/module/test_power/parameters# cat battery_present
> > trueroot@...kaller:/sys/module/test_power/parameters# cat battery_health
> > goodroot@...kaller:/sys/module/test_power/parameters# cat battery_status
> > dischargingroot@...kaller:/sys/module/test_power/parameters# cat battery_technology
> > LIONroot@...kaller:/sys/module/test_power/parameters# cat usb_online
> > onroot@...kaller:/sys/module/test_power/parameters#
> >
> > Signed-off-by: Xiongfeng Wang <wangxiongfeng2@...wei.com>
> > ---
>
> Thanks, queued.
[]
> > diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c
[]
> > @@ -353,6 +353,7 @@ static int param_set_ac_online(const char *key, const struct kernel_param *kp)
> > static int param_get_ac_online(char *buffer, const struct kernel_param *kp)
> > {
> > strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown"));
> > + strcat(buffer, "\n");
> > return strlen(buffer);
> > }
All of these would be better as sprintf(buffer, "%s\n", <whatever>)
so the output is scanned just once instead of scanned three times.
Powered by blists - more mailing lists