diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-06-02 07:01:40 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-03 14:06:14 -0400 |
commit | 6081162e2ed78dfcf149b076b047078ab1445cc2 (patch) | |
tree | aef1cf51ee0a8f77f562defe1fe8ec75812474b7 | |
parent | 7643a2c3fcc13cd6fbd731f214463547383418ae (diff) |
rfkill: add function to query state
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>
-rw-r--r-- | include/linux/rfkill.h | 12 | ||||
-rw-r--r-- | net/rfkill/core.c | 13 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h index 7c116f6631b8..ee3eddea8568 100644 --- a/include/linux/rfkill.h +++ b/include/linux/rfkill.h | |||
@@ -261,6 +261,13 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw); | |||
261 | * registered drivers? | 261 | * registered drivers? |
262 | */ | 262 | */ |
263 | void rfkill_set_global_sw_state(const enum rfkill_type type, bool blocked); | 263 | void rfkill_set_global_sw_state(const enum rfkill_type type, bool blocked); |
264 | |||
265 | /** | ||
266 | * rfkill_blocked - query rfkill block | ||
267 | * | ||
268 | * @rfkill: rfkill struct to query | ||
269 | */ | ||
270 | bool rfkill_blocked(struct rfkill *rfkill); | ||
264 | #else /* !RFKILL */ | 271 | #else /* !RFKILL */ |
265 | static inline struct rfkill * __must_check | 272 | static inline struct rfkill * __must_check |
266 | rfkill_alloc(const char *name, | 273 | rfkill_alloc(const char *name, |
@@ -313,6 +320,11 @@ static inline void rfkill_set_global_sw_state(const enum rfkill_type type, | |||
313 | bool blocked) | 320 | bool blocked) |
314 | { | 321 | { |
315 | } | 322 | } |
323 | |||
324 | static inline bool rfkill_blocked(struct rfkill *rfkill) | ||
325 | { | ||
326 | return false; | ||
327 | } | ||
316 | #endif /* RFKILL || RFKILL_MODULE */ | 328 | #endif /* RFKILL || RFKILL_MODULE */ |
317 | 329 | ||
318 | 330 | ||
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 2230aa6b14f3..91e9168b5447 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
@@ -773,6 +773,19 @@ static struct class rfkill_class = { | |||
773 | .resume = rfkill_resume, | 773 | .resume = rfkill_resume, |
774 | }; | 774 | }; |
775 | 775 | ||
776 | bool rfkill_blocked(struct rfkill *rfkill) | ||
777 | { | ||
778 | unsigned long flags; | ||
779 | u32 state; | ||
780 | |||
781 | spin_lock_irqsave(&rfkill->lock, flags); | ||
782 | state = rfkill->state; | ||
783 | spin_unlock_irqrestore(&rfkill->lock, flags); | ||
784 | |||
785 | return !!(state & RFKILL_BLOCK_ANY); | ||
786 | } | ||
787 | EXPORT_SYMBOL(rfkill_blocked); | ||
788 | |||
776 | 789 | ||
777 | struct rfkill * __must_check rfkill_alloc(const char *name, | 790 | struct rfkill * __must_check rfkill_alloc(const char *name, |
778 | struct device *parent, | 791 | struct device *parent, |