Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 103366
b: refs/heads/master
c: 50db787
h: refs/heads/master
v: v3
  • Loading branch information
Ivo van Doorn authored and John W. Linville committed Jul 8, 2008
1 parent 627bec1 commit fe46c57
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 94 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: f2cae6c5e41a979f85463aff60877b31fa3a383d
refs/heads/master: 50db7875d9dcd89f7624b13535738612faf8db0c
8 changes: 3 additions & 5 deletions trunk/drivers/net/wireless/rt2x00/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ config RT2X00_LIB_FIRMWARE
config RT2X00_LIB_RFKILL
boolean
depends on RT2X00_LIB
depends on INPUT
select RFKILL
select INPUT_POLLDEV

config RT2X00_LIB_LEDS
boolean
Expand All @@ -57,7 +55,7 @@ config RT2400PCI

config RT2400PCI_RFKILL
bool "Ralink rt2400 rfkill support"
depends on RT2400PCI && INPUT
depends on RT2400PCI
select RT2X00_LIB_RFKILL
---help---
This adds support for integrated rt2400 hardware that features a
Expand Down Expand Up @@ -85,7 +83,7 @@ config RT2500PCI

config RT2500PCI_RFKILL
bool "Ralink rt2500 rfkill support"
depends on RT2500PCI && INPUT
depends on RT2500PCI
select RT2X00_LIB_RFKILL
---help---
This adds support for integrated rt2500 hardware that features a
Expand Down Expand Up @@ -115,7 +113,7 @@ config RT61PCI

config RT61PCI_RFKILL
bool "Ralink rt2501/rt61 rfkill support"
depends on RT61PCI && INPUT
depends on RT61PCI
select RT2X00_LIB_RFKILL
---help---
This adds support for integrated rt61 hardware that features a
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/wireless/rt2x00/rt2x00.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ struct rt2x00_dev {
#define RFKILL_STATE_ALLOCATED 1
#define RFKILL_STATE_REGISTERED 2
struct rfkill *rfkill;
struct input_polled_dev *poll_dev;
struct delayed_work rfkill_work;
#endif /* CONFIG_RT2X00_LIB_RFKILL */

/*
Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/net/wireless/rt2x00/rt2x00dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,6 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
* Suspend/disable extra components.
*/
rt2x00leds_suspend(rt2x00dev);
rt2x00rfkill_suspend(rt2x00dev);
rt2x00debug_deregister(rt2x00dev);

exit:
Expand Down Expand Up @@ -1235,7 +1234,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
* Restore/enable extra components.
*/
rt2x00debug_register(rt2x00dev);
rt2x00rfkill_resume(rt2x00dev);
rt2x00leds_resume(rt2x00dev);

/*
Expand Down
12 changes: 1 addition & 11 deletions trunk/drivers/net/wireless/rt2x00/rt2x00lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Both the link tuner as the rfkill will be called once per second.
*/
#define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) )
#define RFKILL_POLL_INTERVAL ( 1000 )
#define RFKILL_POLL_INTERVAL ( round_jiffies_relative(HZ) )

/*
* rt2x00_rate: Per rate device information
Expand Down Expand Up @@ -204,8 +204,6 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev);
void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev);
void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev);
void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev);
void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev);
void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev);
#else
static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
{
Expand All @@ -222,14 +220,6 @@ static inline void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
{
}

static inline void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev)
{
}

static inline void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev)
{
}
#endif /* CONFIG_RT2X00_LIB_RFKILL */

/*
Expand Down
107 changes: 33 additions & 74 deletions trunk/drivers/net/wireless/rt2x00/rt2x00rfkill.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
Abstract: rt2x00 rfkill routines.
*/

#include <linux/input-polldev.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/rfkill.h>
Expand Down Expand Up @@ -61,15 +60,35 @@ static int rt2x00rfkill_toggle_radio(void *data, enum rfkill_state state)
return retval;
}

static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev)
static int rt2x00rfkill_get_state(void *data, enum rfkill_state *state)
{
struct rt2x00_dev *rt2x00dev = poll_dev->private;
int state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev);
struct rt2x00_dev *rt2x00dev = data;

if (rt2x00dev->rfkill->state != state) {
input_report_key(poll_dev->input, KEY_WLAN, 1);
input_report_key(poll_dev->input, KEY_WLAN, 0);
}
*state = rt2x00dev->rfkill->state;

return 0;
}

static void rt2x00rfkill_poll(struct work_struct *work)
{
struct rt2x00_dev *rt2x00dev =
container_of(work, struct rt2x00_dev, rfkill_work.work);
int state;

if (!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
return;

/*
* rfkill_poll reports 1 when the key has been pressed and the
* radio should be blocked.
*/
state = !rt2x00dev->ops->lib->rfkill_poll(rt2x00dev) ?
RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;

rfkill_force_state(rt2x00dev->rfkill, state);

queue_delayed_work(rt2x00dev->hw->workqueue,
&rt2x00dev->rfkill_work, RFKILL_POLL_INTERVAL);
}

void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
Expand All @@ -83,20 +102,14 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
return;
}

if (input_register_polled_device(rt2x00dev->poll_dev)) {
ERROR(rt2x00dev, "Failed to register polled device.\n");
rfkill_unregister(rt2x00dev->rfkill);
return;
}

__set_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);

/*
* Force initial poll which will detect the initial device state,
* and correctly sends the signal to the rfkill layer about this
* state.
*/
rt2x00rfkill_poll(rt2x00dev->poll_dev);
rt2x00rfkill_poll(&rt2x00dev->rfkill_work.work);
}

void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
Expand All @@ -105,38 +118,13 @@ void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
return;

input_unregister_polled_device(rt2x00dev->poll_dev);
cancel_delayed_work_sync(&rt2x00dev->rfkill_work);

rfkill_unregister(rt2x00dev->rfkill);

__clear_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);
}

static struct input_polled_dev *
rt2x00rfkill_allocate_polldev(struct rt2x00_dev *rt2x00dev)
{
struct input_polled_dev *poll_dev;

poll_dev = input_allocate_polled_device();
if (!poll_dev)
return NULL;

poll_dev->private = rt2x00dev;
poll_dev->poll = rt2x00rfkill_poll;
poll_dev->poll_interval = RFKILL_POLL_INTERVAL;

poll_dev->input->name = rt2x00dev->ops->name;
poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy);
poll_dev->input->id.bustype = BUS_HOST;
poll_dev->input->id.vendor = 0x1814;
poll_dev->input->id.product = rt2x00dev->chip.rt;
poll_dev->input->id.version = rt2x00dev->chip.rev;
poll_dev->input->dev.parent = wiphy_dev(rt2x00dev->hw->wiphy);
poll_dev->input->evbit[0] = BIT(EV_KEY);
set_bit(KEY_WLAN, poll_dev->input->keybit);

return poll_dev;
}

void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
{
if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
Expand All @@ -153,14 +141,9 @@ void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
rt2x00dev->rfkill->data = rt2x00dev;
rt2x00dev->rfkill->state = -1;
rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio;
rt2x00dev->rfkill->get_state = rt2x00rfkill_get_state;

rt2x00dev->poll_dev = rt2x00rfkill_allocate_polldev(rt2x00dev);
if (!rt2x00dev->poll_dev) {
ERROR(rt2x00dev, "Failed to allocate polled device.\n");
rfkill_free(rt2x00dev->rfkill);
rt2x00dev->rfkill = NULL;
return;
}
INIT_DELAYED_WORK(&rt2x00dev->rfkill_work, rt2x00rfkill_poll);

return;
}
Expand All @@ -171,32 +154,8 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
return;

input_free_polled_device(rt2x00dev->poll_dev);
rt2x00dev->poll_dev = NULL;
cancel_delayed_work_sync(&rt2x00dev->rfkill_work);

rfkill_free(rt2x00dev->rfkill);
rt2x00dev->rfkill = NULL;
}

void rt2x00rfkill_suspend(struct rt2x00_dev *rt2x00dev)
{
if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
return;

input_free_polled_device(rt2x00dev->poll_dev);
rt2x00dev->poll_dev = NULL;
}

void rt2x00rfkill_resume(struct rt2x00_dev *rt2x00dev)
{
if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) ||
!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
return;

rt2x00dev->poll_dev = rt2x00rfkill_allocate_polldev(rt2x00dev);
if (!rt2x00dev->poll_dev) {
ERROR(rt2x00dev, "Failed to allocate polled device.\n");
return;
}
}

0 comments on commit fe46c57

Please sign in to comment.