Skip to content

Commit 1226d25

Browse files
committed
cfg80211: regulatory: simplify uevent sending
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 <[email protected]>
1 parent 6658ab8 commit 1226d25

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

net/wireless/reg.c

+8-29
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ static struct regulatory_request __rcu *last_request =
9191
/* To trigger userspace events */
9292
static struct platform_device *reg_pdev;
9393

94-
static const struct device_type reg_device_type = {
95-
.uevent = reg_device_uevent,
96-
};
97-
9894
/*
9995
* Central wireless core regulatory domains, we only need two,
10096
* the current one and a world regulatory domain in case we have no
@@ -487,11 +483,16 @@ static inline void reg_regdb_query(const char *alpha2) {}
487483

488484
/*
489485
* This lets us keep regulatory code which is updated on a regulatory
490-
* basis in userspace. Country information is filled in by
491-
* reg_device_uevent
486+
* basis in userspace.
492487
*/
493488
static int call_crda(const char *alpha2)
494489
{
490+
char country[12];
491+
char *env[] = { country, NULL };
492+
493+
snprintf(country, sizeof(country), "COUNTRY=%c%c",
494+
alpha2[0], alpha2[1]);
495+
495496
if (!is_world_regdom((char *) alpha2))
496497
pr_info("Calling CRDA for country: %c%c\n",
497498
alpha2[0], alpha2[1]);
@@ -501,7 +502,7 @@ static int call_crda(const char *alpha2)
501502
/* query internal regulatory database (if it exists) */
502503
reg_regdb_query(alpha2);
503504

504-
return kobject_uevent(&reg_pdev->dev.kobj, KOBJ_CHANGE);
505+
return kobject_uevent_env(&reg_pdev->dev.kobj, KOBJ_CHANGE, env);
505506
}
506507

507508
static enum reg_request_treatment
@@ -2544,26 +2545,6 @@ int set_regdom(const struct ieee80211_regdomain *rd)
25442545
return 0;
25452546
}
25462547

2547-
int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env)
2548-
{
2549-
struct regulatory_request *lr;
2550-
u8 alpha2[2];
2551-
bool add = false;
2552-
2553-
rcu_read_lock();
2554-
lr = get_last_request();
2555-
if (lr && !lr->processed) {
2556-
memcpy(alpha2, lr->alpha2, 2);
2557-
add = true;
2558-
}
2559-
rcu_read_unlock();
2560-
2561-
if (add)
2562-
return add_uevent_var(env, "COUNTRY=%c%c",
2563-
alpha2[0], alpha2[1]);
2564-
return 0;
2565-
}
2566-
25672548
void wiphy_regulatory_register(struct wiphy *wiphy)
25682549
{
25692550
struct regulatory_request *lr;
@@ -2614,8 +2595,6 @@ int __init regulatory_init(void)
26142595
if (IS_ERR(reg_pdev))
26152596
return PTR_ERR(reg_pdev);
26162597

2617-
reg_pdev->dev.type = &reg_device_type;
2618-
26192598
spin_lock_init(&reg_requests_lock);
26202599
spin_lock_init(&reg_pending_beacons_lock);
26212600

net/wireless/reg.h

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy);
2626
int regulatory_hint_user(const char *alpha2,
2727
enum nl80211_user_reg_hint_type user_reg_hint_type);
2828

29-
int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env);
3029
void wiphy_regulatory_register(struct wiphy *wiphy);
3130
void wiphy_regulatory_deregister(struct wiphy *wiphy);
3231

0 commit comments

Comments
 (0)