linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivo van Doorn <ivdoorn@gmail.com>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: John Linville <linville@tuxdriver.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-wireless@vger.kernel.org, Dmitry Torokhov <dtor@mail.ru>
Subject: Re: [PATCH] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
Date: Thu, 31 Jul 2008 16:38:09 +0200	[thread overview]
Message-ID: <200807311638.10270.IvDoorn@gmail.com> (raw)
In-Reply-To: <1217512437-20890-1-git-send-email-hmh@hmh.eng.br>

On Thursday 31 July 2008, Henrique de Moraes Holschuh wrote:
> Every time a new input device that is capable of one of the rfkill EV_SW events
> (currently only SW_RFKILL_ALL) is connected to rfkill-input, we must check the
> states of the input EV_SW switches and take action.  Otherwise, we will ignore
> the initial switch state.
> 
> We also need to re-check the states of the EV_SW switches after a device that
> was under an exclusive grab is released back to us, since we got no input
> events from that device while it was grabbed.
> 
> Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Cc: Ivo van Doorn <IvDoorn@gmail.com>
> Cc: Dmitry Torokhov <dtor@mail.ru>

Sounds sane enough for me.

Acked-by: Ivo van Doorn <IvDoorn@gmail.com>

> ---
>  net/rfkill/rfkill-input.c |   54 ++++++++++++++++++++++++++++++++------------
>  1 files changed, 39 insertions(+), 15 deletions(-)
> 
> diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
> index 8aa8227..e5b6955 100644
> --- a/net/rfkill/rfkill-input.c
> +++ b/net/rfkill/rfkill-input.c
> @@ -109,6 +109,25 @@ static DEFINE_RFKILL_TASK(rfkill_uwb, RFKILL_TYPE_UWB);
>  static DEFINE_RFKILL_TASK(rfkill_wimax, RFKILL_TYPE_WIMAX);
>  static DEFINE_RFKILL_TASK(rfkill_wwan, RFKILL_TYPE_WWAN);
>  
> +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);
> +	} else
> +		rfkill_schedule_epo();
> +}
> +
>  static void rfkill_event(struct input_handle *handle, unsigned int type,
>  			unsigned int code, int data)
>  {
> @@ -132,21 +151,7 @@ static void rfkill_event(struct input_handle *handle, unsigned int type,
>  	} else if (type == EV_SW) {
>  		switch (code) {
>  		case SW_RFKILL_ALL:
> -			/* EVERY radio type. data != 0 means radios ON */
> -			/* handle EPO (emergency power off) through shortcut */
> -			if (data) {
> -				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);
> -			} else
> -				rfkill_schedule_epo();
> +			rfkill_schedule_evsw_rfkillall(data);
>  			break;
>  		default:
>  			break;
> @@ -168,6 +173,7 @@ static int rfkill_connect(struct input_handler *handler, struct input_dev *dev,
>  	handle->handler = handler;
>  	handle->name = "rfkill";
>  
> +	/* causes rfkill_start() to be called */
>  	error = input_register_handle(handle);
>  	if (error)
>  		goto err_free_handle;
> @@ -185,6 +191,23 @@ static int rfkill_connect(struct input_handler *handler, struct input_dev *dev,
>  	return error;
>  }
>  
> +static void rfkill_start(struct input_handle *handle)
> +{
> +	/* Take event_lock to guard against configuration changes, we
> +	 * should be able to deal with concurrency with rfkill_event()
> +	 * just fine (which event_lock will also avoid). */
> +	spin_lock_irq(&handle->dev->event_lock);
> +
> +	if (test_bit(EV_SW, handle->dev->evbit)) {
> +		if (test_bit(SW_RFKILL_ALL, handle->dev->swbit))
> +			rfkill_schedule_evsw_rfkillall(test_bit(SW_RFKILL_ALL,
> +							handle->dev->sw));
> +		/* add resync for further EV_SW events here */
> +	}
> +
> +	spin_unlock_irq(&handle->dev->event_lock);
> +}
> +
>  static void rfkill_disconnect(struct input_handle *handle)
>  {
>  	input_close_device(handle);
> @@ -225,6 +248,7 @@ static struct input_handler rfkill_handler = {
>  	.event =	rfkill_event,
>  	.connect =	rfkill_connect,
>  	.disconnect =	rfkill_disconnect,
> +	.start =	rfkill_start,
>  	.name =		"rfkill",
>  	.id_table =	rfkill_ids,
>  };



  reply	other threads:[~2008-07-31 14:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-22  0:18 [GIT PATCH] rfkill fixes, set 2, v2 Henrique de Moraes Holschuh
2008-07-22  0:18 ` [PATCH 1/6] rfkill: document rfkill_force_state as required (v2) Henrique de Moraes Holschuh
2008-07-22  0:18 ` [PATCH 2/6] rfkill: fix led-trigger unregister order in error unwind Henrique de Moraes Holschuh
2008-07-22  0:18 ` [PATCH 3/6] rfkill: document the rfkill struct locking (v2) Henrique de Moraes Holschuh
2008-07-22 17:11   ` Ivo van Doorn
2008-07-22  0:18 ` [PATCH 4/6] rfkill: mutex fixes Henrique de Moraes Holschuh
2008-07-22  0:18 ` [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device Henrique de Moraes Holschuh
2008-07-22 13:57   ` Dmitry Torokhov
2008-07-22 17:11   ` Ivo van Doorn
2008-07-29 20:53   ` John W. Linville
2008-07-30  1:30     ` Dmitry Torokhov
2008-07-30  3:39       ` Henrique de Moraes Holschuh
2008-07-30  4:07         ` Henrique de Moraes Holschuh
2008-07-31 13:53       ` [PATCH] " Henrique de Moraes Holschuh
2008-07-31 14:38         ` Ivo van Doorn [this message]
2008-07-31 14:22           ` Henrique de Moraes Holschuh
2008-07-22  0:18 ` [PATCH 6/6] rfkill: yet more minor kernel-doc fixes Henrique de Moraes Holschuh
2008-07-22 17:11   ` Ivo van Doorn
2008-07-22 17:11 ` [GIT PATCH] rfkill fixes, set 2, v2 Ivo van Doorn

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=200807311638.10270.IvDoorn@gmail.com \
    --to=ivdoorn@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --cc=hmh@hmh.eng.br \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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).