lkml.org 
[lkml]   [2023]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] iommu: Use sysfs_emit() for sysfs show
On Wed, Mar 22, 2023 at 08:34:21PM +0800, Lu Baolu wrote:
> Use sysfs_emit() instead of the sprintf() for sysfs entries. sysfs_emit()
> knows the maximum of the temporary buffer used for outputting sysfs
> content and avoids overrunning the buffer length.
>
> Prefer 'long long' over 'long long int' as suggested by checkpatch.pl.
>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> drivers/iommu/amd/init.c | 4 ++--
> drivers/iommu/intel/iommu.c | 17 +++++++++--------
> drivers/iommu/iommu.c | 31 +++++++++++++++----------------
> 3 files changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index 19a46b9f7357..a98202018140 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -1941,7 +1941,7 @@ static ssize_t amd_iommu_show_cap(struct device *dev,
> char *buf)
> {
> struct amd_iommu *iommu = dev_to_amd_iommu(dev);
> - return sprintf(buf, "%x\n", iommu->cap);
> + return sysfs_emit(buf, "%x\n", iommu->cap);
> }

It would be nice to add the missing whitespace after declarations here
and other places to follow the coding convention

The conversions look OK though

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason

\
 
 \ /
  Last update: 2023-03-27 01:12    [W:0.027 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site