net: sysfs: cleanup coding style
Subsystems (2)
PATCH 1/1 net: sysfs: cleanup coding style
Replace DEVICE_ATTR() with DEVICE_ATTR_RW() where applicable to follow kernel coding style conventions. Add blank lines between function definitions and macro invocations. Fold multi-line attribute initializations onto single lines where it improves readability without exceeding the line length limit.
--- net/core/net-sysfs.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-)
net/core/net-sysfs.c +20 -23
@@ -494,6 +494,7 @@ static ssize_t mtu_store(struct device *dev, struct device_attribute *attr, {return netdev_store (dev, attr, buf, len, change_mtu); } +NETDEVICE_SHOW_RW (mtu, fmt_dec);static int change_flags (struct net_device *dev,unsigned long new_flags)
@@ -506,6 +507,7 @@ static ssize_t flags_store(struct device *dev, struct device_attribute *attr, {return netdev_store (dev, attr, buf, len, change_flags); } +NETDEVICE_SHOW_RW (flags, fmt_hex); static ssize_t tx_queue_len_store(struct device *dev,
@@ -517,6 +519,7 @@ static ssize_t tx_queue_len_store(struct device *dev,return netdev_store (dev, attr, buf, len, dev_change_tx_queue_len); } +NETDEVICE_SHOW_RW (tx_queue_len, fmt_dec);static int change_gro_flush_timeout (struct net_device *dev,unsigned long val)
@@ -534,6 +537,7 @@ static ssize_t gro_flush_timeout_store(struct device *dev,return netdev_lock_store (dev, attr, buf, len, change_gro_flush_timeout); } +NETDEVICE_SHOW_RW (gro_flush_timeout, fmt_ulong);static int change_napi_defer_hard_irqs (struct net_device *dev,unsigned long val)
@@ -555,6 +559,7 @@ static ssize_t napi_defer_hard_irqs_store(struct device *dev,return netdev_lock_store (dev, attr, buf, len, change_napi_defer_hard_irqs); } +NETDEVICE_SHOW_RW (napi_defer_hard_irqs, fmt_uint); static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
@@ -612,8 +617,9 @@ static ssize_t group_store(struct device *dev, struct device_attribute *attr, {return netdev_store (dev, attr, buf, len, change_group); } +NETDEVICE_SHOW (group, fmt_dec); -static DEVICE_ATTR(netdev_group, 0644, group_show, group_store); +static DEVICE_ATTR_RW (netdev_group);static int change_proto_down (struct net_device *dev,unsigned long proto_down) {
@@ -626,6 +632,7 @@ static ssize_t proto_down_store(struct device *dev, {return netdev_store (dev, attr, buf, len, change_proto_down); } +NETDEVICE_SHOW_RW (proto_down, fmt_dec); static ssize_t phys_port_id_show(struct device *dev,
@@ -1125,8 +1132,7 @@ static struct rx_queue_attribute rps_cpus_attribute __ro_after_init = __ATTR(rps_cpus, 0644, show_rps_map, store_rps_map);static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute__ro_after_init - =__ATTR (rps_flow_cnt,0644 , - show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt); + =__ATTR (rps_flow_cnt,0644 , show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt);#endif /* CONFIG_RPS */ static struct attribute *rx_queue_default_attrs[]__ro_after_init = {
@@ -1279,8 +1285,7 @@ static int rx_queue_change_owner(struct net_device *dev, int index, kuid_t kuid,return error;if (dev->sysfs_rx_queue_group) - error =sysfs_group_change_owner ( - kobj, dev->sysfs_rx_queue_group, kuid, kgid); + error =sysfs_group_change_owner (kobj, dev->sysfs_rx_queue_group, kuid, kgid);return error; }
@@ -1358,6 +1363,7 @@ struct netdev_queue_attribute { struct netdev_queue *queue, const char *buf, size_t len); }; +#define to_netdev_queue_attr (_attr) \ container_of(_attr, struct netdev_queue_attribute, attr)
@@ -1366,8 +1372,7 @@ struct netdev_queue_attribute {static ssize_t netdev_queue_attr_show (struct kobject *kobj,struct attribute *attr,char *buf) { -const struct netdev_queue_attribute *attribute - =to_netdev_queue_attr (attr); +const struct netdev_queue_attribute *attribute =to_netdev_queue_attr (attr);struct netdev_queue *queue =to_netdev_queue (kobj);if (!attribute->show)
@@ -1380,8 +1385,7 @@ static ssize_t netdev_queue_attr_store(struct kobject *kobj,struct attribute *attr, const char *buf, size_t count) { - const struct netdev_queue_attribute *attribute - =to_netdev_queue_attr (attr); + const struct netdev_queue_attribute *attribute = to_netdev_queue_attr(attr);struct netdev_queue *queue =to_netdev_queue (kobj);if (!attribute->store)
@@ -1499,15 +1503,12 @@ static ssize_t tx_maxrate_store(struct kobject *kobj, struct attribute *attr, return err; } -static struct netdev_queue_attribute queue_tx_maxrate__ro_after_init - =__ATTR_RW (tx_maxrate); +static struct netdev_queue_attribute queue_tx_maxrate__ro_after_init =__ATTR_RW (tx_maxrate);#endif -static struct netdev_queue_attribute queue_trans_timeout__ro_after_init - =__ATTR_RO (tx_timeout); +static struct netdev_queue_attribute queue_trans_timeout__ro_after_init =__ATTR_RO (tx_timeout); -static struct netdev_queue_attribute queue_traffic_class__ro_after_init - =__ATTR_RO (traffic_class); +static struct netdev_queue_attribute queue_traffic_class__ro_after_init =__ATTR_RO (traffic_class);#ifdef CONFIG_BQL /*
@@ -1565,8 +1566,7 @@ static ssize_t bql_set_hold_time(struct kobject *kobj, struct attribute *attr, }static struct netdev_queue_attribute bql_hold_time_attribute__ro_after_init - =__ATTR (hold_time,0644 , - bql_show_hold_time, bql_set_hold_time); + =__ATTR (hold_time,0644 , bql_show_hold_time, bql_set_hold_time);static ssize_t bql_show_stall_thrs (struct kobject *kobj,struct attribute *attr,struct netdev_queue *queue,char *buf)
@@ -1660,8 +1660,7 @@ static ssize_t bql_set_ ## NAME(struct kobject *kobj, \ } \ \ static struct netdev_queue_attribute bql_ ## NAME ## _attribute __ro_after_init \ - = __ATTR(NAME, 0644, \ - bql_show_ ## NAME, bql_set_ ## NAME) + = __ATTR(NAME, 0644, bql_show_ ## NAME, bql_set_ ## NAME)BQL_ATTR (limit, limit);BQL_ATTR (limit_max, max_limit);
@@ -1816,8 +1815,7 @@ static ssize_t xps_cpus_store(struct kobject *kobj, struct attribute *attr,return err ? : len; } -static struct netdev_queue_attribute xps_cpus_attribute__ro_after_init - =__ATTR_RW (xps_cpus); +static struct netdev_queue_attribute xps_cpus_attribute__ro_after_init =__ATTR_RW (xps_cpus);static ssize_t xps_rxqs_show (struct kobject *kobj,struct attribute *attr,struct netdev_queue *queue,char *buf)
@@ -1886,8 +1884,7 @@ static ssize_t xps_rxqs_store(struct kobject *kobj, struct attribute *attr,return err ? : len; } -static struct netdev_queue_attribute xps_rxqs_attribute__ro_after_init - =__ATTR_RW (xps_rxqs); +static struct netdev_queue_attribute xps_rxqs_attribute__ro_after_init =__ATTR_RW (xps_rxqs);#endif /* CONFIG_XPS */ static struct attribute *netdev_queue_default_attrs[]__ro_after_init = {
Signature · 1 line
2.53.0
Quoted 5 lines · Lucas Poupeau
Replace
DEVICE_ATTR()withDEVICE_ATTR_RW()where applicable to follow kernel coding style conventions. Add blank lines between function definitions and macro invocations. Fold multi-line attribute initializations onto single lines where it improves readability without exceeding the line length limit.
When you have a list like this, it means you should have a patch series, one patch per item on the list.
Please also take a read of
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
Andrew
---
pw-bot: cr
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Lucas,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
[also build test ERROR on net/main brauner-vfs/vfs.all linus/master v7.2-rc6 next-20260804] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lucas-Poupeau/net-sysfs-cleanup-coding-style/20260805-152318 base: net-next/main patch link: https://lore.kernel.org/r/20260628185824.231250-1-lucasp.linux%40gmail.com patch subject: [PATCH] net: sysfs: cleanup coding style config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20260805/[email protected]/config) compiler: alpha-linux-gcc (GCC) 16.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260805/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
In file included from include/linux/dma-mapping.h:5,
from include/linux/skbuff.h:28,
from include/net/net_namespace.h:44,
from include/linux/netdevice.h:38,
from net/core/net-sysfs.c:10:
>> net/core/net-sysfs.c:622:23: error: 'netdev_group_show' undeclared here (not in a function); did you mean 'netdev_show'?
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~
include/linux/device.h:173:36: note: in definition of macro '__DEVICE_ATTR_SHOW_STORE'
173 | .show = _Generic(_show, \
| ^~~~~
include/linux/device.h:201:9: note: in expansion of macro '__DEVICE_ATTR'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~~
include/linux/device.h:204:9: note: in expansion of macro '__DEVICE_ATTR_RW_MODE'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:52: note: in expansion of macro '__DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~
net/core/net-sysfs.c:622:8: note: in expansion of macro 'DEVICE_ATTR_RW'
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~
>> net/core/net-sysfs.c:622:23: error: 'netdev_group_store' undeclared here (not in a function); did you mean 'netdev_lock_store'?
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~
include/linux/device.h:177:36: note: in definition of macro '__DEVICE_ATTR_SHOW_STORE'
177 | .store = _Generic(_store, \
| ^~~~~~
include/linux/device.h:201:9: note: in expansion of macro '__DEVICE_ATTR'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~~
include/linux/device.h:204:9: note: in expansion of macro '__DEVICE_ATTR_RW_MODE'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:52: note: in expansion of macro '__DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~
net/core/net-sysfs.c:622:8: note: in expansion of macro 'DEVICE_ATTR_RW'
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~
>> net/core/net-sysfs.c:621:16: warning: 'group_show' defined but not used [-Wunused-function]
621 | NETDEVICE_SHOW(group, fmt_dec);
| ^~~~~
net/core/net-sysfs.c:143:16: note: in definition of macro 'NETDEVICE_SHOW'
143 | static ssize_t field##_show(struct device *dev, \
| ^~~~~
>> net/core/net-sysfs.c:615:16: warning: 'group_store' defined but not used [-Wunused-function] 615 | static ssize_t group_store(struct device *dev, struct device_attribute *attr,
| ^~~~~~~~~~~
vim +622 net/core/net-sysfs.c
614
> 615 static ssize_t group_store(struct device *dev, struct device_attribute *attr,
616 const char *buf, size_t len)
617 {
618 return netdev_store(dev, attr, buf, len, change_group);
619 }
620
> 621 NETDEVICE_SHOW(group, fmt_dec);
> 622 static DEVICE_ATTR_RW(netdev_group);623
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Lucas,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
[also build test ERROR on net/main brauner-vfs/vfs.all linus/master v7.2-rc6 next-20260805] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lucas-Poupeau/net-sysfs-cleanup-coding-style/20260805-152318 base: net-next/main patch link: https://lore.kernel.org/r/20260628185824.231250-1-lucasp.linux%40gmail.com patch subject: [PATCH] net: sysfs: cleanup coding style config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260805/[email protected]/config) compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260805/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> net/core/net-sysfs.c:622:8: error: use of undeclared identifier 'netdev_group_show'
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:45: note: expanded from macro 'DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:204:2: note: expanded from macro '__DEVICE_ATTR_RW'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:201:30: note: expanded from macro '__DEVICE_ATTR_RW_MODE'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~
<scratch space>:22:1: note: expanded from here
22 | netdev_group_show
| ^~~~~~~~~~~~~~~~~
>> net/core/net-sysfs.c:622:8: error: use of undeclared identifier 'netdev_group_store'; did you mean 'netdev_lock_store'?
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:45: note: expanded from macro 'DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:204:2: note: expanded from macro '__DEVICE_ATTR_RW'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:201:44: note: expanded from macro '__DEVICE_ATTR_RW_MODE'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~~
<scratch space>:23:1: note: expanded from here
23 | netdev_group_store
| ^~~~~~~~~~~~~~~~~~
net/core/net-sysfs.c:189:1: note: 'netdev_lock_store' declared here
189 | netdev_lock_store(struct device *dev, struct device_attribute *attr,
| ^
net/core/net-sysfs.c:622:8: error: use of undeclared identifier 'netdev_group_store'
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:45: note: expanded from macro 'DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:204:2: note: expanded from macro '__DEVICE_ATTR_RW'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:201:44: note: expanded from macro '__DEVICE_ATTR_RW_MODE'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~~ <scratch space>:23:1: note: expanded from here
23 | netdev_group_store
| ^~~~~~~~~~~~~~~~~~
3 errors generated.
vim +/netdev_group_show +622 net/core/net-sysfs.c
620
621 NETDEVICE_SHOW(group, fmt_dec);
> 622 static DEVICE_ATTR_RW(netdev_group);
623
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Lucas,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
[also build test ERROR on net/main brauner-vfs/vfs.all linus/master v7.2-rc6 next-20260805] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Lucas-Poupeau/net-sysfs-cleanup-coding-style/20260805-152318 base: net-next/main patch link: https://lore.kernel.org/r/20260628185824.231250-1-lucasp.linux%40gmail.com patch subject: [PATCH] net: sysfs: cleanup coding style config: x86_64-kexec (https://download.01.org/0day-ci/archive/20260806/[email protected]/config) compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260806/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> net/core/net-sysfs.c:622:8: error: use of undeclared identifier 'netdev_group_show'
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:45: note: expanded from macro 'DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:204:2: note: expanded from macro '__DEVICE_ATTR_RW'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:201:30: note: expanded from macro '__DEVICE_ATTR_RW_MODE'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~
<scratch space>:22:1: note: expanded from here
22 | netdev_group_show
| ^~~~~~~~~~~~~~~~~
>> net/core/net-sysfs.c:622:8: error: use of undeclared identifier 'netdev_group_store'; did you mean 'netdev_lock_store'?
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:45: note: expanded from macro 'DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:204:2: note: expanded from macro '__DEVICE_ATTR_RW'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:201:44: note: expanded from macro '__DEVICE_ATTR_RW_MODE'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~~
<scratch space>:23:1: note: expanded from here
23 | netdev_group_store
| ^~~~~~~~~~~~~~~~~~
net/core/net-sysfs.c:189:1: note: 'netdev_lock_store' declared here
189 | netdev_lock_store(struct device *dev, struct device_attribute *attr,
| ^
net/core/net-sysfs.c:622:8: error: use of undeclared identifier 'netdev_group_store'
622 | static DEVICE_ATTR_RW(netdev_group);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:246:45: note: expanded from macro 'DEVICE_ATTR_RW'
246 | struct device_attribute dev_attr_##_name = __DEVICE_ATTR_RW(_name)
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:204:2: note: expanded from macro '__DEVICE_ATTR_RW'
204 | __DEVICE_ATTR_RW_MODE(_name, 0644)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:201:44: note: expanded from macro '__DEVICE_ATTR_RW_MODE'
201 | __DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
| ^~~~~~~~~~~~~ <scratch space>:23:1: note: expanded from here
23 | netdev_group_store
| ^~~~~~~~~~~~~~~~~~
3 errors generated.
vim +/netdev_group_show +622 net/core/net-sysfs.c
620
621 NETDEVICE_SHOW(group, fmt_dec);
> 622 static DEVICE_ATTR_RW(netdev_group);
623
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki