Skip to content

Commit

Permalink
rfkill: add function to query state
Browse files Browse the repository at this point in the history
Sometimes it is necessary to know how the state is,
and it is easier to query rfkill than keep track of
it somewhere else, so add a function for that. This
could later be expanded to return hard/soft block,
but so far that isn't necessary.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Jun 3, 2009
1 parent 7643a2c commit 6081162
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/linux/rfkill.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
* registered drivers?
*/
void rfkill_set_global_sw_state(const enum rfkill_type type, bool blocked);

/**
* rfkill_blocked - query rfkill block
*
* @rfkill: rfkill struct to query
*/
bool rfkill_blocked(struct rfkill *rfkill);
#else /* !RFKILL */
static inline struct rfkill * __must_check
rfkill_alloc(const char *name,
Expand Down Expand Up @@ -313,6 +320,11 @@ static inline void rfkill_set_global_sw_state(const enum rfkill_type type,
bool blocked)
{
}

static inline bool rfkill_blocked(struct rfkill *rfkill)
{
return false;
}
#endif /* RFKILL || RFKILL_MODULE */


Expand Down
13 changes: 13 additions & 0 deletions net/rfkill/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,19 @@ static struct class rfkill_class = {
.resume = rfkill_resume,
};

bool rfkill_blocked(struct rfkill *rfkill)
{
unsigned long flags;
u32 state;

spin_lock_irqsave(&rfkill->lock, flags);
state = rfkill->state;
spin_unlock_irqrestore(&rfkill->lock, flags);

return !!(state & RFKILL_BLOCK_ANY);
}
EXPORT_SYMBOL(rfkill_blocked);


struct rfkill * __must_check rfkill_alloc(const char *name,
struct device *parent,
Expand Down

0 comments on commit 6081162

Please sign in to comment.