Linux-FPGA Archive mirror
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@intel.com>
To: Peter Colberg <peter.colberg@intel.com>
Cc: Wu Hao <hao.wu@intel.com>, Tom Rix <trix@redhat.com>,
	Moritz Fischer <mdf@kernel.org>,
	linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	tianfei.zhang@intel.com, russell.h.weight@intel.com,
	matthew.gerlach@linux.intel.com, marpagan@redhat.com,
	lgoncalv@redhat.com
Subject: Re: [PATCH 1/2] fpga: dfl: use sysfs_emit() to format sysfs values
Date: Mon, 10 Jul 2023 15:45:52 +0800	[thread overview]
Message-ID: <ZKu3MIfEyIBqg2g1@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <a80ad13ad82ff294e706bb87e5b62793c5d195f5.1687301688.git.peter.colberg@intel.com>

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@linux.intel.com>
> Signed-off-by: Peter Colberg <peter.colberg@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.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


  reply	other threads:[~2023-07-10  7:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05  2:54 [PATCH 0/2] fpga: dfl: clean up string formatting for sysfs_emit() and dev_dbg() Peter Colberg
2023-07-05  2:54 ` [PATCH 1/2] fpga: dfl: use sysfs_emit() to format sysfs values Peter Colberg
2023-07-10  7:45   ` Xu Yilun [this message]
2023-07-05  2:54 ` [PATCH 2/2] fpga: dfl: omit unneeded casts of u64 values for dev_dbg() Peter Colberg

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=ZKu3MIfEyIBqg2g1@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hao.wu@intel.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marpagan@redhat.com \
    --cc=matthew.gerlach@linux.intel.com \
    --cc=mdf@kernel.org \
    --cc=peter.colberg@intel.com \
    --cc=russell.h.weight@intel.com \
    --cc=tianfei.zhang@intel.com \
    --cc=trix@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).