From patchwork Mon Apr 8 15:59:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Pitt X-Patchwork-Id: 235020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id D5FD22C00A2 for ; Tue, 9 Apr 2013 19:44:59 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UPV6g-0005xI-Bg; Tue, 09 Apr 2013 09:44:50 +0000 Received: from www.piware.de ([213.9.93.70]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UPETg-0005Ka-4k for kernel-team@lists.ubuntu.com; Mon, 08 Apr 2013 15:59:28 +0000 Received: from localhost.localdomain (p57A846C1.dip.t-dialin.net [87.168.70.193]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Martin Pitt (ThinkPad)", Issuer "piware CA" (verified OK)) by www.piware.de (Postfix) with ESMTPS id 39A5CFB8B6 for ; Mon, 8 Apr 2013 17:51:22 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 8AB1163439; Mon, 8 Apr 2013 17:59:26 +0200 (CEST) Date: Mon, 8 Apr 2013 17:59:26 +0200 From: Martin Pitt To: kernel-team@lists.ubuntu.com Subject: [PATCH] mac80211_hwsim: Register and bind to driver Message-ID: <20130408155926.GC3092@piware.de> MIME-Version: 1.0 User-Agent: Mutt/1.5.21 (2010-09-15) X-Mailman-Approved-At: Tue, 09 Apr 2013 09:44:49 +0000 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com 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 Acked-by: Andy Whitcroft From 6d665c5384bbc64c95d87ebde8ce39052a48fa81 Mon Sep 17 00:00:00 2001 From: Martin Pitt 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 [fix an old and a new message to not be line-broken] Signed-off-by: Johannes Berg --- 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 #include #include +#include #include #include #include @@ -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