Commit 807d8add authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Paolo Abeni
Browse files

net: mdio: use macro __ATTR to simplify the code



Use macro __ATTR to simplify the code. Note that __ATTR can't be used
in MDIO_BUS_STATS_ADDR_ATTR_DECL because the included stringification
would conflict with how argument file is passed.

Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/4877a4dc-247c-4453-b281-20a8d969b15b@gmail.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 5c494f40
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -191,24 +191,17 @@ static ssize_t mdio_bus_device_stat_field_show(struct device *dev,
	return sysfs_emit(buf, "%llu\n", val);
}

#define MDIO_BUS_STATS_ATTR_DECL(field, file)				\
#define MDIO_BUS_STATS_ATTR(field)					\
static struct mdio_bus_stat_attr dev_attr_mdio_bus_##field = {		\
	.attr = { .attr = { .name = file, .mode = 0444 },		\
		     .show = mdio_bus_stat_field_show,			\
	},								\
	.attr = __ATTR(field, 0444, mdio_bus_stat_field_show, NULL),	\
	.address = -1,							\
	.field_offset = offsetof(struct mdio_bus_stats, field),		\
};									\
static struct mdio_bus_stat_attr dev_attr_mdio_bus_device_##field = {	\
	.attr = { .attr = { .name = file, .mode = 0444 },		\
		     .show = mdio_bus_device_stat_field_show,		\
	},								\
	.attr = __ATTR(field, 0444, mdio_bus_device_stat_field_show, NULL), \
	.address = -1,							\
	.field_offset = offsetof(struct mdio_bus_stats, field),		\
};

#define MDIO_BUS_STATS_ATTR(field)					\
	MDIO_BUS_STATS_ATTR_DECL(field, __stringify(field))
}

MDIO_BUS_STATS_ATTR(transfers);
MDIO_BUS_STATS_ATTR(errors);