From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Subject: [RFT 2/4] rfkill: add function to query state
Date: Thu, 21 May 2009 23:59:42 +0200 [thread overview]
Message-ID: <20090521220104.962925968@sipsolutions.net> (raw)
In-Reply-To: 20090521215940.344214804@sipsolutions.net
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-21 21:55:37.000000000 +0200
+++ wireless-testing/include/linux/rfkill.h 2009-05-21 21:56:00.000000000 +0200
@@ -225,6 +225,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,
@@ -277,6 +284,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-21 21:55:41.000000000 +0200
+++ wireless-testing/net/rfkill/core.c 2009-05-21 21:56:00.000000000 +0200
@@ -862,6 +862,19 @@ void rfkill_destroy(struct rfkill *rfkil
}
EXPORT_SYMBOL(rfkill_destroy);
+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);
+
static int __init rfkill_init(void)
{
--
next prev parent reply other threads:[~2009-05-21 22:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-21 21:59 [RFT 0/4] rfkill improvements Johannes Berg
2009-05-21 21:59 ` [RFT 1/4] net: introduce pre-up netdev notifier Johannes Berg
2009-05-21 21:59 ` Johannes Berg [this message]
2009-05-21 21:59 ` [RFT 3/4] cfg80211: add rfkill support Johannes Berg
2009-05-23 9:52 ` [RFT 3/4 v2] " Johannes Berg
2009-05-24 13:32 ` [RFT 3/4] " Dan Williams
2009-05-24 17:24 ` Johannes Berg
2009-05-26 16:38 ` Marcel Holtmann
2009-05-21 21:59 ` [RFT 4/4] iwlwifi: port to cfg80211 rfkill Johannes Berg
2009-05-23 8:49 ` [RFT 4/4 v2] " Johannes Berg
2009-05-23 8:52 ` [RFT 5/4] iwm: port to new " Johannes Berg
2009-05-25 1:22 ` Zhu Yi
2009-05-25 5:13 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090521220104.962925968@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.