Skip to content

Commit 6648c65

Browse files
shemmingerdavem330
authored andcommitted
net: style cleanups
Make code closer to current style. Mostly whitespace changes. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 667e427 commit 6648c65

File tree

1 file changed

+36
-32
lines changed

1 file changed

+36
-32
lines changed

net/core/net-sysfs.c

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
9797
return restart_syscall();
9898

9999
if (dev_isalive(netdev)) {
100-
if ((ret = (*set)(netdev, new)) == 0)
100+
ret = (*set)(netdev, new);
101+
if (ret == 0)
101102
ret = len;
102103
}
103104
rtnl_unlock();
@@ -160,6 +161,7 @@ static ssize_t broadcast_show(struct device *dev,
160161
struct device_attribute *attr, char *buf)
161162
{
162163
struct net_device *ndev = to_net_dev(dev);
164+
163165
if (dev_isalive(ndev))
164166
return sysfs_format_mac(buf, ndev->broadcast, ndev->addr_len);
165167
return -EINVAL;
@@ -170,7 +172,7 @@ static int change_carrier(struct net_device *dev, unsigned long new_carrier)
170172
{
171173
if (!netif_running(dev))
172174
return -EINVAL;
173-
return dev_change_carrier(dev, (bool) new_carrier);
175+
return dev_change_carrier(dev, (bool)new_carrier);
174176
}
175177

176178
static ssize_t carrier_store(struct device *dev, struct device_attribute *attr,
@@ -183,9 +185,10 @@ static ssize_t carrier_show(struct device *dev,
183185
struct device_attribute *attr, char *buf)
184186
{
185187
struct net_device *netdev = to_net_dev(dev);
186-
if (netif_running(netdev)) {
188+
189+
if (netif_running(netdev))
187190
return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
188-
}
191+
189192
return -EINVAL;
190193
}
191194
static DEVICE_ATTR_RW(carrier);
@@ -290,6 +293,7 @@ static ssize_t carrier_changes_show(struct device *dev,
290293
char *buf)
291294
{
292295
struct net_device *netdev = to_net_dev(dev);
296+
293297
return sprintf(buf, fmt_dec,
294298
atomic_read(&netdev->carrier_changes));
295299
}
@@ -299,7 +303,7 @@ static DEVICE_ATTR_RO(carrier_changes);
299303

300304
static int change_mtu(struct net_device *dev, unsigned long new_mtu)
301305
{
302-
return dev_set_mtu(dev, (int) new_mtu);
306+
return dev_set_mtu(dev, (int)new_mtu);
303307
}
304308

305309
static ssize_t mtu_store(struct device *dev, struct device_attribute *attr,
@@ -311,7 +315,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec);
311315

312316
static int change_flags(struct net_device *dev, unsigned long new_flags)
313317
{
314-
return dev_change_flags(dev, (unsigned int) new_flags);
318+
return dev_change_flags(dev, (unsigned int)new_flags);
315319
}
316320

317321
static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
@@ -362,8 +366,8 @@ static int change_gro_flush_timeout(struct net_device *dev, unsigned long val)
362366
}
363367

364368
static ssize_t gro_flush_timeout_store(struct device *dev,
365-
struct device_attribute *attr,
366-
const char *buf, size_t len)
369+
struct device_attribute *attr,
370+
const char *buf, size_t len)
367371
{
368372
if (!capable(CAP_NET_ADMIN))
369373
return -EPERM;
@@ -412,7 +416,7 @@ static DEVICE_ATTR_RW(ifalias);
412416

413417
static int change_group(struct net_device *dev, unsigned long new_group)
414418
{
415-
dev_set_group(dev, (int) new_group);
419+
dev_set_group(dev, (int)new_group);
416420
return 0;
417421
}
418422

@@ -426,7 +430,7 @@ static DEVICE_ATTR(netdev_group, S_IRUGO | S_IWUSR, group_show, group_store);
426430

427431
static int change_proto_down(struct net_device *dev, unsigned long proto_down)
428432
{
429-
return dev_change_proto_down(dev, (bool) proto_down);
433+
return dev_change_proto_down(dev, (bool)proto_down);
430434
}
431435

432436
static ssize_t proto_down_store(struct device *dev,
@@ -549,14 +553,14 @@ static ssize_t netstat_show(const struct device *d,
549553
ssize_t ret = -EINVAL;
550554

551555
WARN_ON(offset > sizeof(struct rtnl_link_stats64) ||
552-
offset % sizeof(u64) != 0);
556+
offset % sizeof(u64) != 0);
553557

554558
read_lock(&dev_base_lock);
555559
if (dev_isalive(dev)) {
556560
struct rtnl_link_stats64 temp;
557561
const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
558562

559-
ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *) stats) + offset));
563+
ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *)stats) + offset));
560564
}
561565
read_unlock(&dev_base_lock);
562566
return ret;
@@ -565,7 +569,7 @@ static ssize_t netstat_show(const struct device *d,
565569
/* generate a read-only statistics attribute */
566570
#define NETSTAT_ENTRY(name) \
567571
static ssize_t name##_show(struct device *d, \
568-
struct device_attribute *attr, char *buf) \
572+
struct device_attribute *attr, char *buf) \
569573
{ \
570574
return netstat_show(d, attr, buf, \
571575
offsetof(struct rtnl_link_stats64, name)); \
@@ -625,7 +629,6 @@ static struct attribute *netstat_attrs[] __ro_after_init = {
625629
NULL
626630
};
627631

628-
629632
static const struct attribute_group netstat_group = {
630633
.name = "statistics",
631634
.attrs = netstat_attrs,
@@ -647,8 +650,8 @@ static const struct attribute_group wireless_group = {
647650
#endif /* CONFIG_SYSFS */
648651

649652
#ifdef CONFIG_SYSFS
650-
#define to_rx_queue_attr(_attr) container_of(_attr, \
651-
struct rx_queue_attribute, attr)
653+
#define to_rx_queue_attr(_attr) \
654+
container_of(_attr, struct rx_queue_attribute, attr)
652655

653656
#define to_rx_queue(obj) container_of(obj, struct netdev_rx_queue, kobj)
654657

@@ -725,8 +728,8 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
725728
}
726729

727730
map = kzalloc(max_t(unsigned int,
728-
RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES),
729-
GFP_KERNEL);
731+
RPS_MAP_SIZE(cpumask_weight(mask)), L1_CACHE_BYTES),
732+
GFP_KERNEL);
730733
if (!map) {
731734
free_cpumask_var(mask);
732735
return -ENOMEM;
@@ -736,9 +739,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
736739
for_each_cpu_and(cpu, mask, cpu_online_mask)
737740
map->cpus[i++] = cpu;
738741

739-
if (i)
742+
if (i) {
740743
map->len = i;
741-
else {
744+
} else {
742745
kfree(map);
743746
map = NULL;
744747
}
@@ -827,8 +830,9 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
827830
table->mask = mask;
828831
for (count = 0; count <= mask; count++)
829832
table->flows[count].cpu = RPS_NO_CPU;
830-
} else
833+
} else {
831834
table = NULL;
835+
}
832836

833837
spin_lock(&rps_dev_flow_lock);
834838
old_table = rcu_dereference_protected(queue->rps_flow_table,
@@ -865,7 +869,6 @@ static void rx_queue_release(struct kobject *kobj)
865869
struct rps_map *map;
866870
struct rps_dev_flow_table *flow_table;
867871

868-
869872
map = rcu_dereference_protected(queue->rps_map, 1);
870873
if (map) {
871874
RCU_INIT_POINTER(queue->rps_map, NULL);
@@ -910,7 +913,7 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
910913

911914
kobj->kset = dev->queues_kset;
912915
error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL,
913-
"rx-%u", index);
916+
"rx-%u", index);
914917
if (error)
915918
return error;
916919

@@ -974,8 +977,8 @@ struct netdev_queue_attribute {
974977
ssize_t (*store)(struct netdev_queue *queue,
975978
const char *buf, size_t len);
976979
};
977-
#define to_netdev_queue_attr(_attr) container_of(_attr, \
978-
struct netdev_queue_attribute, attr)
980+
#define to_netdev_queue_attr(_attr) \
981+
container_of(_attr, struct netdev_queue_attribute, attr)
979982

980983
#define to_netdev_queue(obj) container_of(obj, struct netdev_queue, kobj)
981984

@@ -1104,9 +1107,9 @@ static ssize_t bql_set(const char *buf, const size_t count,
11041107
unsigned int value;
11051108
int err;
11061109

1107-
if (!strcmp(buf, "max") || !strcmp(buf, "max\n"))
1110+
if (!strcmp(buf, "max") || !strcmp(buf, "max\n")) {
11081111
value = DQL_MAX_LIMIT;
1109-
else {
1112+
} else {
11101113
err = kstrtouint(buf, 10, &value);
11111114
if (err < 0)
11121115
return err;
@@ -1320,7 +1323,7 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index)
13201323

13211324
kobj->kset = dev->queues_kset;
13221325
error = kobject_init_and_add(kobj, &netdev_queue_ktype, NULL,
1323-
"tx-%u", index);
1326+
"tx-%u", index);
13241327
if (error)
13251328
return error;
13261329

@@ -1377,7 +1380,7 @@ static int register_queue_kobjects(struct net_device *dev)
13771380

13781381
#ifdef CONFIG_SYSFS
13791382
dev->queues_kset = kset_create_and_add("queues",
1380-
NULL, &dev->dev.kobj);
1383+
NULL, &dev->dev.kobj);
13811384
if (!dev->queues_kset)
13821385
return -ENOMEM;
13831386
real_rx = dev->real_num_rx_queues;
@@ -1467,7 +1470,8 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
14671470

14681471
/* pass ifindex to uevent.
14691472
* ifindex is useful as it won't change (interface name may change)
1470-
* and is what RtNetlink uses natively. */
1473+
* and is what RtNetlink uses natively.
1474+
*/
14711475
retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex);
14721476

14731477
exit:
@@ -1542,7 +1546,7 @@ EXPORT_SYMBOL(of_find_net_device_by_node);
15421546
*/
15431547
void netdev_unregister_kobject(struct net_device *ndev)
15441548
{
1545-
struct device *dev = &(ndev->dev);
1549+
struct device *dev = &ndev->dev;
15461550

15471551
if (!atomic_read(&dev_net(ndev)->count))
15481552
dev_set_uevent_suppress(dev, 1);
@@ -1559,7 +1563,7 @@ void netdev_unregister_kobject(struct net_device *ndev)
15591563
/* Create sysfs entries for network device. */
15601564
int netdev_register_kobject(struct net_device *ndev)
15611565
{
1562-
struct device *dev = &(ndev->dev);
1566+
struct device *dev = &ndev->dev;
15631567
const struct attribute_group **groups = ndev->sysfs_groups;
15641568
int error = 0;
15651569

0 commit comments

Comments
 (0)