Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johannes Berg and committed by
John W. Linville
6081162e 7643a2c3

+25
+12
include/linux/rfkill.h
··· 261 261 * registered drivers? 262 262 */ 263 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 271 #else /* !RFKILL */ 265 272 static inline struct rfkill * __must_check 266 273 rfkill_alloc(const char *name, ··· 319 312 static inline void rfkill_set_global_sw_state(const enum rfkill_type type, 320 313 bool blocked) 321 314 { 315 + } 316 + 317 + static inline bool rfkill_blocked(struct rfkill *rfkill) 318 + { 319 + return false; 322 320 } 323 321 #endif /* RFKILL || RFKILL_MODULE */ 324 322
+13
net/rfkill/core.c
··· 773 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 790 struct rfkill * __must_check rfkill_alloc(const char *name, 778 791 struct device *parent,