Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 107087
b: refs/heads/master
c: 064af11
h: refs/heads/master
i:
  107085: 05858b6
  107083: 2e85c53
  107079: 5f7e4c4
  107071: 5fde623
v: v3
  • Loading branch information
Henrique de Moraes Holschuh authored and John W. Linville committed Jul 29, 2008
1 parent 867e7dd commit fa1cba5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f1b23361a0f15497d4c6795a2935b2e98064ddfb
refs/heads/master: 064af1117b4aa64a0e52f6b741df7356ef055142
29 changes: 19 additions & 10 deletions trunk/net/rfkill/rfkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static void update_rfkill_state(struct rfkill *rfkill)
* even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to
* give the driver a hint that it should double-BLOCK the transmitter.
*
* Caller must have aquired rfkill_mutex.
* Caller must have acquired rfkill->mutex.
*/
static int rfkill_toggle_radio(struct rfkill *rfkill,
enum rfkill_state state,
Expand Down Expand Up @@ -216,8 +216,11 @@ void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
rfkill_states[type] = state;

list_for_each_entry(rfkill, &rfkill_list, node) {
if ((!rfkill->user_claim) && (rfkill->type == type))
if ((!rfkill->user_claim) && (rfkill->type == type)) {
mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill, state, 0);
mutex_unlock(&rfkill->mutex);
}
}

mutex_unlock(&rfkill_mutex);
Expand All @@ -228,15 +231,17 @@ EXPORT_SYMBOL(rfkill_switch_all);
* rfkill_epo - emergency power off all transmitters
*
* This kicks all rfkill devices to RFKILL_STATE_SOFT_BLOCKED, ignoring
* everything in its path but rfkill_mutex.
* everything in its path but rfkill_mutex and rfkill->mutex.
*/
void rfkill_epo(void)
{
struct rfkill *rfkill;

mutex_lock(&rfkill_mutex);
list_for_each_entry(rfkill, &rfkill_list, node) {
mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
mutex_unlock(&rfkill->mutex);
}
mutex_unlock(&rfkill_mutex);
}
Expand Down Expand Up @@ -372,6 +377,9 @@ static ssize_t rfkill_claim_store(struct device *dev,
if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (rfkill->user_claim_unsupported)
return -EOPNOTSUPP;

/*
* Take the global lock to make sure the kernel is not in
* the middle of rfkill_switch_all
Expand All @@ -380,19 +388,17 @@ static ssize_t rfkill_claim_store(struct device *dev,
if (error)
return error;

if (rfkill->user_claim_unsupported) {
error = -EOPNOTSUPP;
goto out_unlock;
}
if (rfkill->user_claim != claim) {
if (!claim)
if (!claim) {
mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill,
rfkill_states[rfkill->type],
0);
mutex_unlock(&rfkill->mutex);
}
rfkill->user_claim = claim;
}

out_unlock:
mutex_unlock(&rfkill_mutex);

return error ? error : count;
Expand Down Expand Up @@ -521,8 +527,11 @@ static void rfkill_remove_switch(struct rfkill *rfkill)
{
mutex_lock(&rfkill_mutex);
list_del_init(&rfkill->node);
rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
mutex_unlock(&rfkill_mutex);

mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
mutex_unlock(&rfkill->mutex);
}

/**
Expand Down

0 comments on commit fa1cba5

Please sign in to comment.