public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rfkill: add function to query state
@ 2009-05-29 23:40 Johannes Berg
  0 siblings, 0 replies; only message in thread
From: Johannes Berg @ 2009-05-29 23:40 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless

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>
---
 include/linux/rfkill.h |   12 ++++++++++++
 net/rfkill/core.c      |   13 +++++++++++++
 2 files changed, 25 insertions(+)

--- wireless-testing.orig/include/linux/rfkill.h	2009-05-30 01:38:40.000000000 +0200
+++ wireless-testing/include/linux/rfkill.h	2009-05-30 01:38:44.000000000 +0200
@@ -256,6 +256,13 @@ void rfkill_set_states(struct rfkill *rf
  *	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,
@@ -308,6 +315,11 @@ static inline void rfkill_set_global_sw_
 					      bool blocked)
 {
 }
+
+static inline bool rfkill_blocked(struct rfkill *rfkill)
+{
+	return false;
+}
 #endif /* RFKILL || RFKILL_MODULE */
 
 
--- wireless-testing.orig/net/rfkill/core.c	2009-05-30 01:38:40.000000000 +0200
+++ wireless-testing/net/rfkill/core.c	2009-05-30 01:38:44.000000000 +0200
@@ -756,6 +756,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,



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-29 23:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-29 23:40 [PATCH] rfkill: add function to query state Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox