Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 243064
b: refs/heads/master
c: 5c95638
h: refs/heads/master
v: v3
  • Loading branch information
Corentin Chary authored and Matthew Garrett committed Mar 28, 2011
1 parent f32147a commit d56e2fa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 58 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: 7898cf1a3665d22c4d16308f73e981c6464be81b
refs/heads/master: 5c95638d115f9c6661fff254b3beb14b19f88e41
96 changes: 39 additions & 57 deletions trunk/drivers/platform/x86/eeepc-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,29 @@ static acpi_status eeepc_wmi_set_devstate(u32 dev_id, u32 ctrl_param,
return status;
}

/* Helper for special devices with magic return codes */
static int eeepc_wmi_get_devstate_simple(u32 dev_id)
{
u32 retval = 0;
acpi_status status;

status = eeepc_wmi_get_devstate(dev_id, &retval);

if (ACPI_FAILURE(status))
return -EINVAL;

/* If the device is present, DSTS will always set some bits
* 0x00070000 - 1110000000000000000 - device supported
* 0x00060000 - 1100000000000000000 - not supported
* 0x00020000 - 0100000000000000000 - device supported
* 0x00010000 - 0010000000000000000 - not supported / special mode ?
*/
if (!retval || retval == 0x00060000)
return -ENODEV;

return retval & 0x1;
}

/*
* LEDs
*/
Expand Down Expand Up @@ -290,23 +313,7 @@ static void tpd_led_set(struct led_classdev *led_cdev,

static int read_tpd_state(struct eeepc_wmi *eeepc)
{
u32 retval;
acpi_status status;

status = eeepc_wmi_get_devstate(EEEPC_WMI_DEVID_TPDLED, &retval);

if (ACPI_FAILURE(status))
return -1;
else if (!retval || retval == 0x00060000)
/*
* if touchpad led is present, DSTS will set some bits,
* usually 0x00020000.
* 0x00060000 means that the device is not supported
*/
return -ENODEV;
else
/* Status is stored in the first bit */
return retval & 0x1;
return eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_TPDLED);
}

static enum led_brightness tpd_led_get(struct led_classdev *led_cdev)
Expand Down Expand Up @@ -358,15 +365,11 @@ static void eeepc_wmi_led_exit(struct eeepc_wmi *eeepc)
*/
static bool eeepc_wlan_rfkill_blocked(struct eeepc_wmi *eeepc)
{
u32 retval;
acpi_status status;

status = eeepc_wmi_get_devstate(EEEPC_WMI_DEVID_WLAN, &retval);
int result = eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WLAN);

if (ACPI_FAILURE(status))
if (result < 0)
return false;

return !(retval & 0x1);
return !result;
}

static void eeepc_rfkill_hotplug(struct eeepc_wmi *eeepc)
Expand Down Expand Up @@ -494,19 +497,12 @@ static void eeepc_unregister_rfkill_notifier(struct eeepc_wmi *eeepc,
static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
u8 *value)
{
u32 retval;
acpi_status status;

status = eeepc_wmi_get_devstate(EEEPC_WMI_DEVID_WLAN, &retval);

if (ACPI_FAILURE(status))
return -EIO;
int result = eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_WLAN);

if (!retval || retval == 0x00060000)
return -ENODEV;
else
*value = (retval & 0x1);
if (result < 0)
return result;

*value = !!result;
return 0;
}

Expand Down Expand Up @@ -601,15 +597,14 @@ static int eeepc_rfkill_set(void *data, bool blocked)
static void eeepc_rfkill_query(struct rfkill *rfkill, void *data)
{
int dev_id = (unsigned long)data;
u32 retval;
acpi_status status;
int result;

status = eeepc_wmi_get_devstate(dev_id, &retval);
result = eeepc_wmi_get_devstate_simple(dev_id);

if (ACPI_FAILURE(status))
if (result < 0)
return ;

rfkill_set_sw_state(rfkill, !(retval & 0x1));
rfkill_set_sw_state(rfkill, !result);
}

static int eeepc_rfkill_wlan_set(void *data, bool blocked)
Expand Down Expand Up @@ -650,23 +645,10 @@ static int eeepc_new_rfkill(struct eeepc_wmi *eeepc,
const char *name,
enum rfkill_type type, int dev_id)
{
int result;
u32 retval;
acpi_status status;

status = eeepc_wmi_get_devstate(dev_id, &retval);
int result = eeepc_wmi_get_devstate_simple(dev_id);

if (ACPI_FAILURE(status))
return -1;

/* If the device is present, DSTS will always set some bits
* 0x00070000 - 1110000000000000000 - device supported
* 0x00060000 - 1100000000000000000 - not supported
* 0x00020000 - 0100000000000000000 - device supported
* 0x00010000 - 0010000000000000000 - not supported / special mode ?
*/
if (!retval || retval == 0x00060000)
return -ENODEV;
if (result < 0)
return result;

if (dev_id == EEEPC_WMI_DEVID_WLAN && eeepc->hotplug_wireless)
*rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type,
Expand All @@ -678,7 +660,7 @@ static int eeepc_new_rfkill(struct eeepc_wmi *eeepc,
if (!*rfkill)
return -EINVAL;

rfkill_init_sw_state(*rfkill, !(retval & 0x1));
rfkill_init_sw_state(*rfkill, !result);
result = rfkill_register(*rfkill);
if (result) {
rfkill_destroy(*rfkill);
Expand Down

0 comments on commit d56e2fa

Please sign in to comment.