History

net: allow to change carrier via sysfs

Make carrier writable

Jiri Pirko committed 13 years ago

Commit fdae0fd1 parent 4bf84c31 file · +14 −1Browse files

Unified · Split

net/core/net-sysfs.c+14−1
@@ -126,6 +126,19 @@ static ssize_t show_broadcast(struct device *dev, · 125 unmodified lines
126126 return -EINVAL;
127127 }
128128
129+static 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+
136+static 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+
129142 static ssize_t show_carrier(struct device *dev,
130143 struct device_attribute *attr, char *buf)
131144 {
@@ -331,7 +344,7 @@ static struct device_attribute net_class_attributes[] = { · 199 unmodified lines
331344 __ATTR(link_mode, S_IRUGO, show_link_mode, NULL),
332345 __ATTR(address, S_IRUGO, show_address, NULL),
333346 __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),
335348 __ATTR(speed, S_IRUGO, show_speed, NULL),
336349 __ATTR(duplex, S_IRUGO, show_duplex, NULL),
337350 __ATTR(dormant, S_IRUGO, show_dormant, NULL),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t