Make carrier writable
Unified · Split
| @@ -126,6 +126,19 @@ static ssize_t show_broadcast(struct device *dev, · 125 unmodified lines | ||
| 126 | 126 | return -EINVAL; |
| 127 | 127 | } |
| 128 | 128 | |
| 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 | + | |
| 129 | 142 | static ssize_t show_carrier(struct device *dev, |
| 130 | 143 | struct device_attribute *attr, char *buf) |
| 131 | 144 | { |
| @@ -331,7 +344,7 @@ static struct device_attribute net_class_attributes[] = { · 199 unmodified lines | ||
| 331 | 344 | __ATTR(link_mode, S_IRUGO, show_link_mode, NULL), |
| 332 | 345 | __ATTR(address, S_IRUGO, show_address, NULL), |
| 333 | 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 | 348 | __ATTR(speed, S_IRUGO, show_speed, NULL), |
| 336 | 349 | __ATTR(duplex, S_IRUGO, show_duplex, NULL), |
| 337 | 350 | __ATTR(dormant, S_IRUGO, show_dormant, NULL), |