[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AC6432C.1020202@gmail.com>
Date: Fri, 02 Oct 2009 20:15:08 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Andy Gospodarek <andy@...yhouse.net>
CC: netdev@...r.kernel.org
Subject: Re: [PATCH] net: export device speed and duplex via sysfs
Andy Gospodarek a écrit :
> +static ssize_t show_speed(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct net_device *netdev = to_net_dev(dev);
> + int ret = -EINVAL;
> +
> + if (!rtnl_trylock())
> + return restart_syscall();
> +
> + if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
> + struct ethtool_cmd cmd = { ETHTOOL_GSET };
> +
> + if (netdev->ethtool_ops->get_settings(netdev, &cmd) < 0)
rtnl lock leak ?
> + return -EINVAL;
> + ret = sprintf(buf, fmt_dec, cmd.speed);
> + }
> + rtnl_unlock();
> + return ret;
> +}
> +
> +static ssize_t show_duplex(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct net_device *netdev = to_net_dev(dev);
> + int ret = -EINVAL;
> +
> + if (!rtnl_trylock())
> + return restart_syscall();
> +
> + if (netif_running(netdev) && netdev->ethtool_ops->get_settings) {
> + struct ethtool_cmd cmd = { ETHTOOL_GSET };
> +
> + if (netdev->ethtool_ops->get_settings(netdev, &cmd) < 0)
rtnl lock leak ?
> + return -EINVAL;
> + ret = sprintf(buf, "%s\n", cmd.duplex ? "full" : "half");
> + }
> + rtnl_unlock();
> + return ret;
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists