2008-06-28 08:15:07

by drago01

[permalink] [raw]
Subject: [PATCH] iwl3945: add support for RFKILL_STATE_HARD_BLOCKED

This patch fixes iwl3945 to use the new rfkill states and set the
state to RFKILL_STATE_HARD_BLOCKED when the device is blocked by the
hardware killswitch.
This patch depends on the rfkill subsystem patch for iwl3945.
-------
This patch fixes the rfkill states to set RFKILL_STATE_HARD_BLOCKED when the
radio is disabled by a hardware killswitch.
It does not allow setting the sw state while the device is blocked by
a hardware rfkill switch.

Signed-off-by: Adel Gadllah <[email protected]>

diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c
b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 43cb8ff..f390b96 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -537,10 +537,20 @@ static inline int iwl3945_is_init(struct
iwl3945_priv *priv)
return test_bit(STATUS_INIT, &priv->status);
}

+static inline int iwl3945_is_rfkill_sw(struct iwl3945_priv *priv)
+{
+ return test_bit(STATUS_RF_KILL_SW, &priv->status);
+}
+
+static inline int iwl3945_is_rfkill_hw(struct iwl3945_priv *priv)
+{
+ return test_bit(STATUS_RF_KILL_HW, &priv->status);
+}
+
static inline int iwl3945_is_rfkill(struct iwl3945_priv *priv)
{
- return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
- test_bit(STATUS_RF_KILL_SW, &priv->status);
+ return iwl3945_is_rfkill_hw(priv) ||
+ iwl3945_is_rfkill_sw(priv);
}

static inline int iwl3945_is_ready_rf(struct iwl3945_priv *priv)
@@ -8298,19 +8308,23 @@ static int iwl3945_rfkill_soft_rf_kill(void
*data, enum rfkill_state state)
IWL_DEBUG_RF_KILL("we recieved soft RFKILL set to state %d\n", state);
mutex_lock(&priv->mutex);

+ if (iwl3945_is_rfkill_hw(priv)) {
+ err = -EBUSY;
+ goto out;
+ }
+
switch (state) {
- case RFKILL_STATE_ON:
+ case RFKILL_STATE_UNBLOCKED:
iwl3945_radio_kill_sw(priv, 0);
- /* if HW rf-kill is set dont allow ON state */
- if (iwl3945_is_rfkill(priv))
- err = -EBUSY;
break;
- case RFKILL_STATE_OFF:
+ case RFKILL_STATE_SOFT_BLOCKED:
iwl3945_radio_kill_sw(priv, 1);
- if (!iwl3945_is_rfkill(priv))
- err = -EBUSY;
+ break;
+ default:
+ IWL_WARNING("we recieved unexpected RFKILL state %d\n", state);
break;
}
+out:
mutex_unlock(&priv->mutex);

return err;
@@ -8333,7 +8347,7 @@ int iwl3945_rfkill_init(struct iwl3945_priv *priv)

priv->rfkill_mngr.rfkill->name = priv->cfg->name;
priv->rfkill_mngr.rfkill->data = priv;
- priv->rfkill_mngr.rfkill->state = RFKILL_STATE_ON;
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_UNBLOCKED;
priv->rfkill_mngr.rfkill->toggle_radio = iwl3945_rfkill_soft_rf_kill;
priv->rfkill_mngr.rfkill->user_claim_unsupported = 1;

@@ -8408,10 +8422,15 @@ void iwl3945_rfkill_set_hw_state(struct
iwl3945_priv *priv)
if (!priv->rfkill_mngr.rfkill)
return;

- if (!iwl3945_is_rfkill(priv))
- priv->rfkill_mngr.rfkill->state = RFKILL_STATE_ON;
+ if (iwl3945_is_rfkill_hw(priv)) {
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_HARD_BLOCKED;
+ return;
+ }
+
+ if (!iwl3945_is_rfkill_sw(priv))
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_UNBLOCKED;
else
- priv->rfkill_mngr.rfkill->state = RFKILL_STATE_OFF;
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_SOFT_BLOCKED;
}
#endif


Subject: Re: [PATCH] iwl3945: add support for RFKILL_STATE_HARD_BLOCKED

On Sat, 28 Jun 2008, drago01 wrote:
> This patch fixes the rfkill states to set RFKILL_STATE_HARD_BLOCKED when the
> radio is disabled by a hardware killswitch.
> It does not allow setting the sw state while the device is blocked by
> a hardware rfkill switch.

See my comment on your other patch, the device should be able to
double-block.

--
"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

Subject: Re: [PATCHv2] iwl3945: add support for RFKILL_STATE_HARD_BLOCKED

On Sat, 28 Jun 2008, drago01 wrote:
> On Sat, Jun 28, 2008 at 3:17 PM, Henrique de Moraes Holschuh
> <[email protected]> wrote:
> > On Sat, 28 Jun 2008, drago01 wrote:
> >> This patch fixes the rfkill states to set RFKILL_STATE_HARD_BLOCKED when the
> >> radio is disabled by a hardware killswitch.
> >> It does not allow setting the sw state while the device is blocked by
> >> a hardware rfkill switch.
> >
> > See my comment on your other patch, the device should be able to
> > double-block.
>
> OK, see attached patch.

Looks good, same caveat as the other one: I don't know the driver.

--
"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

2008-06-28 13:51:24

by drago01

[permalink] [raw]
Subject: [PATCHv2] iwl3945: add support for RFKILL_STATE_HARD_BLOCKED

On Sat, Jun 28, 2008 at 3:17 PM, Henrique de Moraes Holschuh
<[email protected]> wrote:
> On Sat, 28 Jun 2008, drago01 wrote:
>> This patch fixes the rfkill states to set RFKILL_STATE_HARD_BLOCKED when the
>> radio is disabled by a hardware killswitch.
>> It does not allow setting the sw state while the device is blocked by
>> a hardware rfkill switch.
>
> See my comment on your other patch, the device should be able to
> double-block.

OK, see attached patch.

--------------
This patch fixes the rfkill states to set RFKILL_STATE_HARD_BLOCKED when the
radio is disabled by a hardware killswitch.
It does not allow unblocking the radio state while the device is blocked by
a hardware rfkill switch.

Signed-off-by: Adel Gadllah <[email protected]>

diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c
b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 43cb8ff..4e5309e 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -537,10 +537,20 @@ static inline int iwl3945_is_init(struct
iwl3945_priv *priv)
return test_bit(STATUS_INIT, &priv->status);
}

+static inline int iwl3945_is_rfkill_sw(struct iwl3945_priv *priv)
+{
+ return test_bit(STATUS_RF_KILL_SW, &priv->status);
+}
+
+static inline int iwl3945_is_rfkill_hw(struct iwl3945_priv *priv)
+{
+ return test_bit(STATUS_RF_KILL_HW, &priv->status);
+}
+
static inline int iwl3945_is_rfkill(struct iwl3945_priv *priv)
{
- return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
- test_bit(STATUS_RF_KILL_SW, &priv->status);
+ return iwl3945_is_rfkill_hw(priv) ||
+ iwl3945_is_rfkill_sw(priv);
}

static inline int iwl3945_is_ready_rf(struct iwl3945_priv *priv)
@@ -8299,18 +8309,21 @@ static int iwl3945_rfkill_soft_rf_kill(void
*data, enum rfkill_state state)
mutex_lock(&priv->mutex);

switch (state) {
- case RFKILL_STATE_ON:
- iwl3945_radio_kill_sw(priv, 0);
- /* if HW rf-kill is set dont allow ON state */
- if (iwl3945_is_rfkill(priv))
+ case RFKILL_STATE_UNBLOCKED:
+ if (iwl3945_is_rfkill_hw(priv)) {
err = -EBUSY;
+ goto out_unlock;
+ }
+ iwl3945_radio_kill_sw(priv, 0);
break;
- case RFKILL_STATE_OFF:
+ case RFKILL_STATE_SOFT_BLOCKED:
iwl3945_radio_kill_sw(priv, 1);
- if (!iwl3945_is_rfkill(priv))
- err = -EBUSY;
+ break;
+ default:
+ IWL_WARNING("we recieved unexpected RFKILL state %d\n", state);
break;
}
+out_unlock:
mutex_unlock(&priv->mutex);

return err;
@@ -8333,7 +8346,7 @@ int iwl3945_rfkill_init(struct iwl3945_priv *priv)

priv->rfkill_mngr.rfkill->name = priv->cfg->name;
priv->rfkill_mngr.rfkill->data = priv;
- priv->rfkill_mngr.rfkill->state = RFKILL_STATE_ON;
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_UNBLOCKED;
priv->rfkill_mngr.rfkill->toggle_radio = iwl3945_rfkill_soft_rf_kill;
priv->rfkill_mngr.rfkill->user_claim_unsupported = 1;

@@ -8408,10 +8421,15 @@ void iwl3945_rfkill_set_hw_state(struct
iwl3945_priv *priv)
if (!priv->rfkill_mngr.rfkill)
return;

- if (!iwl3945_is_rfkill(priv))
- priv->rfkill_mngr.rfkill->state = RFKILL_STATE_ON;
+ if (iwl3945_is_rfkill_hw(priv)) {
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_HARD_BLOCKED;
+ return;
+ }
+
+ if (!iwl3945_is_rfkill_sw(priv))
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_UNBLOCKED;
else
- priv->rfkill_mngr.rfkill->state = RFKILL_STATE_OFF;
+ priv->rfkill_mngr.rfkill->state = RFKILL_STATE_SOFT_BLOCKED;
}
#endif