This is an old revision of the document!


The implications of setting net_device_ops ndo_change_carrier field.

static int change_carrier(struct net_device *dev, unsigned long new_carrier)
{
        if (!netif_running(dev))
                return -EINVAL;
        return dev_change_carrier(dev, (bool) new_carrier);
}

static ssize_t carrier_store(struct device *dev, struct device_attribute *attr,
                             const char *buf, size_t len)
{
        return netdev_store(dev, attr, buf, len, change_carrier);
}

static ssize_t carrier_show(struct device *dev,
                            struct device_attribute *attr, char *buf)
{
        struct net_device *netdev = to_net_dev(dev);
        if (netif_running(netdev)) {
                return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
        }
        return -EINVAL;
}
static DEVICE_ATTR_RW(carrier);
  • ndo_change_carrier.1533378248.txt.gz
  • Last modified: 2018/08/04 10:24
  • by rpjday