aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2012-12-27 18:49:38 -0500
committerDavid S. Miller <davem@davemloft.net>2012-12-28 18:24:18 -0500
commitfdae0fde5352790030d89edd09f1b43b9bed97f8 (patch)
tree82e36fa133aa034ca39f9f576c3d4022cba24648
parent4bf84c35c65f36a344fb7a6cde6274df4120efb8 (diff)
net: allow to change carrier via sysfs
Make carrier writable Signed-off-by: Jiri Pirko <jiri@resnulli.us> Acked-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/net-sysfs.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 28c5f5aa7ca7..29c884a74c38 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -126,6 +126,19 @@ static ssize_t show_broadcast(struct device *dev,
126 return -EINVAL; 126 return -EINVAL;
127} 127}
128 128
129static int change_carrier(struct net_device *net, unsigned long new_carrier)
130{
131 if (!netif_running(net))
132 return -EINVAL;
133 return dev_change_carrier(net, (bool) new_carrier);
134}
135
136static ssize_t store_carrier(struct device *dev, struct device_attribute *attr,
137 const char *buf, size_t len)
138{
139 return netdev_store(dev, attr, buf, len, change_carrier);
140}
141
129static ssize_t show_carrier(struct device *dev, 142static ssize_t show_carrier(struct device *dev,
130 struct device_attribute *attr, char *buf) 143 struct device_attribute *attr, char *buf)
131{ 144{
@@ -331,7 +344,7 @@ static struct device_attribute net_class_attributes[] = {
331 __ATTR(link_mode, S_IRUGO, show_link_mode, NULL), 344 __ATTR(link_mode, S_IRUGO, show_link_mode, NULL),
332 __ATTR(address, S_IRUGO, show_address, NULL), 345 __ATTR(address, S_IRUGO, show_address, NULL),
333 __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), 346 __ATTR(broadcast, S_IRUGO, show_broadcast, NULL),
334 __ATTR(carrier, S_IRUGO, show_carrier, NULL), 347 __ATTR(carrier, S_IRUGO | S_IWUSR, show_carrier, store_carrier),
335 __ATTR(speed, S_IRUGO, show_speed, NULL), 348 __ATTR(speed, S_IRUGO, show_speed, NULL),
336 __ATTR(duplex, S_IRUGO, show_duplex, NULL), 349 __ATTR(duplex, S_IRUGO, show_duplex, NULL),
337 __ATTR(dormant, S_IRUGO, show_dormant, NULL), 350 __ATTR(dormant, S_IRUGO, show_dormant, NULL),