Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90489
b: refs/heads/master
c: ad97edd
h: refs/heads/master
i:
  90487: 914a43e
v: v3
  • Loading branch information
Mohamed Abbas authored and John W. Linville committed Apr 1, 2008
1 parent 787b81c commit c7f211f
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c8381fdcab98b74f670d879097bab35d97d88400
refs/heads/master: ad97edd2f524940d524c26ae273a4eb23067a7c0
6 changes: 6 additions & 0 deletions trunk/drivers/net/wireless/iwlwifi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ config IWLWIFI_LEDS
This option enables LEDS for the iwlwifi drivers


config IWLCORE_RFKILL
boolean "IWLWIFI RF kill support"
depends on IWLCORE
select RFKILL
select RFKILL_INPUT

config IWL4965
tristate "Intel Wireless WiFi 4965AGN"
depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/net/wireless/iwlwifi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ ifeq ($(CONFIG_IWLWIFI_LEDS),y)
iwlcore-objs += iwl-led.o
endif

ifeq ($(CONFIG_IWLCORE_RFKILL),y)
iwlcore-objs += iwl-rfkill.o
endif

obj-$(CONFIG_IWL3945) += iwl3945.o
iwl3945-objs = iwl3945-base.o iwl-3945.o iwl-3945-rs.o

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/net/wireless/iwlwifi/iwl-4965.c
Original file line number Diff line number Diff line change
Expand Up @@ -4961,6 +4961,7 @@ static struct iwl_lib_ops iwl4965_lib = {
.acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
.release_semaphore = iwlcore_eeprom_release_semaphore,
},
.radio_kill_sw = iwl4965_radio_kill_sw,
};

static struct iwl_ops iwl4965_ops = {
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/net/wireless/iwlwifi/iwl-4965.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
extern struct pci_device_id iwl4965_hw_card_ids[];

#define DRV_NAME "iwl4965"
#include "iwl-rfkill.h"
#include "iwl-eeprom.h"
#include "iwl-4965-hw.h"
#include "iwl-csr.h"
Expand Down Expand Up @@ -739,6 +740,7 @@ extern int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index
extern int iwl4965_queue_space(const struct iwl4965_queue *q);
struct iwl_priv;

extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio);
/*
* Forward declare iwl-4965.c functions for iwl-base.c
*/
Expand Down Expand Up @@ -1050,6 +1052,9 @@ struct iwl_priv {
* 4965's initialize alive response contains some calibration data. */
struct iwl4965_init_alive_resp card_alive_init;
struct iwl4965_alive_resp card_alive;
#ifdef CONFIG_IWLCORE_RFKILL
struct iwl_rfkill_mngr rfkill_mngr;
#endif

#ifdef CONFIG_IWL4965_LEDS
struct iwl4965_led led[IWL_LED_TRG_MAX];
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/net/wireless/iwlwifi/iwl-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct iwl_priv; /* FIXME: remove */
#include "iwl-debug.h"
#include "iwl-eeprom.h"
#include "iwl-core.h"
#include "iwl-rfkill.h"

#include "iwl-4965.h" /* FIXME: remove */

Expand Down Expand Up @@ -257,12 +258,15 @@ int iwlcore_low_level_notify(struct iwl_priv *priv,
{
switch (notify) {
case IWLCORE_INIT_EVT:
iwl_rfkill_init(priv);
break;
case IWLCORE_START_EVT:
break;
case IWLCORE_STOP_EVT:
break;
case IWLCORE_REMOVE_EVT:
iwl_rfkill_unregister(priv);
iwl_rfkill_free(priv);
break;
}

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/net/wireless/iwlwifi/iwl-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct iwl_lib_ops {
int (*init_drv)(struct iwl_priv *priv);
/* eeprom operations (as defined in iwl-eeprom.h) */
struct iwl_eeprom_ops eeprom_ops;
void (*radio_kill_sw)(struct iwl_priv *priv, int disable_radio);
};

struct iwl_ops {
Expand Down
174 changes: 174 additions & 0 deletions trunk/drivers/net/wireless/iwlwifi/iwl-rfkill.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/******************************************************************************
*
* Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project, as well
* as portions of the ieee80211 subsystem header files.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* James P. Ketrenos <ipw2100-admin@linux.intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/init.h>

#include <net/mac80211.h>

#include "iwl-eeprom.h"
#include "iwl-core.h"
#include "iwl-4965.h"
#include "iwl-helpers.h"


static inline int iwl_is_rfkill(struct iwl_priv *priv)
{
return test_bit(STATUS_RF_KILL_HW, &priv->status) ||
test_bit(STATUS_RF_KILL_SW, &priv->status);
}


/* software rf-kill from user */
static int iwl_rfkill_soft_rf_kill(void *data, enum rfkill_state state)
{
struct iwl_priv *priv = data;
int err = 0;

if (!priv->rfkill_mngr.rfkill)
return 0;

IWL_DEBUG_RF_KILL("we recieved soft RFKILL set to state %d\n", state);
mutex_lock(&priv->mutex);

switch (state) {
case RFKILL_STATE_ON:
priv->cfg->ops->lib->radio_kill_sw(priv, 0);
/* if HW rf-kill is set dont allow ON state */
if (iwl_is_rfkill(priv))
err = -EBUSY;
break;
case RFKILL_STATE_OFF:
priv->cfg->ops->lib->radio_kill_sw(priv, 1);
if (!iwl_is_rfkill(priv))
err = -EBUSY;
break;
}
mutex_unlock(&priv->mutex);

return err;
}

int iwl_rfkill_init(struct iwl_priv *priv)
{
struct device *device = wiphy_dev(priv->hw->wiphy);
int ret = 0;

BUG_ON(device == NULL);

priv->rfkill_mngr.rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
if (!priv->rfkill_mngr.rfkill) {
ret = -ENOMEM;
goto error;
}

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->toggle_radio = iwl_rfkill_soft_rf_kill;
priv->rfkill_mngr.rfkill->user_claim_unsupported = 1;

priv->rfkill_mngr.rfkill->dev.class->suspend = NULL;
priv->rfkill_mngr.rfkill->dev.class->resume = NULL;

priv->rfkill_mngr.input_dev = input_allocate_device();
if (!priv->rfkill_mngr.input_dev) {
ret = -ENOMEM;
goto freed_rfkill;
}

priv->rfkill_mngr.input_dev->name = priv->cfg->name;
priv->rfkill_mngr.input_dev->phys = wiphy_name(priv->hw->wiphy);
priv->rfkill_mngr.input_dev->id.bustype = BUS_HOST;
priv->rfkill_mngr.input_dev->id.vendor = priv->pci_dev->vendor;
priv->rfkill_mngr.input_dev->dev.parent = device;
priv->rfkill_mngr.input_dev->evbit[0] = BIT(EV_KEY);
set_bit(KEY_WLAN, priv->rfkill_mngr.input_dev->keybit);

ret = rfkill_register(priv->rfkill_mngr.rfkill);
if (ret)
goto free_input_dev;

ret = input_register_device(priv->rfkill_mngr.input_dev);
if (ret)
goto unregister_rfkill;

return ret;

unregister_rfkill:
rfkill_unregister(priv->rfkill_mngr.rfkill);

free_input_dev:
input_free_device(priv->rfkill_mngr.input_dev);
priv->rfkill_mngr.input_dev = NULL;

freed_rfkill:
rfkill_free(priv->rfkill_mngr.rfkill);
priv->rfkill_mngr.rfkill = NULL;

error:
return ret;
}
EXPORT_SYMBOL(iwl_rfkill_init);

void iwl_rfkill_unregister(struct iwl_priv *priv)
{

if (priv->rfkill_mngr.input_dev)
input_unregister_device(priv->rfkill_mngr.input_dev);

if (priv->rfkill_mngr.rfkill)
rfkill_unregister(priv->rfkill_mngr.rfkill);
}
EXPORT_SYMBOL(iwl_rfkill_unregister);


void iwl_rfkill_free(struct iwl_priv *priv)
{
if (priv->rfkill_mngr.input_dev)
input_free_device(priv->rfkill_mngr.input_dev);

if (priv->rfkill_mngr.rfkill)
rfkill_free(priv->rfkill_mngr.rfkill);
}
EXPORT_SYMBOL(iwl_rfkill_free);

/* set rf-kill to the right state. */
void iwl_rfkill_set_hw_state(struct iwl_priv *priv)
{

if (!priv->rfkill_mngr.rfkill)
return;

if (!iwl_is_rfkill(priv))
priv->rfkill_mngr.rfkill->state = RFKILL_STATE_ON;
else
priv->rfkill_mngr.rfkill->state = RFKILL_STATE_OFF;
}
EXPORT_SYMBOL(iwl_rfkill_set_hw_state);
56 changes: 56 additions & 0 deletions trunk/drivers/net/wireless/iwlwifi/iwl-rfkill.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2008 Intel Corporation. All rights reserved.
*
* Portions of this file are derived from the ipw3945 project, as well
* as portions of the ieee80211 subsystem header files.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* James P. Ketrenos <ipw2100-admin@linux.intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*****************************************************************************/
#ifndef __iwl_rf_kill_h__
#define __iwl_rf_kill_h__

struct iwl_priv;

#include <linux/rfkill.h>
#include <linux/input.h>


#ifdef CONFIG_IWLCORE_RFKILL
struct iwl_rfkill_mngr {
struct rfkill *rfkill;
struct input_dev *input_dev;
};

void iwl_rfkill_set_hw_state(struct iwl_priv *priv);
void iwl_rfkill_free(struct iwl_priv *priv);
void iwl_rfkill_unregister(struct iwl_priv *priv);
int iwl_rfkill_init(struct iwl_priv *priv);
#else
static inline void iwl_rfkill_set_hw_state(struct iwl_priv *priv) {}
static inline void iwl_rfkill_free(struct iwl_priv *priv) {}
static inline void iwl_rfkill_unregister(struct iwl_priv *priv) {}
static inline int iwl_rfkill_init(struct iwl_priv *priv) { return 0; }
#endif



#endif /* __iwl_rf_kill_h__ */
Loading

0 comments on commit c7f211f

Please sign in to comment.