* [PATCH] rfkill: Use sysfs_emit() to instead of sprintf()
@ 2023-02-01 8:17 Bo Liu
2023-02-03 19:07 ` Simon Horman
0 siblings, 1 reply; 4+ messages in thread
From: Bo Liu @ 2023-02-01 8:17 UTC (permalink / raw)
To: johannes, davem, edumazet, kuba, pabeni
Cc: linux-wireless, netdev, linux-kernel, Bo Liu
Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.
Signed-off-by: Bo Liu <liubo03@inspur.com>
---
net/rfkill/core.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index b390ff245d5e..a103b2da4ed2 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -685,7 +685,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%s\n", rfkill->name);
+ return sysfs_emit(buf, "%s\n", rfkill->name);
}
static DEVICE_ATTR_RO(name);
@@ -694,7 +694,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%s\n", rfkill_types[rfkill->type]);
+ return sysfs_emit(buf, "%s\n", rfkill_types[rfkill->type]);
}
static DEVICE_ATTR_RO(type);
@@ -703,7 +703,7 @@ static ssize_t index_show(struct device *dev, struct device_attribute *attr,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%d\n", rfkill->idx);
+ return sysfs_emit(buf, "%d\n", rfkill->idx);
}
static DEVICE_ATTR_RO(index);
@@ -712,7 +712,7 @@ static ssize_t persistent_show(struct device *dev,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%d\n", rfkill->persistent);
+ return sysfs_emit(buf, "%d\n", rfkill->persistent);
}
static DEVICE_ATTR_RO(persistent);
@@ -721,7 +721,7 @@ static ssize_t hard_show(struct device *dev, struct device_attribute *attr,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 );
+ return sysfs_emit(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 );
}
static DEVICE_ATTR_RO(hard);
@@ -730,7 +730,7 @@ static ssize_t soft_show(struct device *dev, struct device_attribute *attr,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 );
+ return sysfs_emit(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 );
}
static ssize_t soft_store(struct device *dev, struct device_attribute *attr,
@@ -764,7 +764,7 @@ static ssize_t hard_block_reasons_show(struct device *dev,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "0x%lx\n", rfkill->hard_block_reasons);
+ return sysfs_emit(buf, "0x%lx\n", rfkill->hard_block_reasons);
}
static DEVICE_ATTR_RO(hard_block_reasons);
@@ -783,7 +783,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
{
struct rfkill *rfkill = to_rfkill(dev);
- return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state));
+ return sysfs_emit(buf, "%d\n", user_state_from_blocked(rfkill->state));
}
static ssize_t state_store(struct device *dev, struct device_attribute *attr,
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: Use sysfs_emit() to instead of sprintf()
2023-02-01 8:17 [PATCH] rfkill: Use sysfs_emit() to instead of sprintf() Bo Liu
@ 2023-02-03 19:07 ` Simon Horman
2023-02-07 15:09 ` Kalle Valo
0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2023-02-03 19:07 UTC (permalink / raw)
To: Bo Liu
Cc: johannes, davem, edumazet, kuba, pabeni, linux-wireless, netdev,
linux-kernel
Hi Bo Liu,
On Wed, Feb 01, 2023 at 03:17:18AM -0500, Bo Liu wrote:
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
Thanks for your patch. As it is not a bug fix it should be targeted at
'net-next' (as opposed to 'net'). This should be specified in the patch
subject something like this:
[PATCH net-next v2] rfkill: Use sysfs_emit() to instead of sprintf()
> Signed-off-by: Bo Liu <liubo03@inspur.com>
> ---
> net/rfkill/core.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index b390ff245d5e..a103b2da4ed2 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
...
> @@ -721,7 +721,7 @@ static ssize_t hard_show(struct device *dev, struct device_attribute *attr,
> {
> struct rfkill *rfkill = to_rfkill(dev);
>
> - return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 );
> + return sysfs_emit(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 );
return sysfs_emit(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0);
./scripts/checkpatch.pl complains that there should not be a space before
the last ')'.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: Use sysfs_emit() to instead of sprintf()
2023-02-03 19:07 ` Simon Horman
@ 2023-02-07 15:09 ` Kalle Valo
2023-02-07 16:07 ` Simon Horman
0 siblings, 1 reply; 4+ messages in thread
From: Kalle Valo @ 2023-02-07 15:09 UTC (permalink / raw)
To: Simon Horman
Cc: Bo Liu, johannes, davem, edumazet, kuba, pabeni, linux-wireless,
netdev, linux-kernel
Simon Horman <simon.horman@corigine.com> writes:
> Hi Bo Liu,
>
> On Wed, Feb 01, 2023 at 03:17:18AM -0500, Bo Liu wrote:
>> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
>> should only use sysfs_emit() or sysfs_emit_at() when formatting the
>> value to be returned to user space.
>
> Thanks for your patch. As it is not a bug fix it should be targeted at
> 'net-next' (as opposed to 'net'). This should be specified in the patch
> subject something like this:
>
> [PATCH net-next v2] rfkill: Use sysfs_emit() to instead of sprintf()
rfkill patches should go to wireless-next, right?
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rfkill: Use sysfs_emit() to instead of sprintf()
2023-02-07 15:09 ` Kalle Valo
@ 2023-02-07 16:07 ` Simon Horman
0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-02-07 16:07 UTC (permalink / raw)
To: Kalle Valo
Cc: Bo Liu, johannes, davem, edumazet, kuba, pabeni, linux-wireless,
netdev, linux-kernel
On Tue, Feb 07, 2023 at 05:09:02PM +0200, Kalle Valo wrote:
> Simon Horman <simon.horman@corigine.com> writes:
>
> > Hi Bo Liu,
> >
> > On Wed, Feb 01, 2023 at 03:17:18AM -0500, Bo Liu wrote:
> >> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> >> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> >> value to be returned to user space.
> >
> > Thanks for your patch. As it is not a bug fix it should be targeted at
> > 'net-next' (as opposed to 'net'). This should be specified in the patch
> > subject something like this:
> >
> > [PATCH net-next v2] rfkill: Use sysfs_emit() to instead of sprintf()
>
> rfkill patches should go to wireless-next, right?
Yes, my bad.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-07 16:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 8:17 [PATCH] rfkill: Use sysfs_emit() to instead of sprintf() Bo Liu
2023-02-03 19:07 ` Simon Horman
2023-02-07 15:09 ` Kalle Valo
2023-02-07 16:07 ` Simon Horman
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).