* [PATCH] cpuidle: sysfs: fix coding style issue
@ 2025-08-24 17:15 vivekyadav1207731111
2025-08-24 17:50 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: vivekyadav1207731111 @ 2025-08-24 17:15 UTC (permalink / raw)
To: daniel.lezcano, rafael; +Cc: linux-kernel, linux-pm, Vivek Yadav
From: Vivek Yadav <vivekyadav1207731111@gmail.com>
Fix a checkpatch.pl error by adding space around '+='
operator.
No functional changes intended.
[checkpatch.pl output]
ERROR: spaces required around that '+='
Signed-off-by: Vivek Yadav <vivekyadav1207731111@gmail.com>
---
drivers/cpuidle/sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index d6f5da61cb7d..cbf2e021c6ba 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -34,7 +34,7 @@ static ssize_t show_available_governors(struct device *dev,
}
out:
- i+= sprintf(&buf[i], "\n");
+ i += sprintf(&buf[i], "\n");
mutex_unlock(&cpuidle_lock);
return i;
}
---
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cpuidle: sysfs: fix coding style issue
2025-08-24 17:15 [PATCH] cpuidle: sysfs: fix coding style issue vivekyadav1207731111
@ 2025-08-24 17:50 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2025-08-24 17:50 UTC (permalink / raw)
To: vivekyadav1207731111, daniel.lezcano, rafael; +Cc: linux-kernel, linux-pm
On Sun, 2025-08-24 at 10:15 -0700, vivekyadav1207731111@gmail.com wrote:
> From: Vivek Yadav <vivekyadav1207731111@gmail.com>
>
> Fix a checkpatch.pl error by adding space around '+='
> operator.
>
> No functional changes intended.
>
> [checkpatch.pl output]
> ERROR: spaces required around that '+='
Perhaps better to convert all sprintf style uses
to sysfs_emit and sysfs_emit_at
> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
[]
> @@ -34,7 +34,7 @@ static ssize_t show_available_governors(struct device *dev,
> }
>
> out:
> - i+= sprintf(&buf[i], "\n");
> + i += sprintf(&buf[i], "\n");
> mutex_unlock(&cpuidle_lock);
> return i;
> }
Something akin to:
---
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index d6f5da61cb7d8..3adb98c9986fd 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -22,21 +22,19 @@ static ssize_t show_available_governors(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- ssize_t i = 0;
+ ssize_t len = 0;
struct cpuidle_governor *tmp;
mutex_lock(&cpuidle_lock);
- list_for_each_entry(tmp, &cpuidle_governors, governor_list) {
- if (i >= (ssize_t) (PAGE_SIZE - (CPUIDLE_NAME_LEN + 2)))
- goto out;
- i += scnprintf(&buf[i], CPUIDLE_NAME_LEN + 1, "%s ", tmp->name);
- }
+ list_for_each_entry(tmp, &cpuidle_governors, governor_list)
+ len += sysfs_emit_at(buf, len, "%s%s",
+ len > 0 ? " " : "", tmp->name);
+ len += sysfs_emit_at(buf, len, "\n");
-out:
- i+= sprintf(&buf[i], "\n");
mutex_unlock(&cpuidle_lock);
- return i;
+
+ return len;
}
static ssize_t show_current_driver(struct device *dev,
---
etc...
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-24 17:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-24 17:15 [PATCH] cpuidle: sysfs: fix coding style issue vivekyadav1207731111
2025-08-24 17:50 ` Joe Perches
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 NNTP newsgroup(s).