Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111196
b: refs/heads/master
c: 02589f6
h: refs/heads/master
v: v3
  • Loading branch information
Henrique de Moraes Holschuh authored and John W. Linville committed Aug 22, 2008
1 parent a7f3c73 commit c080c3a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 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: c94c93da90a9e46a73a5733ff8454fb4b14733fb
refs/heads/master: 02589f60510030a3c1496e7a8c511e4f674ef5ff
29 changes: 28 additions & 1 deletion trunk/net/rfkill/rfkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,44 @@ static struct class rfkill_class = {
.dev_uevent = rfkill_dev_uevent,
};

static int rfkill_check_duplicity(const struct rfkill *rfkill)
{
struct rfkill *p;
unsigned long seen[BITS_TO_LONGS(RFKILL_TYPE_MAX)];

memset(seen, 0, sizeof(seen));

list_for_each_entry(p, &rfkill_list, node) {
if (p == rfkill) {
WARN_ON(1);
return -EEXIST;
}
set_bit(p->type, seen);
}

/* 0: first switch of its kind */
return test_bit(rfkill->type, seen);
}

static int rfkill_add_switch(struct rfkill *rfkill)
{
int error;

mutex_lock(&rfkill_mutex);

error = rfkill_check_duplicity(rfkill);
if (error < 0)
goto unlock_out;

rfkill_toggle_radio(rfkill, rfkill_states[rfkill->type], 0);

list_add_tail(&rfkill->node, &rfkill_list);

error = 0;
unlock_out:
mutex_unlock(&rfkill_mutex);

return 0;
return error;
}

static void rfkill_remove_switch(struct rfkill *rfkill)
Expand Down

0 comments on commit c080c3a

Please sign in to comment.