Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16218
b: refs/heads/master
c: fd586ba
h: refs/heads/master
v: v3
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Jan 5, 2006
1 parent f015f7d commit a01988b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1f1bf132d81ed723bc5fefbcec7d0779ce683a4f
refs/heads/master: fd586bacf439f36dea9b9bf6e6133ac87df2730c
68 changes: 21 additions & 47 deletions trunk/net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,11 @@ static ssize_t netdev_store(struct class_device *dev,
return ret;
}

/* generate a read-only network device class attribute */
#define NETDEVICE_ATTR(field, format_string) \
NETDEVICE_SHOW(field, format_string) \
static CLASS_DEVICE_ATTR(field, S_IRUGO, show_##field, NULL) \

NETDEVICE_ATTR(addr_len, fmt_dec);
NETDEVICE_ATTR(iflink, fmt_dec);
NETDEVICE_ATTR(ifindex, fmt_dec);
NETDEVICE_ATTR(features, fmt_long_hex);
NETDEVICE_ATTR(type, fmt_dec);
NETDEVICE_SHOW(addr_len, fmt_dec);
NETDEVICE_SHOW(iflink, fmt_dec);
NETDEVICE_SHOW(ifindex, fmt_dec);
NETDEVICE_SHOW(features, fmt_long_hex);
NETDEVICE_SHOW(type, fmt_dec);

/* use same locking rules as GIFHWADDR ioctl's */
static ssize_t format_addr(char *buf, const unsigned char *addr, int len)
Expand Down Expand Up @@ -136,10 +131,6 @@ static ssize_t show_carrier(struct class_device *dev, char *buf)
return -EINVAL;
}

static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
static CLASS_DEVICE_ATTR(broadcast, S_IRUGO, show_broadcast, NULL);
static CLASS_DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL);

/* read-write attributes */
NETDEVICE_SHOW(mtu, fmt_dec);

Expand All @@ -153,8 +144,6 @@ static ssize_t store_mtu(struct class_device *dev, const char *buf, size_t len)
return netdev_store(dev, buf, len, change_mtu);
}

static CLASS_DEVICE_ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu);

NETDEVICE_SHOW(flags, fmt_hex);

static int change_flags(struct net_device *net, unsigned long new_flags)
Expand All @@ -167,8 +156,6 @@ static ssize_t store_flags(struct class_device *dev, const char *buf, size_t len
return netdev_store(dev, buf, len, change_flags);
}

static CLASS_DEVICE_ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags);

NETDEVICE_SHOW(tx_queue_len, fmt_ulong);

static int change_tx_queue_len(struct net_device *net, unsigned long new_len)
Expand All @@ -182,9 +169,6 @@ static ssize_t store_tx_queue_len(struct class_device *dev, const char *buf, siz
return netdev_store(dev, buf, len, change_tx_queue_len);
}

static CLASS_DEVICE_ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
store_tx_queue_len);

NETDEVICE_SHOW(weight, fmt_dec);

static int change_weight(struct net_device *net, unsigned long new_weight)
Expand All @@ -198,24 +182,21 @@ static ssize_t store_weight(struct class_device *dev, const char *buf, size_t le
return netdev_store(dev, buf, len, change_weight);
}

static CLASS_DEVICE_ATTR(weight, S_IRUGO | S_IWUSR, show_weight,
store_weight);


static struct class_device_attribute *net_class_attributes[] = {
&class_device_attr_ifindex,
&class_device_attr_iflink,
&class_device_attr_addr_len,
&class_device_attr_tx_queue_len,
&class_device_attr_features,
&class_device_attr_mtu,
&class_device_attr_flags,
&class_device_attr_weight,
&class_device_attr_type,
&class_device_attr_address,
&class_device_attr_broadcast,
&class_device_attr_carrier,
NULL
static struct class_device_attribute net_class_attributes[] = {
__ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
__ATTR(iflink, S_IRUGO, show_iflink, NULL),
__ATTR(ifindex, S_IRUGO, show_ifindex, NULL),
__ATTR(features, S_IRUGO, show_features, NULL),
__ATTR(type, S_IRUGO, show_type, NULL),
__ATTR(address, S_IRUGO, show_address, NULL),
__ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
__ATTR(carrier, S_IRUGO, show_carrier, NULL),
__ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu),
__ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags),
__ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
store_tx_queue_len),
__ATTR(weight, S_IRUGO | S_IWUSR, show_weight, store_weight),
{}
};

/* Show a given an attribute in the statistics group */
Expand Down Expand Up @@ -407,6 +388,7 @@ static void netdev_release(struct class_device *cd)
static struct class net_class = {
.name = "net",
.release = netdev_release,
.class_dev_attrs = net_class_attributes,
#ifdef CONFIG_HOTPLUG
.uevent = netdev_uevent,
#endif
Expand All @@ -431,8 +413,6 @@ void netdev_unregister_sysfs(struct net_device * net)
int netdev_register_sysfs(struct net_device *net)
{
struct class_device *class_dev = &(net->class_dev);
int i;
struct class_device_attribute *attr;
int ret;

class_dev->class = &net_class;
Expand All @@ -442,12 +422,6 @@ int netdev_register_sysfs(struct net_device *net)
if ((ret = class_device_register(class_dev)))
goto out;

for (i = 0; (attr = net_class_attributes[i]) != NULL; i++) {
if ((ret = class_device_create_file(class_dev, attr)))
goto out_unreg;
}


if (net->get_stats &&
(ret = sysfs_create_group(&class_dev->kobj, &netstat_group)))
goto out_unreg;
Expand Down

0 comments on commit a01988b

Please sign in to comment.