[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZKu3MIfEyIBqg2g1@yilunxu-OptiPlex-7050>
Date: Mon, 10 Jul 2023 15:45:52 +0800
From: Xu Yilun <yilun.xu@...el.com>
To: Peter Colberg <peter.colberg@...el.com>
Cc: Wu Hao <hao.wu@...el.com>, Tom Rix <trix@...hat.com>,
Moritz Fischer <mdf@...nel.org>, linux-fpga@...r.kernel.org,
linux-kernel@...r.kernel.org,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
tianfei.zhang@...el.com, russell.h.weight@...el.com,
matthew.gerlach@...ux.intel.com, marpagan@...hat.com,
lgoncalv@...hat.com
Subject: Re: [PATCH 1/2] fpga: dfl: use sysfs_emit() to format sysfs values
On 2023-07-04 at 22:54:50 -0400, Peter Colberg wrote:
> Use sysfs_emit() to format sysfs values, which wraps vscnprintf() for a
> PAGE_SIZE buffer. Remove explicit casts in favour of using the printk()
> format specifier corresponding to the type of the formatted value.
>
> These changes are cosmetic only; no functional changes.
>
> Suggested-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Signed-off-by: Peter Colberg <peter.colberg@...el.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> drivers/fpga/dfl-afu-error.c | 7 +++----
> drivers/fpga/dfl-afu-main.c | 17 ++++++++---------
> drivers/fpga/dfl-fme-error.c | 19 ++++++++-----------
> drivers/fpga/dfl-fme-main.c | 26 ++++++++++----------------
> drivers/fpga/dfl-fme-perf.c | 16 +++++++---------
> drivers/fpga/dfl.c | 4 ++--
> drivers/fpga/fpga-bridge.c | 2 +-
> drivers/fpga/fpga-mgr.c | 4 ++--
> drivers/fpga/fpga-region.c | 5 ++---
> 9 files changed, 43 insertions(+), 57 deletions(-)
>
[...]
> diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
> index 7422d2bc6f37..1b072416069b 100644
> --- a/drivers/fpga/dfl-fme-perf.c
> +++ b/drivers/fpga/dfl-fme-perf.c
> @@ -524,20 +524,18 @@ static ssize_t fme_perf_event_show(struct device *dev,
> {
> struct dev_ext_attribute *eattr;
> unsigned long config;
> - char *ptr = buf;
>
> eattr = container_of(attr, struct dev_ext_attribute, attr);
> config = (unsigned long)eattr->var;
>
> - ptr += sprintf(ptr, "event=0x%02x", (unsigned int)get_event(config));
> - ptr += sprintf(ptr, ",evtype=0x%02x", (unsigned int)get_evtype(config));
> + if (!is_portid_root(get_portid(config)))
> + return sysfs_emit(buf,
> + "event=0x%02llx,evtype=0x%02llx,portid=?\n",
^ ^
why llx, should be lx?
> + get_event(config), get_evtype(config));
>
> - if (is_portid_root(get_portid(config)))
> - ptr += sprintf(ptr, ",portid=0x%02x\n", FME_PORTID_ROOT);
> - else
> - ptr += sprintf(ptr, ",portid=?\n");
> -
> - return (ssize_t)(ptr - buf);
> + return sysfs_emit(buf, "event=0x%02llx,evtype=0x%02llx,portid=0x%02x\n",
same
> + get_event(config), get_evtype(config),
> + FME_PORTID_ROOT);
BTW, have you ever tested with perf tool? The perf sysfs is a little
tricky to make perf work. I'm not sure everything is fine with naked
eyes.
Thanks,
Yilun
Powered by blists - more mailing lists