[Acked] [PATCH] mac80211_hwsim: Register and bind to driver

Andy Whitcroft apw at canonical.com
Tue Apr 9 11:48:56 UTC 2013


On Mon, Apr 08, 2013 at 05:59:26PM +0200, Martin Pitt wrote:
> Hello kernel team,
> 
> today I fixed mac80211_hwsim to get a proper "driver" attribute, so
> that it works with NetworkManager. This will allow us to write
> integration tests not only for wpa_supplicant and dhclient, but for
> the whole NM stack. [1]
> 
> I sent the patch upstream this morning, and Johannes Berg applied it
> to his tree:
> 
>   https://git.kernel.org/cgit/linux/kernel/git/jberg/mac80211-next.git/commit/?id=6d665c5384bbc64c95d87ebde8ce39052a48fa81
> 
> If it is appropriate, it would be nice to include it into the raring
> kernel. However, it's not necessary to break freeze rules or go
> through extraordinary efforts, as we can also apply a workaround to NM
> for the time being.
> 
> I filed a bug to track this: https://launchpad.net/bugs/1166250
> 
> Thanks for considering,
> 
> Martin
> 
> [1] https://blueprints.launchpad.net/ubuntu/+spec/client-1303-converged-network-stack
> -- 
> Martin Pitt                        | http://www.piware.de
> Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

> From 6d665c5384bbc64c95d87ebde8ce39052a48fa81 Mon Sep 17 00:00:00 2001
> From: Martin Pitt <martin.pitt at ubuntu.com>
> Date: Mon, 08 Apr 2013 09:30:01 +0000
> Subject: mac80211_hwsim: Register and bind to driver
> 
> Properly register our mac80211_hwsim_driver, attach it to the platform bus.
> Bind newly created hwsim devices to that driver, so that our wlan devices get
> a proper "driver" sysfs attribute.
> 
> This makes mac80211_hwsim interfaces work with NetworkManager.
> 
> Signed-off-by: Martin Pitt <martin.pitt at ubuntu.com>
> [fix an old and a new message to not be line-broken]
> Signed-off-by: Johannes Berg <johannes.berg at intel.com>
> ---
> diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
> index 70b6ce6..9a0d526 100644
> --- a/drivers/net/wireless/mac80211_hwsim.c
> +++ b/drivers/net/wireless/mac80211_hwsim.c
> @@ -25,6 +25,7 @@
>  #include <linux/if_arp.h>
>  #include <linux/rtnetlink.h>
>  #include <linux/etherdevice.h>
> +#include <linux/platform_device.h>
>  #include <linux/debugfs.h>
>  #include <linux/module.h>
>  #include <linux/ktime.h>
> @@ -1687,6 +1688,7 @@ static void mac80211_hwsim_free(void)
>  		debugfs_remove(data->debugfs_ps);
>  		debugfs_remove(data->debugfs);
>  		ieee80211_unregister_hw(data->hw);
> +		device_release_driver(data->dev);
>  		device_unregister(data->dev);
>  		ieee80211_free_hw(data->hw);
>  	}
> @@ -1695,7 +1697,9 @@ static void mac80211_hwsim_free(void)
>  
>  
>  static struct device_driver mac80211_hwsim_driver = {
> -	.name = "mac80211_hwsim"
> +	.name = "mac80211_hwsim",
> +	.bus = &platform_bus_type,
> +	.owner = THIS_MODULE,
>  };
>  
>  static const struct net_device_ops hwsim_netdev_ops = {
> @@ -2191,6 +2195,8 @@ static int __init init_mac80211_hwsim(void)
>  	if (IS_ERR(hwsim_class))
>  		return PTR_ERR(hwsim_class);
>  
> +	driver_register(&mac80211_hwsim_driver);
> +
>  	memset(addr, 0, ETH_ALEN);
>  	addr[0] = 0x02;
>  
> @@ -2211,12 +2217,20 @@ static int __init init_mac80211_hwsim(void)
>  					  "hwsim%d", i);
>  		if (IS_ERR(data->dev)) {
>  			printk(KERN_DEBUG
> -			       "mac80211_hwsim: device_create "
> -			       "failed (%ld)\n", PTR_ERR(data->dev));
> +			       "mac80211_hwsim: device_create failed (%ld)\n",
> +			       PTR_ERR(data->dev));
>  			err = -ENOMEM;
>  			goto failed_drvdata;
>  		}
>  		data->dev->driver = &mac80211_hwsim_driver;
> +		err = device_bind_driver(data->dev);
> +		if (err != 0) {
> +			printk(KERN_DEBUG
> +			       "mac80211_hwsim: device_bind_driver failed (%d)\n",
> +			       err);
> +			goto failed_hw;
> +		}
> +
>  		skb_queue_head_init(&data->pending);
>  
>  		SET_IEEE80211_DEV(hw, data->dev);
> @@ -2515,6 +2529,7 @@ failed_drvdata:
>  	ieee80211_free_hw(hw);
>  failed:
>  	mac80211_hwsim_free();
> +	driver_unregister(&mac80211_hwsim_driver);
>  	return err;
>  }
>  module_init(init_mac80211_hwsim);
> @@ -2527,5 +2542,6 @@ static void __exit exit_mac80211_hwsim(void)
>  
>  	mac80211_hwsim_free();
>  	unregister_netdev(hwsim_mon);
> +	driver_unregister(&mac80211_hwsim_driver);
>  }
>  module_exit(exit_mac80211_hwsim);
> --
> cgit v0.9.1

Looks to be a fairly simple fix, with us so close to freeze I would be
tempted to say lets take it a SAUCE patch and let it drop out when we
get the real fix from Linus' tree.  The chances of regression are small
as all it appears to do is add some sysfs files for the device, which
can only make it work better with network-manager.

Acked-by: Andy Whitcroft <apw at canonical.com>

-apw




More information about the kernel-team mailing list