提交 d6f15ed8 编写于 作者: M Marco Chiappero 提交者: Matthew Garrett

sony-laptop: use soft rfkill status stored in hw

The SNC device on recent Vaio laptops also stores the soft status and
leaves it available after reboot. Use it and always set the last soft
and hard status on module load.

[malattia@linux.it: patch taken from a largely modified sony-laptop.c,
smaller modifications to the original code to simplify it]
Signed-off-by: NMattia Dongili <malattia@linux.it>
Signed-off-by: NMatthew Garrett <mjg@redhat.com>
上级 dd258c00
...@@ -1213,7 +1213,7 @@ static int sony_nc_rfkill_set(void *data, bool blocked) ...@@ -1213,7 +1213,7 @@ static int sony_nc_rfkill_set(void *data, bool blocked)
int argument = sony_rfkill_address[(long) data] + 0x100; int argument = sony_rfkill_address[(long) data] + 0x100;
if (!blocked) if (!blocked)
argument |= 0xff0000; argument |= 0x030000;
return sony_call_snc_handle(sony_rfkill_handle, argument, &result); return sony_call_snc_handle(sony_rfkill_handle, argument, &result);
} }
...@@ -1230,7 +1230,7 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, ...@@ -1230,7 +1230,7 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,
enum rfkill_type type; enum rfkill_type type;
const char *name; const char *name;
int result; int result;
bool hwblock; bool hwblock, swblock;
switch (nc_type) { switch (nc_type) {
case SONY_WIFI: case SONY_WIFI:
...@@ -1258,8 +1258,21 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, ...@@ -1258,8 +1258,21 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,
if (!rfk) if (!rfk)
return -ENOMEM; return -ENOMEM;
sony_call_snc_handle(sony_rfkill_handle, 0x200, &result); if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0) {
rfkill_destroy(rfk);
return -1;
}
hwblock = !(result & 0x1); hwblock = !(result & 0x1);
if (sony_call_snc_handle(sony_rfkill_handle,
sony_rfkill_address[nc_type],
&result) < 0) {
rfkill_destroy(rfk);
return -1;
}
swblock = !(result & 0x2);
rfkill_init_sw_state(rfk, swblock);
rfkill_set_hw_state(rfk, hwblock); rfkill_set_hw_state(rfk, hwblock);
err = rfkill_register(rfk); err = rfkill_register(rfk);
...@@ -1295,7 +1308,7 @@ static void sony_nc_rfkill_update(void) ...@@ -1295,7 +1308,7 @@ static void sony_nc_rfkill_update(void)
sony_call_snc_handle(sony_rfkill_handle, argument, &result); sony_call_snc_handle(sony_rfkill_handle, argument, &result);
rfkill_set_states(sony_rfkill_devices[i], rfkill_set_states(sony_rfkill_devices[i],
!(result & 0xf), false); !(result & 0x2), false);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册