All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v3 3/5] net: use ndo_fix_features for ethtool_ops->set_flags
Date: Sun, 30 Jan 2011 08:44:03 +1000	[thread overview]
Message-ID: <1296341043.3477.64.camel@localhost> (raw)
In-Reply-To: <3ebf175d86bad22033e680e0cde198598ffcedc6.1296325509.git.mirq-linux@rere.qmqm.pl>

On Sat, 2011-01-29 at 19:39 +0100, Michał Mirosław wrote:
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  net/core/ethtool.c |   22 ++++++++++++++++++++--
>  1 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index 409aebb..17a689f4 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -240,6 +240,25 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
>  	return ret;
>  }
>  
> +static int __ethtool_set_flags(struct net_device *dev, u32 data)
> +{
> +	if (data & ~flags_dup_features)
> +		return -EINVAL;
> +
> +	if (!(dev->hw_features & flags_dup_features)) {
> +		if (!dev->ethtool_ops->set_flags)
> +			return -EOPNOTSUPP;
> +		return dev->ethtool_ops->set_flags(dev, data);
> +	}
> +
> +	dev->wanted_features =
> +		(dev->wanted_features & ~flags_dup_features) | data;
> +
> +	netdev_update_features(dev);
> +
> +	return 0;
[...]

I think it would be clearer to write this as:

	if (dev->hw_features & flags_dup_features) {
		dev->wanted_features =
			(dev->wanted_features & ~flags_dup_features) | data;
		netdev_update_features(dev);
		return 0;
	}

	if (dev->ethtool_ops->set_flags)
		return dev->ethtool_ops->set_flags(dev, data);

	return -EOPNOTSUPP;

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2011-01-29 22:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-29 18:39 [PATCH v3 0/5] net: Unified offload configuration Michał Mirosław
2011-01-29 18:39 ` [PATCH v3 3/5] net: use ndo_fix_features for ethtool_ops->set_flags Michał Mirosław
2011-01-29 22:44   ` Ben Hutchings [this message]
2011-02-03 13:45     ` Michał Mirosław
2011-01-29 18:39 ` [PATCH v3 5/5] loopback: convert to hw_features Michał Mirosław
2011-01-29 18:39 ` [PATCH v3 1/5] net: Introduce new feature setting ops Michał Mirosław
2011-01-29 22:24   ` Ben Hutchings
2011-02-03 13:42     ` Michał Mirosław
2011-01-29 18:39 ` [PATCH v3 4/5] net: introduce NETIF_F_RXCSUM Michał Mirosław
2011-01-29 22:45   ` Ben Hutchings
2011-01-29 18:39 ` [PATCH] ethtool: implement G/SFEATURES calls Michał Mirosław
2011-01-29 22:47   ` Ben Hutchings
2011-01-29 18:39 ` [PATCH v3 2/5] net: ethtool: use ndo_fix_features for offload setting Michał Mirosław
2011-01-29 22:38   ` Ben Hutchings

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=1296341043.3477.64.camel@localhost \
    --to=bhutchings@solarflare.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.