Re: [PATCH 1/2] fpga: dfl: use sysfs_emit() to format sysfs values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux