Skip to content

Commit

Permalink
ACPI: thinkpad-acpi: prepare for bluetooth and wwan rfkill support
Browse files Browse the repository at this point in the history
Get rid of some forward definitions by moving code around, this will make
the rfkill conversion of wwan and bluetooth a bit cleaner.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
  • Loading branch information
Henrique de Moraes Holschuh committed Jul 21, 2008
1 parent 733e27c commit 07431ec
Showing 1 changed file with 74 additions and 80 deletions.
154 changes: 74 additions & 80 deletions drivers/misc/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2581,8 +2581,37 @@ enum {
TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */
};

static int bluetooth_get_radiosw(void);
static int bluetooth_set_radiosw(int radio_on);
static int bluetooth_get_radiosw(void)
{
int status;

if (!tp_features.bluetooth)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
return -EIO;

return (status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0;
}

static int bluetooth_set_radiosw(int radio_on)
{
int status;

if (!tp_features.bluetooth)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
return -EIO;
if (radio_on)
status |= TP_ACPI_BLUETOOTH_RADIOSSW;
else
status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
return -EIO;

return 0;
}

/* sysfs bluetooth enable ---------------------------------------------- */
static ssize_t bluetooth_enable_show(struct device *dev,
Expand Down Expand Up @@ -2628,6 +2657,12 @@ static const struct attribute_group bluetooth_attr_group = {
.attrs = bluetooth_attributes,
};

static void bluetooth_exit(void)
{
sysfs_remove_group(&tpacpi_pdev->dev.kobj,
&bluetooth_attr_group);
}

static int __init bluetooth_init(struct ibm_init_struct *iibm)
{
int res;
Expand Down Expand Up @@ -2664,44 +2699,6 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
return (tp_features.bluetooth)? 0 : 1;
}

static void bluetooth_exit(void)
{
sysfs_remove_group(&tpacpi_pdev->dev.kobj,
&bluetooth_attr_group);
}

static int bluetooth_get_radiosw(void)
{
int status;

if (!tp_features.bluetooth)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
return -EIO;

return ((status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0);
}

static int bluetooth_set_radiosw(int radio_on)
{
int status;

if (!tp_features.bluetooth)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
return -EIO;
if (radio_on)
status |= TP_ACPI_BLUETOOTH_RADIOSSW;
else
status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
return -EIO;

return 0;
}

/* procfs -------------------------------------------------------------- */
static int bluetooth_read(char *p)
{
Expand Down Expand Up @@ -2756,8 +2753,37 @@ enum {
TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */
};

static int wan_get_radiosw(void);
static int wan_set_radiosw(int radio_on);
static int wan_get_radiosw(void)
{
int status;

if (!tp_features.wan)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
return -EIO;

return (status & TP_ACPI_WANCARD_RADIOSSW) != 0;
}

static int wan_set_radiosw(int radio_on)
{
int status;

if (!tp_features.wan)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
return -EIO;
if (radio_on)
status |= TP_ACPI_WANCARD_RADIOSSW;
else
status &= ~TP_ACPI_WANCARD_RADIOSSW;
if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
return -EIO;

return 0;
}

/* sysfs wan enable ---------------------------------------------------- */
static ssize_t wan_enable_show(struct device *dev,
Expand Down Expand Up @@ -2803,6 +2829,12 @@ static const struct attribute_group wan_attr_group = {
.attrs = wan_attributes,
};

static void wan_exit(void)
{
sysfs_remove_group(&tpacpi_pdev->dev.kobj,
&wan_attr_group);
}

static int __init wan_init(struct ibm_init_struct *iibm)
{
int res;
Expand Down Expand Up @@ -2837,44 +2869,6 @@ static int __init wan_init(struct ibm_init_struct *iibm)
return (tp_features.wan)? 0 : 1;
}

static void wan_exit(void)
{
sysfs_remove_group(&tpacpi_pdev->dev.kobj,
&wan_attr_group);
}

static int wan_get_radiosw(void)
{
int status;

if (!tp_features.wan)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
return -EIO;

return ((status & TP_ACPI_WANCARD_RADIOSSW) != 0);
}

static int wan_set_radiosw(int radio_on)
{
int status;

if (!tp_features.wan)
return -ENODEV;

if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
return -EIO;
if (radio_on)
status |= TP_ACPI_WANCARD_RADIOSSW;
else
status &= ~TP_ACPI_WANCARD_RADIOSSW;
if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
return -EIO;

return 0;
}

/* procfs -------------------------------------------------------------- */
static int wan_read(char *p)
{
Expand Down

0 comments on commit 07431ec

Please sign in to comment.