Subject: Re: [Bonding-devel] [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type

From: Stephen Hemminger <[email-masked]>
Date: Wed, 10 Mar 2010 14:47:10 -0800

On Wed, 10 Mar 2010 21:29:35 +0100
Jiri Pirko <[email-masked]> wrote:

> diff --git a/net/core/dev.c b/net/core/dev.c
> index bcc490c..5de4a15 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1084,9 +1084,9 @@ void netdev_state_change(struct net_device *dev)
>  }
>  EXPORT_SYMBOL(netdev_state_change);
>  
> -void netdev_bonding_change(struct net_device *dev, unsigned long event)
> +int netdev_bonding_change(struct net_device *dev, unsigned long event)
>  {
> -	call_netdevice_notifiers(event, dev);
> +	return call_netdevice_notifiers(event, dev);
>  }
>  EXPORT_SYMBOL(netdev_bonding_change);
>  

I don't think all this pre-post stuff needed.
Since this is general (not just bonding) how about

int netdev_change_type(struct net_device *dev, int newtype)
{
	int ret, oldtype;

	if (dev->flags & IFF_UP)
		return -EBUSY;

	oldtype = dev->type;
	dev->type = newtype;
	ret = call_netdevice_notifier(NETDEV_CHANGETYPE, dev);
	ret = notifier_to_errno(ret);
	if (ret)
	     dev->type = oldtype;

	return ret;
}