* [PATCH 1/6] rfkill: document rfkill_force_state as required (v2)
2008-07-22 0:18 [GIT PATCH] rfkill fixes, set 2, v2 Henrique de Moraes Holschuh
@ 2008-07-22 0:18 ` 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
` (5 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-22 0:18 UTC (permalink / raw)
To: John Linville; +Cc: linux-wireless, Ivo van Doorn, Henrique de Moraes Holschuh
While the rfkill class does work with just get_state(), it doesn't work
well on devices that are subject to external events that cause rfkill state
changes.
Document that rfkill_force_state() is required in those cases.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
---
Documentation/rfkill.txt | 20 ++++++++++++++++----
net/rfkill/rfkill.c | 7 ++++++-
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/Documentation/rfkill.txt b/Documentation/rfkill.txt
index 0843ed0..28b6ec8 100644
--- a/Documentation/rfkill.txt
+++ b/Documentation/rfkill.txt
@@ -390,9 +390,10 @@ rfkill lines are inactive, it must return RFKILL_STATE_SOFT_BLOCKED if its soft
rfkill input line is active. Only if none of the rfkill input lines are
active, will it return RFKILL_STATE_UNBLOCKED.
-If it doesn't implement the get_state() hook, it must make sure that its calls
-to rfkill_force_state() are enough to keep the status always up-to-date, and it
-must do a rfkill_force_state() on resume from sleep.
+Since the device has a hardware rfkill line, it IS subject to state changes
+external to rfkill. Therefore, the driver must make sure that it calls
+rfkill_force_state() to keep the status always up-to-date, and it must do a
+rfkill_force_state() on resume from sleep.
Every time the driver gets a notification from the card that one of its rfkill
lines changed state (polling might be needed on badly designed cards that don't
@@ -422,13 +423,24 @@ of the hardware is unknown), or read-write (where the hardware can be queried
about its current state).
The rfkill class will call the get_state hook of a device every time it needs
-to know the *real* current state of the hardware. This can happen often.
+to know the *real* current state of the hardware. This can happen often, but
+it does not do any polling, so it is not enough on hardware that is subject
+to state changes outside of the rfkill subsystem.
+
+Therefore, calling rfkill_force_state() when a state change happens is
+mandatory when the device has a hardware rfkill line, or when something else
+like the firmware could cause its state to be changed without going through the
+rfkill class.
Some hardware provides events when its status changes. In these cases, it is
best for the driver to not provide a get_state hook, and instead register the
rfkill class *already* with the correct status, and keep it updated using
rfkill_force_state() when it gets an event from the hardware.
+rfkill_force_state() must be used on the device resume handlers to update the
+rfkill status, should there be any chance of the device status changing during
+the sleep.
+
There is no provision for a statically-allocated rfkill struct. You must
use rfkill_allocate() to allocate one.
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 7a560b7..022fe50 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -252,7 +252,12 @@ EXPORT_SYMBOL_GPL(rfkill_epo);
* a notification by the firmware/hardware of the current *real*
* state of the radio rfkill switch.
*
- * It may not be called from an atomic context.
+ * Devices which are subject to external changes on their rfkill
+ * state (such as those caused by a hardware rfkill line) MUST
+ * have their driver arrange to call rfkill_force_state() as soon
+ * as possible after such a change.
+ *
+ * This function may not be called from an atomic context.
*/
int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state)
{
--
1.5.6.2
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 2/6] rfkill: fix led-trigger unregister order in error unwind
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 ` Henrique de Moraes Holschuh
2008-07-22 0:18 ` [PATCH 3/6] rfkill: document the rfkill struct locking (v2) Henrique de Moraes Holschuh
` (4 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-22 0:18 UTC (permalink / raw)
To: John Linville
Cc: linux-wireless, Ivo van Doorn, Henrique de Moraes Holschuh,
Michael Buesch, Dmitry Baryshkov
rfkill needs to unregister the led trigger AFTER a call to
rfkill_remove_switch(), otherwise it will not update the LED state,
possibly leaving it ON when it should be OFF.
To make led-trigger unregistering safer, guard against unregistering a
trigger twice, and also against issuing trigger events to a led trigger
that was unregistered. This makes the error unwind paths more resilient.
Refer to commit 8a8f1c0437a77cce29c1cb6089f01f22a6d9ca6e,
"rfkill: Register LED triggers before registering switch".
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Cc: Michael Buesch <mb@bu3sch.de>
Cc: Dmitry Baryshkov <dbaryshkov@gmail.com>
---
net/rfkill/rfkill.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 022fe50..fc3a4fd 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -590,8 +590,10 @@ static void rfkill_led_trigger_register(struct rfkill *rfkill)
static void rfkill_led_trigger_unregister(struct rfkill *rfkill)
{
#ifdef CONFIG_RFKILL_LEDS
- if (rfkill->led_trigger.name)
+ if (rfkill->led_trigger.name) {
led_trigger_unregister(&rfkill->led_trigger);
+ rfkill->led_trigger.name = NULL;
+ }
#endif
}
@@ -627,8 +629,8 @@ int rfkill_register(struct rfkill *rfkill)
error = device_add(dev);
if (error) {
- rfkill_led_trigger_unregister(rfkill);
rfkill_remove_switch(rfkill);
+ rfkill_led_trigger_unregister(rfkill);
return error;
}
--
1.5.6.2
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 3/6] rfkill: document the rfkill struct locking (v2)
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 ` 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
` (3 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-22 0:18 UTC (permalink / raw)
To: John Linville
Cc: linux-wireless, Ivo van Doorn, Henrique de Moraes Holschuh,
Ivo van Doorn
Reorder fields in struct rfkill and add comments to make it clear
which fields are protected by rfkill->mutex.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <IvDoorn@gmail.com>
---
include/linux/rfkill.h | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index c5f6e54..741d1a6 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -68,7 +68,8 @@ enum rfkill_state {
* @user_claim_unsupported: Whether the hardware supports exclusive
* RF-kill control by userspace. Set this before registering.
* @user_claim: Set when the switch is controlled exlusively by userspace.
- * @mutex: Guards switch state transitions
+ * @mutex: Guards switch state transitions. It serializes callbacks
+ * and also protects the state.
* @data: Pointer to the RF button drivers private data which will be
* passed along when toggling radio state.
* @toggle_radio(): Mandatory handler to control state of the radio.
@@ -89,12 +90,13 @@ struct rfkill {
const char *name;
enum rfkill_type type;
- enum rfkill_state state;
bool user_claim_unsupported;
bool user_claim;
+ /* the mutex serializes callbacks and also protects
+ * the state */
struct mutex mutex;
-
+ enum rfkill_state state;
void *data;
int (*toggle_radio)(void *data, enum rfkill_state state);
int (*get_state)(void *data, enum rfkill_state *state);
--
1.5.6.2
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 3/6] rfkill: document the rfkill struct locking (v2)
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
0 siblings, 0 replies; 19+ messages in thread
From: Ivo van Doorn @ 2008-07-22 17:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh; +Cc: John Linville, linux-wireless
On Tuesday 22 July 2008, Henrique de Moraes Holschuh wrote:
> Reorder fields in struct rfkill and add comments to make it clear
> which fields are protected by rfkill->mutex.
>
> 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>
> ---
> include/linux/rfkill.h | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
> index c5f6e54..741d1a6 100644
> --- a/include/linux/rfkill.h
> +++ b/include/linux/rfkill.h
> @@ -68,7 +68,8 @@ enum rfkill_state {
> * @user_claim_unsupported: Whether the hardware supports exclusive
> * RF-kill control by userspace. Set this before registering.
> * @user_claim: Set when the switch is controlled exlusively by userspace.
> - * @mutex: Guards switch state transitions
> + * @mutex: Guards switch state transitions. It serializes callbacks
> + * and also protects the state.
> * @data: Pointer to the RF button drivers private data which will be
> * passed along when toggling radio state.
> * @toggle_radio(): Mandatory handler to control state of the radio.
> @@ -89,12 +90,13 @@ struct rfkill {
> const char *name;
> enum rfkill_type type;
>
> - enum rfkill_state state;
> bool user_claim_unsupported;
> bool user_claim;
>
> + /* the mutex serializes callbacks and also protects
> + * the state */
> struct mutex mutex;
> -
> + enum rfkill_state state;
> void *data;
> int (*toggle_radio)(void *data, enum rfkill_state state);
> int (*get_state)(void *data, enum rfkill_state *state);
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/6] rfkill: mutex fixes
2008-07-22 0:18 [GIT PATCH] rfkill fixes, set 2, v2 Henrique de Moraes Holschuh
` (2 preceding siblings ...)
2008-07-22 0:18 ` [PATCH 3/6] rfkill: document the rfkill struct locking (v2) Henrique de Moraes Holschuh
@ 2008-07-22 0:18 ` 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
` (2 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-22 0:18 UTC (permalink / raw)
To: John Linville; +Cc: linux-wireless, Ivo van Doorn, Henrique de Moraes Holschuh
There are two mutexes in rfkill:
rfkill->mutex, which protects some of the fields of a rfkill struct, and is
also used for callback serialization.
rfkill_mutex, which protects the global state, the list of registered
rfkill structs and rfkill->claim.
Make sure to use the correct mutex, and to not miss locking rfkill->mutex
even when we already took rfkill_mutex.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
---
net/rfkill/rfkill.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index fc3a4fd..ac205ec 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -150,7 +150,7 @@ static void update_rfkill_state(struct rfkill *rfkill)
* even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to
* give the driver a hint that it should double-BLOCK the transmitter.
*
- * Caller must have aquired rfkill_mutex.
+ * Caller must have acquired rfkill->mutex.
*/
static int rfkill_toggle_radio(struct rfkill *rfkill,
enum rfkill_state state,
@@ -216,8 +216,11 @@ void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
rfkill_states[type] = state;
list_for_each_entry(rfkill, &rfkill_list, node) {
- if ((!rfkill->user_claim) && (rfkill->type == type))
+ if ((!rfkill->user_claim) && (rfkill->type == type)) {
+ mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill, state, 0);
+ mutex_unlock(&rfkill->mutex);
+ }
}
mutex_unlock(&rfkill_mutex);
@@ -228,7 +231,7 @@ 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.
+ * everything in its path but rfkill_mutex and rfkill->mutex.
*/
void rfkill_epo(void)
{
@@ -236,7 +239,9 @@ void rfkill_epo(void)
mutex_lock(&rfkill_mutex);
list_for_each_entry(rfkill, &rfkill_list, node) {
+ mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
+ mutex_unlock(&rfkill->mutex);
}
mutex_unlock(&rfkill_mutex);
}
@@ -372,6 +377,9 @@ static ssize_t rfkill_claim_store(struct device *dev,
if (!capable(CAP_NET_ADMIN))
return -EPERM;
+ if (rfkill->user_claim_unsupported)
+ return -EOPNOTSUPP;
+
/*
* Take the global lock to make sure the kernel is not in
* the middle of rfkill_switch_all
@@ -380,19 +388,17 @@ static ssize_t rfkill_claim_store(struct device *dev,
if (error)
return error;
- if (rfkill->user_claim_unsupported) {
- error = -EOPNOTSUPP;
- goto out_unlock;
- }
if (rfkill->user_claim != claim) {
- if (!claim)
+ if (!claim) {
+ mutex_lock(&rfkill->mutex);
rfkill_toggle_radio(rfkill,
rfkill_states[rfkill->type],
0);
+ mutex_unlock(&rfkill->mutex);
+ }
rfkill->user_claim = claim;
}
-out_unlock:
mutex_unlock(&rfkill_mutex);
return error ? error : count;
@@ -521,8 +527,11 @@ static void rfkill_remove_switch(struct rfkill *rfkill)
{
mutex_lock(&rfkill_mutex);
list_del_init(&rfkill->node);
- rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
mutex_unlock(&rfkill_mutex);
+
+ mutex_lock(&rfkill->mutex);
+ rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
+ mutex_unlock(&rfkill->mutex);
}
/**
--
1.5.6.2
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
2008-07-22 0:18 [GIT PATCH] rfkill fixes, set 2, v2 Henrique de Moraes Holschuh
` (3 preceding siblings ...)
2008-07-22 0:18 ` [PATCH 4/6] rfkill: mutex fixes Henrique de Moraes Holschuh
@ 2008-07-22 0:18 ` Henrique de Moraes Holschuh
2008-07-22 13:57 ` Dmitry Torokhov
` (2 more replies)
2008-07-22 0:18 ` [PATCH 6/6] rfkill: yet more minor kernel-doc fixes Henrique de Moraes Holschuh
2008-07-22 17:11 ` [GIT PATCH] rfkill fixes, set 2, v2 Ivo van Doorn
6 siblings, 3 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-22 0:18 UTC (permalink / raw)
To: John Linville
Cc: linux-wireless, Ivo van Doorn, Henrique de Moraes Holschuh,
Ivo van Doorn, Dmitry Torokhov
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>
---
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..827f178 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,
};
--
1.5.6.2
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
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
2 siblings, 0 replies; 19+ messages in thread
From: Dmitry Torokhov @ 2008-07-22 13:57 UTC (permalink / raw)
To: Henrique de Moraes Holschuh; +Cc: John Linville, linux-wireless, Ivo van Doorn
On Mon, Jul 21, 2008 at 09:18:21PM -0300, 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>
Looks good, you may add:
Acked-by: Dmitry Torokhov <dtor@mail.ru>
--
Dmitry
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
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
2 siblings, 0 replies; 19+ messages in thread
From: Ivo van Doorn @ 2008-07-22 17:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: John Linville, linux-wireless, Dmitry Torokhov
On Tuesday 22 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>
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..827f178 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,
> };
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
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
2 siblings, 1 reply; 19+ messages in thread
From: John W. Linville @ 2008-07-29 20:53 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: linux-wireless, Ivo van Doorn, Dmitry Torokhov
On Mon, Jul 21, 2008 at 09:18:21PM -0300, Henrique de Moraes Holschuh w=
rote:
> 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 wi=
ll ignore
> the initial switch state.
>=20
> We also need to re-check the states of the EV_SW switches after a dev=
ice that
> was under an exclusive grab is released back to us, since we got no i=
nput
> events from that device while it was grabbed.
>=20
> Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Cc: Ivo van Doorn <IvDoorn@gmail.com>
> Cc: Dmitry Torokhov <dtor@mail.ru>
CC [M] net/rfkill/rfkill-input.o
net/rfkill/rfkill-input.c: In function =E2=80=98rfkill_start=E2=80=99:
net/rfkill/rfkill-input.c:201: warning: passing argument 2 of =E2=80=98=
constant_test_bit=E2=80=99 from incompatible pointer type
net/rfkill/rfkill-input.c:201: warning: passing argument 2 of =E2=80=98=
variable_test_bit=E2=80=99 from incompatible pointer type
net/rfkill/rfkill-input.c:202: warning: passing argument 2 of =E2=80=98=
constant_test_bit=E2=80=99 from incompatible pointer type
net/rfkill/rfkill-input.c:202: warning: passing argument 2 of =E2=80=98=
variable_test_bit=E2=80=99 from incompatible pointer type
net/rfkill/rfkill-input.c:203: warning: passing argument 2 of =E2=80=98=
constant_test_bit=E2=80=99 from incompatible pointer type
net/rfkill/rfkill-input.c:203: warning: passing argument 2 of =E2=80=98=
variable_test_bit=E2=80=99 from incompatible pointer type
Don't you need an index for those evbit, swbit, and sw arrays?
--=20
John W. Linville
linville@tuxdriver.com
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
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-31 13:53 ` [PATCH] " Henrique de Moraes Holschuh
0 siblings, 2 replies; 19+ messages in thread
From: Dmitry Torokhov @ 2008-07-30 1:30 UTC (permalink / raw)
To: John W. Linville
Cc: Henrique de Moraes Holschuh, linux-wireless, Ivo van Doorn
On Tue, Jul 29, 2008 at 04:53:15PM -0400, John W. Linville wrote:
> On Mon, Jul 21, 2008 at 09:18:21PM -0300, 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 mus=
t check the
> > states of the input EV_SW switches and take action. Otherwise, we =
will ignore
> > the initial switch state.
> >=20
> > We also need to re-check the states of the EV_SW switches after a d=
evice that
> > was under an exclusive grab is released back to us, since we got no=
input
> > events from that device while it was grabbed.
> >=20
> > Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> > Cc: Ivo van Doorn <IvDoorn@gmail.com>
> > Cc: Dmitry Torokhov <dtor@mail.ru>
>=20
> CC [M] net/rfkill/rfkill-input.o
> net/rfkill/rfkill-input.c: In function =E2=80=98rfkill_start=E2=80=99=
:
> net/rfkill/rfkill-input.c:201: warning: passing argument 2 of =E2=80=98=
constant_test_bit=E2=80=99 from incompatible pointer type
> net/rfkill/rfkill-input.c:201: warning: passing argument 2 of =E2=80=98=
variable_test_bit=E2=80=99 from incompatible pointer type
> net/rfkill/rfkill-input.c:202: warning: passing argument 2 of =E2=80=98=
constant_test_bit=E2=80=99 from incompatible pointer type
> net/rfkill/rfkill-input.c:202: warning: passing argument 2 of =E2=80=98=
variable_test_bit=E2=80=99 from incompatible pointer type
> net/rfkill/rfkill-input.c:203: warning: passing argument 2 of =E2=80=98=
constant_test_bit=E2=80=99 from incompatible pointer type
> net/rfkill/rfkill-input.c:203: warning: passing argument 2 of =E2=80=98=
variable_test_bit=E2=80=99 from incompatible pointer type
>=20
> Don't you need an index for those evbit, swbit, and sw arrays?
No, we just need to drop the &:
diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
index 827f178..e5b6955 100644
--- a/net/rfkill/rfkill-input.c
+++ b/net/rfkill/rfkill-input.c
@@ -198,10 +198,10 @@ static void rfkill_start(struct input_handle *han=
dle)
* just fine (which event_lock will also avoid). */
spin_lock_irq(&handle->dev->event_lock);
=20
- if (test_bit(EV_SW, &handle->dev->evbit)) {
- if (test_bit(SW_RFKILL_ALL, &handle->dev->swbit))
+ 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));
+ handle->dev->sw));
/* add resync for further EV_SW events here */
}
=20
--=20
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
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
1 sibling, 1 reply; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-30 3:39 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: John W. Linville, linux-wireless, Ivo van Doorn
On Tue, 29 Jul 2008, Dmitry Torokhov wrote:
> On Tue, Jul 29, 2008 at 04:53:15PM -0400, John W. Linville wrote:
> > On Mon, Jul 21, 2008 at 09:18:21PM -0300, 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>
> >
> > CC [M] net/rfkill/rfkill-input.o
> > net/rfkill/rfkill-input.c: In function ???rfkill_start???:
> > net/rfkill/rfkill-input.c:201: warning: passing argument 2 of ???constant_test_bit??? from incompatible pointer type
> > net/rfkill/rfkill-input.c:201: warning: passing argument 2 of ???variable_test_bit??? from incompatible pointer type
> > net/rfkill/rfkill-input.c:202: warning: passing argument 2 of ???constant_test_bit??? from incompatible pointer type
> > net/rfkill/rfkill-input.c:202: warning: passing argument 2 of ???variable_test_bit??? from incompatible pointer type
> > net/rfkill/rfkill-input.c:203: warning: passing argument 2 of ???constant_test_bit??? from incompatible pointer type
> > net/rfkill/rfkill-input.c:203: warning: passing argument 2 of ???variable_test_bit??? from incompatible pointer type
> >
> > Don't you need an index for those evbit, swbit, and sw arrays?
>
> No, we just need to drop the &:
>
> diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
> index 827f178..e5b6955 100644
> --- a/net/rfkill/rfkill-input.c
> +++ b/net/rfkill/rfkill-input.c
> @@ -198,10 +198,10 @@ static void rfkill_start(struct input_handle *handle)
> * 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))
> + if (test_bit(EV_SW, handle->dev->evbit)) {
[...]
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
John, do you want me to fix the patch and resend it, instead of Dmitry's
incremental fix?
Anyway, gcc 4.3 and 4.2 don't complain about the &array here, and
unfortunately my C-spec-fu is not strong enough to know what is wrong with
"&array" instead of just "array", or "&array[0]". They are all equivalent
to gcc 4.2 and 4.3.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 5/6] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
2008-07-30 3:39 ` Henrique de Moraes Holschuh
@ 2008-07-30 4:07 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-30 4:07 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: John W. Linville, linux-wireless, Ivo van Doorn
Hi Dmitry!
On Wed, 30 Jul 2008, Henrique de Moraes Holschuh wrote:
> On Tue, 29 Jul 2008, Dmitry Torokhov wrote:
> > On Tue, Jul 29, 2008 at 04:53:15PM -0400, John W. Linville wrote:
> > > On Mon, Jul 21, 2008 at 09:18:21PM -0300, 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>
> > >
> > > CC [M] net/rfkill/rfkill-input.o
> > > net/rfkill/rfkill-input.c: In function ???rfkill_start???:
> > > net/rfkill/rfkill-input.c:201: warning: passing argument 2 of ???constant_test_bit??? from incompatible pointer type
> > > net/rfkill/rfkill-input.c:201: warning: passing argument 2 of ???variable_test_bit??? from incompatible pointer type
> > > net/rfkill/rfkill-input.c:202: warning: passing argument 2 of ???constant_test_bit??? from incompatible pointer type
> > > net/rfkill/rfkill-input.c:202: warning: passing argument 2 of ???variable_test_bit??? from incompatible pointer type
> > > net/rfkill/rfkill-input.c:203: warning: passing argument 2 of ???constant_test_bit??? from incompatible pointer type
> > > net/rfkill/rfkill-input.c:203: warning: passing argument 2 of ???variable_test_bit??? from incompatible pointer type
> > >
> > > Don't you need an index for those evbit, swbit, and sw arrays?
> >
> > No, we just need to drop the &:
> >
> > diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c
> > index 827f178..e5b6955 100644
> > --- a/net/rfkill/rfkill-input.c
> > +++ b/net/rfkill/rfkill-input.c
> > @@ -198,10 +198,10 @@ static void rfkill_start(struct input_handle *handle)
> > * 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))
> > + if (test_bit(EV_SW, handle->dev->evbit)) {
> [...]
>
> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
>
> John, do you want me to fix the patch and resend it, instead of Dmitry's
> incremental fix?
>
> Anyway, gcc 4.3 and 4.2 don't complain about the &array here, and
> unfortunately my C-spec-fu is not strong enough to know what is wrong with
> "&array" instead of just "array", or "&array[0]". They are all equivalent
> to gcc 4.2 and 4.3.
Oh, I see. type of &swbit is "pointer to unsigned int[]", while swbit (and
&swbit[0]) are "pointer to unsigned int". Bleh. Never mind that the correct
type to be using for *_bit's target would be "pointer to unsigned int[]",
that would be a pain to use most of the time...
Sometimes, I really hate C.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
2008-07-30 1:30 ` Dmitry Torokhov
2008-07-30 3:39 ` Henrique de Moraes Holschuh
@ 2008-07-31 13:53 ` Henrique de Moraes Holschuh
2008-07-31 14:38 ` Ivo van Doorn
1 sibling, 1 reply; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-31 13:53 UTC (permalink / raw)
To: John Linville
Cc: Dmitry Torokhov, linux-wireless, Ivo van Doorn,
Henrique de Moraes Holschuh, Ivo van Doorn, Dmitry Torokhov
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>
---
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,
};
--
1.5.6.3
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
2008-07-31 13:53 ` [PATCH] " Henrique de Moraes Holschuh
@ 2008-07-31 14:38 ` Ivo van Doorn
2008-07-31 14:22 ` Henrique de Moraes Holschuh
0 siblings, 1 reply; 19+ messages in thread
From: Ivo van Doorn @ 2008-07-31 14:38 UTC (permalink / raw)
To: Henrique de Moraes Holschuh
Cc: John Linville, Dmitry Torokhov, linux-wireless, Dmitry Torokhov
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,
> };
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH] rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
2008-07-31 14:38 ` Ivo van Doorn
@ 2008-07-31 14:22 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-31 14:22 UTC (permalink / raw)
To: Ivo van Doorn
Cc: John Linville, Dmitry Torokhov, linux-wireless, Dmitry Torokhov
On Thu, 31 Jul 2008, Ivo van Doorn wrote:
> 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>
Thanks. For reference, this is the same old patch, but with Dmitry's fix to
my &array error that John's gcc complained about.
Not that I have found how to get gcc to give me these warnings yet. Maybe I
haven't tried hard enough :(
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 6/6] rfkill: yet more minor kernel-doc fixes
2008-07-22 0:18 [GIT PATCH] rfkill fixes, set 2, v2 Henrique de Moraes Holschuh
` (4 preceding siblings ...)
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 0:18 ` 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
6 siblings, 1 reply; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-07-22 0:18 UTC (permalink / raw)
To: John Linville
Cc: linux-wireless, Ivo van Doorn, Henrique de Moraes Holschuh,
Ivo van Doorn
For some stupid reason, I sent and old version of the patch minor kernel
doc-fix patch, and it got merged before I noticed the problem. This is an
incremental fix on top.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <IvDoorn@gmail.com>
---
net/rfkill/rfkill.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index ac205ec..c6f2f38 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -130,7 +130,6 @@ static void update_rfkill_state(struct rfkill *rfkill)
/**
* rfkill_toggle_radio - wrapper for toggle_radio hook
- *
* @rfkill: the rfkill struct to use
* @force: calls toggle_radio even if cache says it is not needed,
* and also makes sure notifications of the state will be
@@ -141,8 +140,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.
*
- * Note that @force cannot override a (possibly cached) state of
- * RFKILL_STATE_HARD_BLOCKED. Any device making use of
+ * 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
* rfkill_force_state(), so the cache either is bypassed or valid.
*
@@ -200,12 +199,12 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
/**
* rfkill_switch_all - Toggle state of all switches of given type
- * @type: type of interfaces to be affeceted
+ * @type: type of interfaces to be affected
* @state: the new state
*
- * This function toggles state of all switches of given type unless
- * a specific switch is claimed by userspace in which case it is
- * left alone.
+ * 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).
*/
void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
{
@@ -540,9 +539,10 @@ static void rfkill_remove_switch(struct rfkill *rfkill)
* @type: type of the switch (RFKILL_TYPE_*)
*
* This function should be called by the network driver when it needs
- * rfkill structure. Once the structure is allocated the driver shoud
- * finish its initialization by setting name, private data, enable_radio
+ * rfkill structure. Once the structure is allocated the driver should
+ * finish its initialization by setting the name, private data, enable_radio
* and disable_radio methods and then register it with rfkill_register().
+ *
* NOTE: If registration fails the structure shoudl be freed by calling
* rfkill_free() otherwise rfkill_unregister() should be used.
*/
@@ -574,7 +574,7 @@ EXPORT_SYMBOL(rfkill_allocate);
* rfkill_free - Mark rfkill structure for deletion
* @rfkill: rfkill structure to be destroyed
*
- * Decrements reference count of rfkill structure so it is destroyed.
+ * Decrements reference count of the rfkill structure so it is destroyed.
* Note that rfkill_free() should _not_ be called after rfkill_unregister().
*/
void rfkill_free(struct rfkill *rfkill)
--
1.5.6.2
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 6/6] rfkill: yet more minor kernel-doc fixes
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
0 siblings, 0 replies; 19+ messages in thread
From: Ivo van Doorn @ 2008-07-22 17:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh; +Cc: John Linville, linux-wireless
On Tuesday 22 July 2008, Henrique de Moraes Holschuh wrote:
> For some stupid reason, I sent and old version of the patch minor kernel
> doc-fix patch, and it got merged before I noticed the problem. This is an
> incremental fix on top.
>
> 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>
> ---
> net/rfkill/rfkill.c | 20 ++++++++++----------
> 1 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
> index ac205ec..c6f2f38 100644
> --- a/net/rfkill/rfkill.c
> +++ b/net/rfkill/rfkill.c
> @@ -130,7 +130,6 @@ static void update_rfkill_state(struct rfkill *rfkill)
>
> /**
> * rfkill_toggle_radio - wrapper for toggle_radio hook
> - *
> * @rfkill: the rfkill struct to use
> * @force: calls toggle_radio even if cache says it is not needed,
> * and also makes sure notifications of the state will be
> @@ -141,8 +140,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.
> *
> - * Note that @force cannot override a (possibly cached) state of
> - * RFKILL_STATE_HARD_BLOCKED. Any device making use of
> + * 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
> * rfkill_force_state(), so the cache either is bypassed or valid.
> *
> @@ -200,12 +199,12 @@ static int rfkill_toggle_radio(struct rfkill *rfkill,
>
> /**
> * rfkill_switch_all - Toggle state of all switches of given type
> - * @type: type of interfaces to be affeceted
> + * @type: type of interfaces to be affected
> * @state: the new state
> *
> - * This function toggles state of all switches of given type unless
> - * a specific switch is claimed by userspace in which case it is
> - * left alone.
> + * 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).
> */
> void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state)
> {
> @@ -540,9 +539,10 @@ static void rfkill_remove_switch(struct rfkill *rfkill)
> * @type: type of the switch (RFKILL_TYPE_*)
> *
> * This function should be called by the network driver when it needs
> - * rfkill structure. Once the structure is allocated the driver shoud
> - * finish its initialization by setting name, private data, enable_radio
> + * rfkill structure. Once the structure is allocated the driver should
> + * finish its initialization by setting the name, private data, enable_radio
> * and disable_radio methods and then register it with rfkill_register().
> + *
> * NOTE: If registration fails the structure shoudl be freed by calling
> * rfkill_free() otherwise rfkill_unregister() should be used.
> */
> @@ -574,7 +574,7 @@ EXPORT_SYMBOL(rfkill_allocate);
> * rfkill_free - Mark rfkill structure for deletion
> * @rfkill: rfkill structure to be destroyed
> *
> - * Decrements reference count of rfkill structure so it is destroyed.
> + * Decrements reference count of the rfkill structure so it is destroyed.
> * Note that rfkill_free() should _not_ be called after rfkill_unregister().
> */
> void rfkill_free(struct rfkill *rfkill)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [GIT PATCH] rfkill fixes, set 2, v2
2008-07-22 0:18 [GIT PATCH] rfkill fixes, set 2, v2 Henrique de Moraes Holschuh
` (5 preceding siblings ...)
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
6 siblings, 0 replies; 19+ messages in thread
From: Ivo van Doorn @ 2008-07-22 17:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh; +Cc: John Linville, linux-wireless
On Tuesday 22 July 2008, Henrique de Moraes Holschuh wrote:
>
> Here is the updated version, with all requested corrections.
>
> Ivo, please check if they're as you wanted in the patches still missing
> your acked-by (patches 3, 5).
They look good. Thanks for the update. :)
> There is one extra minor doc-fix patch, patch 6. I found I somehow sent
> an older version for merge (d3d682041a15f69cd335172041a8393e878521e9
> "rfkill: some minor kernel-doc changes for rfkill_toggle_radio"), and
> since I had the fix lying around...
>
> Henrique de Moraes Holschuh (6):
> rfkill: document rfkill_force_state as required (v2)
> rfkill: fix led-trigger unregister order in error unwind
> rfkill: document the rfkill struct locking (v2)
> rfkill: mutex fixes
> rfkill: query EV_SW states when rfkill-input (re)?connects to a input device
> rfkill: yet more minor kernel-doc fixes
>
> Please consider for merging for 2.6.27-rc1, as they are fixes and not
> enhancements.
>
> Patches based on wireless-testing master.
Ivo
^ permalink raw reply [flat|nested] 19+ messages in thread