Commit 6648c65e authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

net: style cleanups

Make code closer to current style. Mostly whitespace changes.
Signed-off-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 667e427b
...@@ -97,7 +97,8 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr, ...@@ -97,7 +97,8 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
return restart_syscall(); return restart_syscall();
if (dev_isalive(netdev)) { if (dev_isalive(netdev)) {
if ((ret = (*set)(netdev, new)) == 0) ret = (*set)(netdev, new);
if (ret == 0)
ret = len; ret = len;
} }
rtnl_unlock(); rtnl_unlock();
...@@ -160,6 +161,7 @@ static ssize_t broadcast_show(struct device *dev, ...@@ -160,6 +161,7 @@ static ssize_t broadcast_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct net_device *ndev = to_net_dev(dev); struct net_device *ndev = to_net_dev(dev);
if (dev_isalive(ndev)) if (dev_isalive(ndev))
return sysfs_format_mac(buf, ndev->broadcast, ndev->addr_len); return sysfs_format_mac(buf, ndev->broadcast, ndev->addr_len);
return -EINVAL; return -EINVAL;
...@@ -170,7 +172,7 @@ static int change_carrier(struct net_device *dev, unsigned long new_carrier) ...@@ -170,7 +172,7 @@ static int change_carrier(struct net_device *dev, unsigned long new_carrier)
{ {
if (!netif_running(dev)) if (!netif_running(dev))
return -EINVAL; return -EINVAL;
return dev_change_carrier(dev, (bool) new_carrier); return dev_change_carrier(dev, (bool)new_carrier);
} }
static ssize_t carrier_store(struct device *dev, struct device_attribute *attr, static ssize_t carrier_store(struct device *dev, struct device_attribute *attr,
...@@ -183,9 +185,10 @@ static ssize_t carrier_show(struct device *dev, ...@@ -183,9 +185,10 @@ static ssize_t carrier_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct net_device *netdev = to_net_dev(dev); struct net_device *netdev = to_net_dev(dev);
if (netif_running(netdev)) {
if (netif_running(netdev))
return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev)); return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
}
return -EINVAL; return -EINVAL;
} }
static DEVICE_ATTR_RW(carrier); static DEVICE_ATTR_RW(carrier);
...@@ -290,6 +293,7 @@ static ssize_t carrier_changes_show(struct device *dev, ...@@ -290,6 +293,7 @@ static ssize_t carrier_changes_show(struct device *dev,
char *buf) char *buf)
{ {
struct net_device *netdev = to_net_dev(dev); struct net_device *netdev = to_net_dev(dev);
return sprintf(buf, fmt_dec, return sprintf(buf, fmt_dec,
atomic_read(&netdev->carrier_changes)); atomic_read(&netdev->carrier_changes));
} }
...@@ -299,7 +303,7 @@ static DEVICE_ATTR_RO(carrier_changes); ...@@ -299,7 +303,7 @@ static DEVICE_ATTR_RO(carrier_changes);
static int change_mtu(struct net_device *dev, unsigned long new_mtu) static int change_mtu(struct net_device *dev, unsigned long new_mtu)
{ {
return dev_set_mtu(dev, (int) new_mtu); return dev_set_mtu(dev, (int)new_mtu);
} }
static ssize_t mtu_store(struct device *dev, struct device_attribute *attr, static ssize_t mtu_store(struct device *dev, struct device_attribute *attr,
...@@ -311,7 +315,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec); ...@@ -311,7 +315,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec);
static int change_flags(struct net_device *dev, unsigned long new_flags) static int change_flags(struct net_device *dev, unsigned long new_flags)
{ {
return dev_change_flags(dev, (unsigned int) new_flags); return dev_change_flags(dev, (unsigned int)new_flags);
} }
static ssize_t flags_store(struct device *dev, struct device_attribute *attr, static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
...@@ -412,7 +416,7 @@ static DEVICE_ATTR_RW(ifalias); ...@@ -412,7 +416,7 @@ static DEVICE_ATTR_RW(ifalias);
static int change_group(struct net_device *dev, unsigned long new_group) static int change_group(struct net_device *dev, unsigned long new_group)
{ {
dev_set_group(dev, (int) new_group); dev_set_group(dev, (int)new_group);
return 0; return 0;
} }
...@@ -426,7 +430,7 @@ static DEVICE_ATTR(netdev_group, S_IRUGO | S_IWUSR, group_show, group_store); ...@@ -426,7 +430,7 @@ static DEVICE_ATTR(netdev_group, S_IRUGO | S_IWUSR, group_show, group_store);
static int change_proto_down(struct net_device *dev, unsigned long proto_down) static int change_proto_down(struct net_device *dev, unsigned long proto_down)
{ {
return dev_change_proto_down(dev, (bool) proto_down); return dev_change_proto_down(dev, (bool)proto_down);
} }
static ssize_t proto_down_store(struct device *dev, static ssize_t proto_down_store(struct device *dev,
...@@ -556,7 +560,7 @@ static ssize_t netstat_show(const struct device *d, ...@@ -556,7 +560,7 @@ static ssize_t netstat_show(const struct device *d,
struct rtnl_link_stats64 temp; struct rtnl_link_stats64 temp;
const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp); const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *) stats) + offset)); ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *)stats) + offset));
} }
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
return ret; return ret;
...@@ -625,7 +629,6 @@ static struct attribute *netstat_attrs[] __ro_after_init = { ...@@ -625,7 +629,6 @@ static struct attribute *netstat_attrs[] __ro_after_init = {
NULL NULL
}; };
static const struct attribute_group netstat_group = { static const struct attribute_group netstat_group = {
.name = "statistics", .name = "statistics",
.attrs = netstat_attrs, .attrs = netstat_attrs,
...@@ -647,8 +650,8 @@ static const struct attribute_group wireless_group = { ...@@ -647,8 +650,8 @@ static const struct attribute_group wireless_group = {
#endif /* CONFIG_SYSFS */ #endif /* CONFIG_SYSFS */
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
#define to_rx_queue_attr(_attr) container_of(_attr, \ #define to_rx_queue_attr(_attr) \
struct rx_queue_attribute, attr) container_of(_attr, struct rx_queue_attribute, attr)
#define to_rx_queue(obj) container_of(obj, struct netdev_rx_queue, kobj) #define to_rx_queue(obj) container_of(obj, struct netdev_rx_queue, kobj)
...@@ -736,9 +739,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, ...@@ -736,9 +739,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
for_each_cpu_and(cpu, mask, cpu_online_mask) for_each_cpu_and(cpu, mask, cpu_online_mask)
map->cpus[i++] = cpu; map->cpus[i++] = cpu;
if (i) if (i) {
map->len = i; map->len = i;
else { } else {
kfree(map); kfree(map);
map = NULL; map = NULL;
} }
...@@ -827,8 +830,9 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue, ...@@ -827,8 +830,9 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
table->mask = mask; table->mask = mask;
for (count = 0; count <= mask; count++) for (count = 0; count <= mask; count++)
table->flows[count].cpu = RPS_NO_CPU; table->flows[count].cpu = RPS_NO_CPU;
} else } else {
table = NULL; table = NULL;
}
spin_lock(&rps_dev_flow_lock); spin_lock(&rps_dev_flow_lock);
old_table = rcu_dereference_protected(queue->rps_flow_table, old_table = rcu_dereference_protected(queue->rps_flow_table,
...@@ -865,7 +869,6 @@ static void rx_queue_release(struct kobject *kobj) ...@@ -865,7 +869,6 @@ static void rx_queue_release(struct kobject *kobj)
struct rps_map *map; struct rps_map *map;
struct rps_dev_flow_table *flow_table; struct rps_dev_flow_table *flow_table;
map = rcu_dereference_protected(queue->rps_map, 1); map = rcu_dereference_protected(queue->rps_map, 1);
if (map) { if (map) {
RCU_INIT_POINTER(queue->rps_map, NULL); RCU_INIT_POINTER(queue->rps_map, NULL);
...@@ -974,8 +977,8 @@ struct netdev_queue_attribute { ...@@ -974,8 +977,8 @@ struct netdev_queue_attribute {
ssize_t (*store)(struct netdev_queue *queue, ssize_t (*store)(struct netdev_queue *queue,
const char *buf, size_t len); const char *buf, size_t len);
}; };
#define to_netdev_queue_attr(_attr) container_of(_attr, \ #define to_netdev_queue_attr(_attr) \
struct netdev_queue_attribute, attr) container_of(_attr, struct netdev_queue_attribute, attr)
#define to_netdev_queue(obj) container_of(obj, struct netdev_queue, kobj) #define to_netdev_queue(obj) container_of(obj, struct netdev_queue, kobj)
...@@ -1104,9 +1107,9 @@ static ssize_t bql_set(const char *buf, const size_t count, ...@@ -1104,9 +1107,9 @@ static ssize_t bql_set(const char *buf, const size_t count,
unsigned int value; unsigned int value;
int err; int err;
if (!strcmp(buf, "max") || !strcmp(buf, "max\n")) if (!strcmp(buf, "max") || !strcmp(buf, "max\n")) {
value = DQL_MAX_LIMIT; value = DQL_MAX_LIMIT;
else { } else {
err = kstrtouint(buf, 10, &value); err = kstrtouint(buf, 10, &value);
if (err < 0) if (err < 0)
return err; return err;
...@@ -1467,7 +1470,8 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env) ...@@ -1467,7 +1470,8 @@ static int netdev_uevent(struct device *d, struct kobj_uevent_env *env)
/* pass ifindex to uevent. /* pass ifindex to uevent.
* ifindex is useful as it won't change (interface name may change) * ifindex is useful as it won't change (interface name may change)
* and is what RtNetlink uses natively. */ * and is what RtNetlink uses natively.
*/
retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex); retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex);
exit: exit:
...@@ -1542,7 +1546,7 @@ EXPORT_SYMBOL(of_find_net_device_by_node); ...@@ -1542,7 +1546,7 @@ EXPORT_SYMBOL(of_find_net_device_by_node);
*/ */
void netdev_unregister_kobject(struct net_device *ndev) void netdev_unregister_kobject(struct net_device *ndev)
{ {
struct device *dev = &(ndev->dev); struct device *dev = &ndev->dev;
if (!atomic_read(&dev_net(ndev)->count)) if (!atomic_read(&dev_net(ndev)->count))
dev_set_uevent_suppress(dev, 1); dev_set_uevent_suppress(dev, 1);
...@@ -1559,7 +1563,7 @@ void netdev_unregister_kobject(struct net_device *ndev) ...@@ -1559,7 +1563,7 @@ void netdev_unregister_kobject(struct net_device *ndev)
/* Create sysfs entries for network device. */ /* Create sysfs entries for network device. */
int netdev_register_kobject(struct net_device *ndev) int netdev_register_kobject(struct net_device *ndev)
{ {
struct device *dev = &(ndev->dev); struct device *dev = &ndev->dev;
const struct attribute_group **groups = ndev->sysfs_groups; const struct attribute_group **groups = ndev->sysfs_groups;
int error = 0; int error = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment