aboutsummaryrefslogtreecommitdiffstats
path: root/net/rfkill
diff options
context:
space:
mode:
Diffstat (limited to 'net/rfkill')
-rw-r--r--net/rfkill/rfkill.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 3eaa39403c13..df1269c5ca70 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -200,7 +200,7 @@ static void __rfkill_switch_all(const enum rfkill_type type,
200 200
201 rfkill_global_states[type].current_state = state; 201 rfkill_global_states[type].current_state = state;
202 list_for_each_entry(rfkill, &rfkill_list, node) { 202 list_for_each_entry(rfkill, &rfkill_list, node) {
203 if ((!rfkill->user_claim) && (rfkill->type == type)) { 203 if (rfkill->type == type) {
204 mutex_lock(&rfkill->mutex); 204 mutex_lock(&rfkill->mutex);
205 rfkill_toggle_radio(rfkill, state, 0); 205 rfkill_toggle_radio(rfkill, state, 0);
206 mutex_unlock(&rfkill->mutex); 206 mutex_unlock(&rfkill->mutex);
@@ -447,53 +447,14 @@ static ssize_t rfkill_claim_show(struct device *dev,
447 struct device_attribute *attr, 447 struct device_attribute *attr,
448 char *buf) 448 char *buf)
449{ 449{
450 struct rfkill *rfkill = to_rfkill(dev); 450 return sprintf(buf, "%d\n", 0);
451
452 return sprintf(buf, "%d\n", rfkill->user_claim);
453} 451}
454 452
455static ssize_t rfkill_claim_store(struct device *dev, 453static ssize_t rfkill_claim_store(struct device *dev,
456 struct device_attribute *attr, 454 struct device_attribute *attr,
457 const char *buf, size_t count) 455 const char *buf, size_t count)
458{ 456{
459 struct rfkill *rfkill = to_rfkill(dev); 457 return -EOPNOTSUPP;
460 unsigned long claim_tmp;
461 bool claim;
462 int error;
463
464 if (!capable(CAP_NET_ADMIN))
465 return -EPERM;
466
467 if (rfkill->user_claim_unsupported)
468 return -EOPNOTSUPP;
469
470 error = strict_strtoul(buf, 0, &claim_tmp);
471 if (error)
472 return error;
473 claim = !!claim_tmp;
474
475 /*
476 * Take the global lock to make sure the kernel is not in
477 * the middle of rfkill_switch_all
478 */
479 error = mutex_lock_killable(&rfkill_global_mutex);
480 if (error)
481 return error;
482
483 if (rfkill->user_claim != claim) {
484 if (!claim && !rfkill_epo_lock_active) {
485 mutex_lock(&rfkill->mutex);
486 rfkill_toggle_radio(rfkill,
487 rfkill_global_states[rfkill->type].current_state,
488 0);
489 mutex_unlock(&rfkill->mutex);
490 }
491 rfkill->user_claim = claim;
492 }
493
494 mutex_unlock(&rfkill_global_mutex);
495
496 return error ? error : count;
497} 458}
498 459
499static struct device_attribute rfkill_dev_attrs[] = { 460static struct device_attribute rfkill_dev_attrs[] = {