/* To trigger userspace events */
static struct platform_device *reg_pdev;
+static struct device_type reg_device_type = {
+ .uevent = reg_device_uevent,
+};
+
/*
* Central wireless core regulatory domains, we only need two,
* the current one and a world regulatory domain in case we have no
/*
* This lets us keep regulatory code which is updated on a regulatory
- * basis in userspace.
+ * basis in userspace. Country information is filled in by
+ * reg_device_uevent
*/
static int call_crda(const char *alpha2)
{
- char country_env[9 + 2] = "COUNTRY=";
- char *envp[] = {
- country_env,
- NULL
- };
-
if (!is_world_regdom((char *) alpha2))
pr_info("Calling CRDA for country: %c%c\n",
alpha2[0], alpha2[1]);
/* query internal regulatory database (if it exists) */
reg_regdb_query(alpha2);
- country_env[8] = alpha2[0];
- country_env[9] = alpha2[1];
-
- return kobject_uevent_env(®_pdev->dev.kobj, KOBJ_CHANGE, envp);
+ return kobject_uevent(®_pdev->dev.kobj, KOBJ_CHANGE);
}
/* Used by nl80211 before kmalloc'ing our regulatory domain */
return r;
}
+#ifdef CONFIG_HOTPLUG
+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ if (last_request && !last_request->processed) {
+ if (add_uevent_var(env, "COUNTRY=%c%c",
+ last_request->alpha2[0],
+ last_request->alpha2[1]))
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+#else
+int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ return -ENODEV;
+}
+#endif /* CONFIG_HOTPLUG */
+
/* Caller must hold cfg80211_mutex */
void reg_device_remove(struct wiphy *wiphy)
{
if (IS_ERR(reg_pdev))
return PTR_ERR(reg_pdev);
+ reg_pdev->dev.type = ®_device_type;
+
spin_lock_init(®_requests_lock);
spin_lock_init(®_pending_beacons_lock);