2022-03-07 08:00:59

by Lianjie Zhang

[permalink] [raw]
Subject: [PATCH v2] bonding: helper macro __ATTR_RO to make code more clear

From: zhanglianjie <[email protected]>

Delete SLAVE_ATTR macro, use __ATTR_RO replacement,
make code logic clearer and unified.

Signed-off-by: Lianjie Zhang <[email protected]>
Reviewed-by: Jay Vosburgh <[email protected]>

diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
index 6a6cdd0bb258..69b0a3751dff 100644
--- a/drivers/net/bonding/bond_sysfs_slave.c
+++ b/drivers/net/bonding/bond_sysfs_slave.c
@@ -15,14 +15,8 @@ struct slave_attribute {
ssize_t (*show)(struct slave *, char *);
};

-#define SLAVE_ATTR(_name, _mode, _show) \
-const struct slave_attribute slave_attr_##_name = { \
- .attr = {.name = __stringify(_name), \
- .mode = _mode }, \
- .show = _show, \
-};
#define SLAVE_ATTR_RO(_name) \
- SLAVE_ATTR(_name, 0444, _name##_show)
+const struct slave_attribute slave_attr_##_name = __ATTR_RO(_name)

static ssize_t state_show(struct slave *slave, char *buf)
{
--
2.20.1




2022-03-08 23:32:12

by Jay Vosburgh

[permalink] [raw]
Subject: Re: [PATCH v2] bonding: helper macro __ATTR_RO to make code more clear

Lianjie Zhang <[email protected]> wrote:

>From: zhanglianjie <[email protected]>
>
>Delete SLAVE_ATTR macro, use __ATTR_RO replacement,
>make code logic clearer and unified.
>
>Signed-off-by: Lianjie Zhang <[email protected]>
>Reviewed-by: Jay Vosburgh <[email protected]>

Please do not add tags that individuals do not explicitly
provide.

Other than the above, the change seems fine.

Acked-by: Jay Vosburgh <[email protected]>

-J

>diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
>index 6a6cdd0bb258..69b0a3751dff 100644
>--- a/drivers/net/bonding/bond_sysfs_slave.c
>+++ b/drivers/net/bonding/bond_sysfs_slave.c
>@@ -15,14 +15,8 @@ struct slave_attribute {
> ssize_t (*show)(struct slave *, char *);
> };
>
>-#define SLAVE_ATTR(_name, _mode, _show) \
>-const struct slave_attribute slave_attr_##_name = { \
>- .attr = {.name = __stringify(_name), \
>- .mode = _mode }, \
>- .show = _show, \
>-};
> #define SLAVE_ATTR_RO(_name) \
>- SLAVE_ATTR(_name, 0444, _name##_show)
>+const struct slave_attribute slave_attr_##_name = __ATTR_RO(_name)
>
> static ssize_t state_show(struct slave *slave, char *buf)
> {
>--
>2.20.1

---
-Jay Vosburgh, [email protected]