From: Ivo van Doorn <ivdoorn@gmail.com>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: John Linville <linville@tuxdriver.com>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH 1/2] rfkill: protect suspended rfkill controllers
Date: Sat, 2 Aug 2008 20:25:11 +0200 [thread overview]
Message-ID: <200808022025.12160.IvDoorn@gmail.com> (raw)
In-Reply-To: <1217699786-20672-2-git-send-email-hmh@hmh.eng.br>
On Saturday 02 August 2008, Henrique de Moraes Holschuh wrote:
> Guard rfkill controllers attached to a rfkill class against state changes
> after class suspend has been issued.
>
> Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Cc: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
> ---
> Documentation/rfkill.txt | 5 +++++
> net/rfkill/rfkill.c | 14 ++++++++++----
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
> index 28b6ec8..6fcb306 100644
> --- a/Documentation/rfkill.txt
> +++ b/Documentation/rfkill.txt
> @@ -363,6 +363,11 @@ This rule exists because users of the rfkill subsystem expect to get (and set,
> when possible) the overall transmitter rfkill state, not of a particular rfkill
> line.
>
> +5. During suspend, the rfkill class will attempt to soft-block the radio
> +through a call to rfkill->toggle_radio, and will try to restore its previous
> +state during resume. After a rfkill class is suspended, it will *not* call
> +rfkill->toggle_radio until it is resumed.
> +
> Example of a WLAN wireless driver connected to the rfkill subsystem:
> --------------------------------------------------------------------
>
> diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
> index d2d4565..35a9994 100644
> --- a/net/rfkill/rfkill.c
> +++ b/net/rfkill/rfkill.c
> @@ -150,6 +150,8 @@ static void update_rfkill_state(struct rfkill *rfkill)
> * calls and handling all the red tape such as issuing notifications
> * if the call is successful.
> *
> + * Suspended devices are not touched at all, and -EAGAIN is returned.
> + *
> * Note that the @force parameter cannot override a (possibly cached)
> * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of
> * RFKILL_STATE_HARD_BLOCKED implements either get_state() or
> @@ -168,6 +170,9 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
> int retval = 0;
> enum rfkill_state oldstate, newstate;
>
> + if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP))
> + return -EBUSY;
> +
> oldstate = rfkill->state;
>
> if (rfkill->get_state && !force &&
> @@ -214,7 +219,7 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
> *
> * This function toggles the state of all switches of given type,
> * unless a specific switch is claimed by userspace (in which case,
> - * that switch is left alone).
> + * that switch is left alone) or suspended.
> */
> void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
> {
> @@ -239,8 +244,8 @@ EXPORT_SYMBOL(rfkill_switch_all);
> /**
> * rfkill_epo - emergency power off all transmitters
> *
> - * This kicks all rfkill devices to RFKILL_STATE_SOFT_BLOCKED, ignoring
> - * everything in its path but rfkill_mutex and rfkill->mutex.
> + * This kicks all non-suspended rfkill devices to RFKILL_STATE_SOFT_BLOCKED,
> + * ignoring everything in its path but rfkill_mutex and rfkill->mutex.
> */
> void rfkill_epo(void)
> {
> @@ -458,13 +463,14 @@ static int rfkill_resume(struct device *dev)
> if (dev->power.power_state.event != PM_EVENT_ON) {
> mutex_lock(&rfkill->mutex);
>
> + dev->power.power_state.event = PM_EVENT_ON;
> +
> /* restore radio state AND notify everybody */
> rfkill_toggle_radio(rfkill, rfkill->state, 1);
>
> mutex_unlock(&rfkill->mutex);
> }
>
> - dev->power.power_state = PMSG_ON;
> return 0;
> }
> #else
next prev parent reply other threads:[~2008-08-02 18:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-02 17:56 [GIT PATCH] rfkill fixes, set 3 Henrique de Moraes Holschuh
2008-08-02 17:56 ` [PATCH 1/2] rfkill: protect suspended rfkill controllers Henrique de Moraes Holschuh
2008-08-02 18:25 ` Ivo van Doorn [this message]
2008-08-02 17:56 ` [PATCH 2/2] rfkill: use strict_strtoul Henrique de Moraes Holschuh
2008-08-02 18:25 ` Ivo van Doorn
2008-08-17 18:16 ` John W. Linville
2008-08-17 19:31 ` Michael Buesch
2008-08-19 21:53 ` 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=200808022025.12160.IvDoorn@gmail.com \
--to=ivdoorn@gmail.com \
--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).