* [PATCH] mac80211_hwsim: Register and bind to driver
@ 2013-04-08 9:06 Martin Pitt
2013-04-08 9:12 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: Martin Pitt @ 2013-04-08 9:06 UTC (permalink / raw)
To: John W. Linville, linux-wireless-u79uwXL29TY76Z2rM5mHXA
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Johannes Berg, Dan Williams
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-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
---
drivers/net/wireless/mac80211_hwsim.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 0064d38..50a8b52 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>
@@ -1675,6 +1676,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);
}
@@ -1683,7 +1685,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 = {
@@ -2179,6 +2183,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;
@@ -2205,6 +2211,14 @@ static int __init init_mac80211_hwsim(void)
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);
@@ -2518,5 +2532,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);
--
1.7.2.5
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mac80211_hwsim: Register and bind to driver
2013-04-08 9:06 [PATCH] mac80211_hwsim: Register and bind to driver Martin Pitt
@ 2013-04-08 9:12 ` Johannes Berg
[not found] ` <1365412374.25475.2.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2013-04-08 9:12 UTC (permalink / raw)
To: Martin Pitt
Cc: John W. Linville, linux-wireless, netdev, linux-kernel,
Dan Williams
Looks fine, but ...
> @@ -2179,6 +2183,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;
I think you forgot to update the error path to unregister the driver.
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mac80211_hwsim: Register and bind to driver
[not found] ` <1365412374.25475.2.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
@ 2013-04-08 9:28 ` Martin Pitt
0 siblings, 0 replies; 3+ messages in thread
From: Martin Pitt @ 2013-04-08 9:28 UTC (permalink / raw)
To: Johannes Berg
Cc: John W. Linville, linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan Williams
Hello Johannes,
Johannes Berg [2013-04-08 11:12 +0200]:
> I think you forgot to update the error path to unregister the driver.
Oops, thanks for spotting. Sending [PATCH v2].
Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-08 9:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-08 9:06 [PATCH] mac80211_hwsim: Register and bind to driver Martin Pitt
2013-04-08 9:12 ` Johannes Berg
[not found] ` <1365412374.25475.2.camel-8Nb76shvtaUJvtFkdXX2HixXY32XiHfO@public.gmane.org>
2013-04-08 9:28 ` Martin Pitt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).