Subject: Re: [PATCH v3 3/5] net: use ndo_fix_features for ethtool_ops->set_flags

From: Ben Hutchings <[email-masked]>
Date: Sun, 30 Jan 2011 08:44:03 +1000

On Sat, 2011-01-29 at 19:39 +0100, Michał Mirosław wrote:
> Signed-off-by: Michał Mirosław <[email-masked]>
> ---
>  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.