diff options
author | David S. Miller <davem@davemloft.net> | 2009-07-24 04:03:51 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-07-24 04:03:51 +0200 |
commit | 74d154189d597b91da4322996dbf4f5c3d1544ab (patch) | |
tree | 6f09861b5e2f875d2d8ea2127b16add9103221c6 /net/rfkill | |
parent | Fix typos in comments in via-velocity header. (diff) | |
parent | ixgbe: remove unnecessary call to device_init_wakeup (diff) | |
download | linux-74d154189d597b91da4322996dbf4f5c3d1544ab.tar.xz linux-74d154189d597b91da4322996dbf4f5c3d1544ab.zip |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts:
drivers/net/wireless/iwmc3200wifi/netdev.c
net/wireless/scan.c
Diffstat (limited to 'net/rfkill')
-rw-r--r-- | net/rfkill/core.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 47497c97c8d9..044de1c6af3d 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -549,6 +549,10 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) swprev = !!(rfkill->state & RFKILL_BLOCK_SW); hwprev = !!(rfkill->state & RFKILL_BLOCK_HW); __rfkill_set_sw_state(rfkill, sw); + if (hw) + rfkill->state |= RFKILL_BLOCK_HW; + else + rfkill->state &= ~RFKILL_BLOCK_HW; spin_unlock_irqrestore(&rfkill->lock, flags); @@ -648,15 +652,26 @@ static ssize_t rfkill_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - /* - * The intention was that userspace can only take control over - * a given device when/if rfkill-input doesn't control it due - * to user_claim. Since user_claim is currently unsupported, - * we never support changing the state from userspace -- this - * can be implemented again later. - */ + struct rfkill *rfkill = to_rfkill(dev); + unsigned long state; + int err; + + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + err = strict_strtoul(buf, 0, &state); + if (err) + return err; + + if (state != RFKILL_USER_STATE_SOFT_BLOCKED && + state != RFKILL_USER_STATE_UNBLOCKED) + return -EINVAL; + + mutex_lock(&rfkill_global_mutex); + rfkill_set_block(rfkill, state == RFKILL_USER_STATE_SOFT_BLOCKED); + mutex_unlock(&rfkill_global_mutex); - return -EPERM; + return err ?: count; } static ssize_t rfkill_claim_show(struct device *dev, |