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
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[] = { · 199 unmodified lines
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),

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