From: "Andrew V. Stepanov" <stanv@altlinux.org>
To: davem@davemloft.net, johannes@sipsolutions.net, linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, Andriy Stepanov <stanv@altlinux.ru>
Subject: [PATCH 1/1] rfkill: add module option to become inactive.
Date: Tue, 27 Sep 2011 14:33:44 +0400 [thread overview]
Message-ID: <1317119624-2974-1-git-send-email-stanv@altlinux.org> (raw)
From: Andriy Stepanov <stanv@altlinux.ru>
Use as:
modprobe rfkill unblocked=1
or
/etc/modprobe.d/options
options rfkill unblocked=1
Signed-off-by: Andriy Stepanov <stanv@altlinux.ru>
---
net/rfkill/core.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index be90640..9d9014a 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -47,6 +47,10 @@
RFKILL_BLOCK_SW_PREV)
#define RFKILL_BLOCK_SW_SETCALL BIT(31)
+int rfkill_unblocked;
+module_param_named(unblocked, rfkill_unblocked, int, 0);
+MODULE_PARM_DESC(unblocked, "rfkill subsystem become inactive.");
+
struct rfkill {
spinlock_t lock;
@@ -455,6 +459,10 @@ bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked)
{
bool ret, change;
+ if (rfkill_unblocked) {
+ return blocked;
+ }
+
ret = __rfkill_set_hw_state(rfkill, blocked, &change);
if (!rfkill->registered)
@@ -486,6 +494,10 @@ bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked)
unsigned long flags;
bool prev, hwblock;
+ if (rfkill_unblocked) {
+ return blocked;
+ }
+
BUG_ON(!rfkill);
spin_lock_irqsave(&rfkill->lock, flags);
@@ -511,6 +523,10 @@ void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked)
{
unsigned long flags;
+ if (rfkill_unblocked) {
+ return;
+ }
+
BUG_ON(!rfkill);
BUG_ON(rfkill->registered);
@@ -526,6 +542,10 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw)
unsigned long flags;
bool swprev, hwprev;
+ if (rfkill_unblocked) {
+ return;
+ }
+
BUG_ON(!rfkill);
spin_lock_irqsave(&rfkill->lock, flags);
@@ -760,6 +780,10 @@ static int rfkill_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
void rfkill_pause_polling(struct rfkill *rfkill)
{
+ if (rfkill_unblocked) {
+ return;
+ }
+
BUG_ON(!rfkill);
if (!rfkill->ops->poll)
@@ -771,6 +795,10 @@ EXPORT_SYMBOL(rfkill_pause_polling);
void rfkill_resume_polling(struct rfkill *rfkill)
{
+ if (rfkill_unblocked) {
+ return;
+ }
+
BUG_ON(!rfkill);
if (!rfkill->ops->poll)
@@ -818,6 +846,10 @@ bool rfkill_blocked(struct rfkill *rfkill)
unsigned long flags;
u32 state;
+ if (rfkill_unblocked) {
+ return false;
+ }
+
spin_lock_irqsave(&rfkill->lock, flags);
state = rfkill->state;
spin_unlock_irqrestore(&rfkill->lock, flags);
@@ -836,6 +868,11 @@ struct rfkill * __must_check rfkill_alloc(const char *name,
struct rfkill *rfkill;
struct device *dev;
+ if (rfkill_unblocked) {
+ printk(KERN_DEBUG "rfkill: ignore object allocation.\n");
+ return ERR_PTR(-ENODEV);
+ }
+
if (WARN_ON(!ops))
return NULL;
@@ -915,6 +952,14 @@ int __must_check rfkill_register(struct rfkill *rfkill)
struct device *dev = &rfkill->dev;
int error;
+ if (rfkill_unblocked) {
+ if (rfkill == ERR_PTR(-ENODEV)) {
+ return 0;
+ } else {
+ return -EINVAL;
+ }
+ }
+
BUG_ON(!rfkill);
mutex_lock(&rfkill_global_mutex);
@@ -978,6 +1023,10 @@ void rfkill_unregister(struct rfkill *rfkill)
{
BUG_ON(!rfkill);
+ if (rfkill_unblocked) {
+ return;
+ }
+
if (rfkill->ops->poll)
cancel_delayed_work_sync(&rfkill->poll_work);
@@ -999,6 +1048,11 @@ EXPORT_SYMBOL(rfkill_unregister);
void rfkill_destroy(struct rfkill *rfkill)
{
+
+ if (rfkill_unblocked) {
+ return;
+ }
+
if (rfkill)
put_device(&rfkill->dev);
}
--
1.7.4.4
next reply other threads:[~2011-09-27 6:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 10:33 Andrew V. Stepanov [this message]
2011-09-27 7:46 ` [PATCH 1/1] rfkill: add module option to become inactive Johannes Berg
2011-09-27 8:03 ` Andrew V. Stepanov
2011-09-27 8:08 ` Johannes Berg
2011-09-27 8:46 ` Andrew V. Stepanov
2011-09-27 8:54 ` Johannes Berg
2011-09-27 9:34 ` Andrew V. Stepanov
2011-09-27 11:08 ` Johannes Berg
2011-09-27 11:50 ` Andrew V. Stepanov
2011-09-27 12:00 ` Johannes Berg
2011-09-29 21:56 ` Henrique de Moraes Holschuh
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=1317119624-2974-1-git-send-email-stanv@altlinux.org \
--to=stanv@altlinux.org \
--cc=davem@davemloft.net \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=stanv@altlinux.ru \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).