From: Ivo van Doorn <ivdoorn@gmail.com>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH] rfkill: add master_switch_mode functionality
Date: Wed, 23 Jul 2008 20:39:39 +0200 [thread overview]
Message-ID: <200807232039.39602.IvDoorn@gmail.com> (raw)
In-Reply-To: <1216775046-9506-4-git-send-email-hmh@hmh.eng.br>
On Wednesday 23 July 2008, Henrique de Moraes Holschuh wrote:
> Let the user configure what rfkill-input should do upon EV_SW SW_RFKILL_ALL
> ON.
>
> The mode of operation can be set through the master_switch_mode parameter.
> master_switch_mode 0 does nothing. 1 tries to restore the state before the
> last EV_SW SW_RFKILL_ALL OFF, or the default states of the switches if no
> EV_SW SW_RFKILL_ALL OFF ever happened. 2 tries to unblock all switches
> (default).
>
> Note that the default mode of operation is unchanged.
>
> Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Cc: Ivo van Doorn <IvDoorn@gmail.com>
> ---
> net/rfkill/rfkill-input.c | 129 +++++++++++++++++++++++++++++++++++++--------
> 1 files changed, 107 insertions(+), 22 deletions(-)
>
> diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
> index 827f178..273fb38 100644
> --- a/net/rfkill/rfkill-input.c
> +++ b/net/rfkill/rfkill-input.c
> @@ -23,6 +23,18 @@ MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
> MODULE_DESCRIPTION("Input layer to RF switch connector");
> MODULE_LICENSE("GPL");
>
> +enum rfkill_input_master_mode {
> + RFKILL_INPUT_MASTER_DONOTHING = 0,
> + RFKILL_INPUT_MASTER_RESTORE = 1,
> + RFKILL_INPUT_MASTER_UNBLOCKALL = 2,
RFKILL_INPUT_MASTER_LAST, /* Internal */
See below for reason. :)
> spin_lock_irqsave(&task->lock, flags);
> @@ -114,18 +176,33 @@ static void rfkill_schedule_evsw_rfkillall(int state)
> /* EVERY radio type. state != 0 means radios ON */
> /* handle EPO (emergency power off) through shortcut */
> if (state) {
> - rfkill_schedule_set(&rfkill_wwan,
> - RFKILL_STATE_UNBLOCKED);
> - rfkill_schedule_set(&rfkill_wimax,
> - RFKILL_STATE_UNBLOCKED);
> - rfkill_schedule_set(&rfkill_uwb,
> - RFKILL_STATE_UNBLOCKED);
> - rfkill_schedule_set(&rfkill_bt,
> - RFKILL_STATE_UNBLOCKED);
> - rfkill_schedule_set(&rfkill_wlan,
> - RFKILL_STATE_UNBLOCKED);
> + switch (rfkill_master_switch_mode) {
> + case RFKILL_INPUT_MASTER_UNBLOCKALL:
> + rfkill_schedule_set(&rfkill_wwan,
> + RFKILL_STATE_UNBLOCKED);
> + rfkill_schedule_set(&rfkill_wimax,
> + RFKILL_STATE_UNBLOCKED);
> + rfkill_schedule_set(&rfkill_uwb,
> + RFKILL_STATE_UNBLOCKED);
> + rfkill_schedule_set(&rfkill_bt,
> + RFKILL_STATE_UNBLOCKED);
> + rfkill_schedule_set(&rfkill_wlan,
> + RFKILL_STATE_UNBLOCKED);
> + break;
> + case RFKILL_INPUT_MASTER_RESTORE:
> + rfkill_schedule_global_op(RFKILL_GLOBAL_OP_RESTORE);
> + break;
> + case RFKILL_INPUT_MASTER_DONOTHING:
> + break;
> + default:
> + printk(KERN_ERR
> + "rfkill-input: Illegal value for "
> + "master_switch_mode parameter: %d\n",
> + rfkill_master_switch_mode);
You probably need to move this printk below to rfkill_handler_init()
since there it will return -EINVAL so it won't reach this function.
> + break;
> + }
> } else
> - rfkill_schedule_epo();
> + rfkill_schedule_global_op(RFKILL_GLOBAL_OP_EPO);
> }
>
> static void rfkill_event(struct input_handle *handle, unsigned int type,
> @@ -255,6 +332,14 @@ static struct input_handler rfkill_handler = {
>
> static int __init rfkill_handler_init(void)
> {
> + switch (rfkill_master_switch_mode) {
> + case RFKILL_INPUT_MASTER_DONOTHING:
> + case RFKILL_INPUT_MASTER_RESTORE:
> + case RFKILL_INPUT_MASTER_UNBLOCKALL:
> + break;
> + default:
> + return -EINVAL;
> + }
if (rfkill_master_switch_mode >= RFKILL_INPUT_MASTER_LAST)
return -EINVAL
This will make sure new entries in the enum are automatically handled.
Note that your next patch doesn't update the above switch statement,
and thus always returns -EINVAL when those values are used.
> return input_register_handler(&rfkill_handler);
> }
>
Ivo
next prev parent reply other threads:[~2008-07-23 18:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-23 1:04 [GIT PATCH] RFC: next batch of rfkill changes Henrique de Moraes Holschuh
2008-07-23 1:04 ` [PATCH] rfkill: detect bogus double-registering Henrique de Moraes Holschuh
2008-07-23 3:41 ` Johannes Berg
2008-07-23 15:27 ` Henrique de Moraes Holschuh
2008-07-23 16:30 ` Johannes Berg
2008-07-23 17:41 ` Henrique de Moraes Holschuh
2008-07-23 18:12 ` Ivo van Doorn
2008-07-23 1:04 ` [PATCH] rfkill: add default global states Henrique de Moraes Holschuh
2008-07-23 18:28 ` Ivo van Doorn
2008-07-23 18:42 ` Henrique de Moraes Holschuh
2008-07-23 19:20 ` Ivo van Doorn
2008-07-23 1:04 ` [PATCH] rfkill: add master_switch_mode functionality Henrique de Moraes Holschuh
2008-07-23 18:39 ` Ivo van Doorn [this message]
2008-07-23 19:37 ` Henrique de Moraes Holschuh
2008-07-23 1:04 ` [PATCH] rfkill: add EPO lock to rfkill-input Henrique de Moraes Holschuh
2008-07-23 18:44 ` Ivo van Doorn
2008-07-23 19:01 ` Henrique de Moraes Holschuh
2008-07-23 19:28 ` Ivo van Doorn
2008-07-23 1:04 ` [PATCH] rfkill: rename rfkill_mutex to rfkill_global_mutex Henrique de Moraes Holschuh
2008-07-23 18:44 ` Ivo van Doorn
2008-07-23 1:04 ` [PATCH] rfkill: rate-limit rfkill-input workqueue usage Henrique de Moraes Holschuh
2008-07-23 18:46 ` Ivo van Doorn
2008-07-23 19:43 ` Dmitry Torokhov
2008-07-23 20:27 ` Henrique de Moraes Holschuh
2008-07-23 20:39 ` Dmitry Torokhov
2008-07-23 1:12 ` [GIT PATCH] RFC: next batch of rfkill changes Henrique de Moraes Holschuh
2008-07-23 18:08 ` Ivo van Doorn
2008-07-23 19:09 ` Henrique de Moraes Holschuh
2008-08-01 18:11 ` John W. Linville
2008-08-01 19:35 ` 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=200807232039.39602.IvDoorn@gmail.com \
--to=ivdoorn@gmail.com \
--cc=hmh@hmh.eng.br \
--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 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).