Skip to content

Commit

Permalink
cfg80211: regulatory: simplify uevent sending
Browse files Browse the repository at this point in the history
There's no need for the struct device_type with the uevent function
etc., just fill the country alpha2 when sending the event.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Feb 25, 2014
1 parent 6658ab8 commit 1226d25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
37 changes: 8 additions & 29 deletions net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ static struct regulatory_request __rcu *last_request =
/* To trigger userspace events */
static struct platform_device *reg_pdev;

static const 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
Expand Down Expand Up @@ -487,11 +483,16 @@ static inline void reg_regdb_query(const char *alpha2) {}

/*
* This lets us keep regulatory code which is updated on a regulatory
* basis in userspace. Country information is filled in by
* reg_device_uevent
* basis in userspace.
*/
static int call_crda(const char *alpha2)
{
char country[12];
char *env[] = { country, NULL };

snprintf(country, sizeof(country), "COUNTRY=%c%c",
alpha2[0], alpha2[1]);

if (!is_world_regdom((char *) alpha2))
pr_info("Calling CRDA for country: %c%c\n",
alpha2[0], alpha2[1]);
Expand All @@ -501,7 +502,7 @@ static int call_crda(const char *alpha2)
/* query internal regulatory database (if it exists) */
reg_regdb_query(alpha2);

return kobject_uevent(&reg_pdev->dev.kobj, KOBJ_CHANGE);
return kobject_uevent_env(&reg_pdev->dev.kobj, KOBJ_CHANGE, env);
}

static enum reg_request_treatment
Expand Down Expand Up @@ -2544,26 +2545,6 @@ int set_regdom(const struct ieee80211_regdomain *rd)
return 0;
}

int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
{
struct regulatory_request *lr;
u8 alpha2[2];
bool add = false;

rcu_read_lock();
lr = get_last_request();
if (lr && !lr->processed) {
memcpy(alpha2, lr->alpha2, 2);
add = true;
}
rcu_read_unlock();

if (add)
return add_uevent_var(env, "COUNTRY=%c%c",
alpha2[0], alpha2[1]);
return 0;
}

void wiphy_regulatory_register(struct wiphy *wiphy)
{
struct regulatory_request *lr;
Expand Down Expand Up @@ -2614,8 +2595,6 @@ int __init regulatory_init(void)
if (IS_ERR(reg_pdev))
return PTR_ERR(reg_pdev);

reg_pdev->dev.type = &reg_device_type;

spin_lock_init(&reg_requests_lock);
spin_lock_init(&reg_pending_beacons_lock);

Expand Down
1 change: 0 additions & 1 deletion net/wireless/reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy);
int regulatory_hint_user(const char *alpha2,
enum nl80211_user_reg_hint_type user_reg_hint_type);

int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env);
void wiphy_regulatory_register(struct wiphy *wiphy);
void wiphy_regulatory_deregister(struct wiphy *wiphy);

Expand Down

0 comments on commit 1226d25

Please sign in to comment.