From: Eric Dumazet <eric.dumazet@gmail•com>
To: Andy Gospodarek <andy@greyhouse•net>
Cc: netdev@vger•kernel.org
Subject: Re: [PATCH] net: export device speed and duplex via sysfs
Date: Fri, 02 Oct 2009 20:15:08 +0200 [thread overview]
Message-ID: <4AC6432C.1020202@gmail.com> (raw)
In-Reply-To: <20091002180742.GH4436@gospo.rdu.redhat.com>
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;
> +}
> +
next prev parent reply other threads:[~2009-10-02 18:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-02 18:07 [PATCH] net: export device speed and duplex via sysfs Andy Gospodarek
2009-10-02 18:15 ` Eric Dumazet [this message]
2009-10-02 19:26 ` [PATCH v2] " Andy Gospodarek
2009-10-02 18:19 ` [PATCH] " Ben Hutchings
2009-10-02 20:01 ` Andy Gospodarek
2009-10-05 7:44 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AC6432C.1020202@gmail.com \
--to=eric.dumazet@gmail$(echo .)com \
--cc=andy@greyhouse$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox