* Re: [net-next] net: bonding: Convert to use sysfs_emit() APIs
2022-09-28 11:40 [net-next] net: bonding: Convert to use sysfs_emit() APIs Wang Yufen
@ 2022-09-28 11:27 ` Nikolay Aleksandrov
2022-09-28 11:38 ` wangyufen
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Aleksandrov @ 2022-09-28 11:27 UTC (permalink / raw)
To: Wang Yufen, j.vosburgh, vfalico, andy, davem, edumazet, kuba, pabeni
Cc: netdev
On 28/09/2022 14:40, Wang Yufen 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.
>
> Signed-off-by: Wang Yufen <wangyufen@huawei.com>
> ---
> drivers/net/bonding/bond_sysfs_slave.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
This converts only the bonding partially (bond_sysfs_slave.c).
Why not do it all in one go?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [net-next] net: bonding: Convert to use sysfs_emit() APIs
2022-09-28 11:27 ` Nikolay Aleksandrov
@ 2022-09-28 11:38 ` wangyufen
0 siblings, 0 replies; 3+ messages in thread
From: wangyufen @ 2022-09-28 11:38 UTC (permalink / raw)
To: Nikolay Aleksandrov, j.vosburgh, vfalico, andy, davem, edumazet,
kuba, pabeni
Cc: netdev
在 2022/9/28 19:27, Nikolay Aleksandrov 写道:
> On 28/09/2022 14:40, Wang Yufen 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.
>>
>> Signed-off-by: Wang Yufen <wangyufen@huawei.com>
>> ---
>> drivers/net/bonding/bond_sysfs_slave.c | 24 ++++++++++++------------
>> 1 file changed, 12 insertions(+), 12 deletions(-)
>>
> This converts only the bonding partially (bond_sysfs_slave.c).
> Why not do it all in one go?
>
Sorry, my mistake, I missed a place and bond_sysfs.c will send v2 together.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [net-next] net: bonding: Convert to use sysfs_emit() APIs
@ 2022-09-28 11:40 Wang Yufen
2022-09-28 11:27 ` Nikolay Aleksandrov
0 siblings, 1 reply; 3+ messages in thread
From: Wang Yufen @ 2022-09-28 11:40 UTC (permalink / raw)
To: j.vosburgh, vfalico, andy, davem, edumazet, kuba, pabeni; +Cc: netdev
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: Wang Yufen <wangyufen@huawei.com>
---
drivers/net/bonding/bond_sysfs_slave.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
index 69b0a37..6cc53d2 100644
--- a/drivers/net/bonding/bond_sysfs_slave.c
+++ b/drivers/net/bonding/bond_sysfs_slave.c
@@ -22,30 +22,30 @@ static ssize_t state_show(struct slave *slave, char *buf)
{
switch (bond_slave_state(slave)) {
case BOND_STATE_ACTIVE:
- return sprintf(buf, "active\n");
+ return sysfs_emit(buf, "active\n");
case BOND_STATE_BACKUP:
- return sprintf(buf, "backup\n");
+ return sysfs_emit(buf, "backup\n");
default:
- return sprintf(buf, "UNKNOWN\n");
+ return sysfs_emit(buf, "UNKNOWN\n");
}
}
static SLAVE_ATTR_RO(state);
static ssize_t mii_status_show(struct slave *slave, char *buf)
{
- return sprintf(buf, "%s\n", bond_slave_link_status(slave->link));
+ return sysfs_emit(buf, "%s\n", bond_slave_link_status(slave->link));
}
static SLAVE_ATTR_RO(mii_status);
static ssize_t link_failure_count_show(struct slave *slave, char *buf)
{
- return sprintf(buf, "%d\n", slave->link_failure_count);
+ return sysfs_emit(buf, "%d\n", slave->link_failure_count);
}
static SLAVE_ATTR_RO(link_failure_count);
static ssize_t perm_hwaddr_show(struct slave *slave, char *buf)
{
- return sprintf(buf, "%*phC\n",
+ return sysfs_emit(buf, "%*phC\n",
slave->dev->addr_len,
slave->perm_hwaddr);
}
@@ -53,7 +53,7 @@ static ssize_t perm_hwaddr_show(struct slave *slave, char *buf)
static ssize_t queue_id_show(struct slave *slave, char *buf)
{
- return sprintf(buf, "%d\n", slave->queue_id);
+ return sysfs_emit(buf, "%d\n", slave->queue_id);
}
static SLAVE_ATTR_RO(queue_id);
@@ -68,7 +68,7 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
agg->aggregator_identifier);
}
- return sprintf(buf, "N/A\n");
+ return sysfs_emit(buf, "N/A\n");
}
static SLAVE_ATTR_RO(ad_aggregator_id);
@@ -79,11 +79,11 @@ static ssize_t ad_actor_oper_port_state_show(struct slave *slave, char *buf)
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
ad_port = &SLAVE_AD_INFO(slave)->port;
if (ad_port->aggregator)
- return sprintf(buf, "%u\n",
+ return sysfs_emit(buf, "%u\n",
ad_port->actor_oper_port_state);
}
- return sprintf(buf, "N/A\n");
+ return sysfs_emit(buf, "N/A\n");
}
static SLAVE_ATTR_RO(ad_actor_oper_port_state);
@@ -94,11 +94,11 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf)
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
ad_port = &SLAVE_AD_INFO(slave)->port;
if (ad_port->aggregator)
- return sprintf(buf, "%u\n",
+ return sysfs_emit(buf, "%u\n",
ad_port->partner_oper.port_state);
}
- return sprintf(buf, "N/A\n");
+ return sysfs_emit(buf, "N/A\n");
}
static SLAVE_ATTR_RO(ad_partner_oper_port_state);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-28 11:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 11:40 [net-next] net: bonding: Convert to use sysfs_emit() APIs Wang Yufen
2022-09-28 11:27 ` Nikolay Aleksandrov
2022-09-28 11:38 ` wangyufen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.