diff mbox series

[net-next,v2,1/4] s390/lcs: Convert sysfs sprintf to sysfs_emit

Message ID 20230621134921.904217-2-wintera@linux.ibm.com (mailing list archive)
State Accepted
Commit d3f0c7fa09932d34bbf5548a156316927a099f25
Delegated to: Netdev Maintainers
Headers show
Series s390/net: updates 2023-06-10 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 5 maintainers not CCed: borntraeger@linux.ibm.com gor@linux.ibm.com wenjia@linux.ibm.com agordeev@linux.ibm.com svens@linux.ibm.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Alexandra Winter June 21, 2023, 1:49 p.m. UTC
From: Thorsten Winkler <twinkler@linux.ibm.com>

Following the advice of the Documentation/filesystems/sysfs.rst.
All sysfs related show()-functions should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

While at it, follow Linux kernel coding style and unify indentation

Reported-by: Jules Irenge <jbi.octave@gmail.com>
Reported-by: Joe Perches <joe@perches.com>
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Thorsten Winkler <twinkler@linux.ibm.com>
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
---
 drivers/s390/net/lcs.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Joe Perches June 27, 2023, 5:09 a.m. UTC | #1
On Wed, 2023-06-21 at 15:49 +0200, Alexandra Winter wrote:
> From: Thorsten Winkler <twinkler@linux.ibm.com>
> 
> Following the advice of the Documentation/filesystems/sysfs.rst.
> All sysfs related show()-functions should only use sysfs_emit() or
> sysfs_emit_at() when formatting the value to be returned to user space.
> 
> While at it, follow Linux kernel coding style and unify indentation
[]
> diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
[]
> @@ -1901,14 +1901,14 @@ lcs_open_device(struct net_device *dev)
>  static ssize_t
>  lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
>  {
> -        struct lcs_card *card;
> +	struct lcs_card *card;
>  
>  	card = dev_get_drvdata(dev);
>  
> -        if (!card)
> -                return 0;
> +	if (!card)
> +		return 0;
>  
> -        return sprintf(buf, "%d\n", card->portno);
> +	return sysfs_emit(buf, "%d\n", card->portno);
[]
> @@ -1970,7 +1971,7 @@ lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
>  
>  	card = dev_get_drvdata(dev);
>  
> -	return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
> +	return card ? sysfs_emit(buf, "%u\n", card->lancmd_timeout) : 0;

Like the other show function
I think it'd be nicer to use:

	card = dev_get_drvdata(dev);
	if (!card)
		return 0;

	return sysfs_emit(buf, "%u\n", card->lancmd_timeout);
diff mbox series

Patch

diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 84c8981317b4..bd3d788e5f2d 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1901,14 +1901,14 @@  lcs_open_device(struct net_device *dev)
 static ssize_t
 lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
 {
-        struct lcs_card *card;
+	struct lcs_card *card;
 
 	card = dev_get_drvdata(dev);
 
-        if (!card)
-                return 0;
+	if (!card)
+		return 0;
 
-        return sprintf(buf, "%d\n", card->portno);
+	return sysfs_emit(buf, "%d\n", card->portno);
 }
 
 /*
@@ -1958,7 +1958,8 @@  lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
 	if (!cgdev)
 		return -ENODEV;
 
-	return sprintf(buf, "%s\n", lcs_type[cgdev->cdev[0]->id.driver_info]);
+	return sysfs_emit(buf, "%s\n",
+			  lcs_type[cgdev->cdev[0]->id.driver_info]);
 }
 
 static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
@@ -1970,7 +1971,7 @@  lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 	card = dev_get_drvdata(dev);
 
-	return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0;
+	return card ? sysfs_emit(buf, "%u\n", card->lancmd_timeout) : 0;
 }
 
 static ssize_t