Use a bitfield to hold boolean module-wide flags, to conserve some memory.
It is easy and it is clean, so we do it just for the heck of it even if it
saves very little space.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
-static int hotkey_supported;
-static int hotkey_mask_supported;
static int hotkey_orig_status;
static int hotkey_orig_mask;
static int hotkey_orig_status;
static int hotkey_orig_mask;
IBM_HANDLE_INIT(hkey);
/* hotkey not supported on 570 */
IBM_HANDLE_INIT(hkey);
/* hotkey not supported on 570 */
- hotkey_supported = hkey_handle != NULL;
+ tp_features.hotkey = hkey_handle != NULL;
vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n",
vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n",
- str_supported(hotkey_supported));
+ str_supported(tp_features.hotkey));
- if (hotkey_supported) {
+ if (tp_features.hotkey) {
/* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
A30, R30, R31, T20-22, X20-21, X22-24 */
/* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
A30, R30, R31, T20-22, X20-21, X22-24 */
- hotkey_mask_supported =
- acpi_evalf(hkey_handle, NULL, "DHKN", "qv");
+ tp_features.hotkey_mask =
+ acpi_evalf(hkey_handle, NULL, "DHKN", "qv");
vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
- str_supported(hotkey_mask_supported));
+ str_supported(tp_features.hotkey_mask));
if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask))
return -ENODEV;
}
if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask))
return -ENODEV;
}
- return (hotkey_supported)? 0 : 1;
+ return (tp_features.hotkey)? 0 : 1;
}
static void hotkey_exit(void)
{
}
static void hotkey_exit(void)
{
- if (hotkey_supported) {
+ if (tp_features.hotkey) {
dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n");
hotkey_set(hotkey_orig_status, hotkey_orig_mask);
}
dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n");
hotkey_set(hotkey_orig_status, hotkey_orig_mask);
}
if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
return 0;
if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
return 0;
- if (hotkey_mask_supported)
+ if (tp_features.hotkey_mask)
if (!acpi_evalf(hkey_handle, mask, "DHKN", "d"))
return 0;
if (!acpi_evalf(hkey_handle, mask, "DHKN", "d"))
return 0;
if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
return 0;
if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
return 0;
- if (hotkey_mask_supported)
+ if (tp_features.hotkey_mask)
for (i = 0; i < 32; i++) {
int bit = ((1 << i) & mask) != 0;
if (!acpi_evalf(hkey_handle,
for (i = 0; i < 32; i++) {
int bit = ((1 << i) & mask) != 0;
if (!acpi_evalf(hkey_handle,
int status, mask;
int len = 0;
int status, mask;
int len = 0;
- if (!hotkey_supported) {
+ if (!tp_features.hotkey) {
len += sprintf(p + len, "status:\t\tnot supported\n");
return len;
}
len += sprintf(p + len, "status:\t\tnot supported\n");
return len;
}
return -EIO;
len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
return -EIO;
len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
- if (hotkey_mask_supported) {
+ if (tp_features.hotkey_mask) {
len += sprintf(p + len, "mask:\t\t0x%04x\n", mask);
len += sprintf(p + len,
"commands:\tenable, disable, reset, <mask>\n");
len += sprintf(p + len, "mask:\t\t0x%04x\n", mask);
len += sprintf(p + len,
"commands:\tenable, disable, reset, <mask>\n");
char *cmd;
int do_cmd = 0;
char *cmd;
int do_cmd = 0;
+ if (!tp_features.hotkey)
return -ENODEV;
if (!hotkey_get(&status, &mask))
return -ENODEV;
if (!hotkey_get(&status, &mask))
-static int bluetooth_supported;
-
static int __init bluetooth_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
static int __init bluetooth_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
/* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
/* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
- bluetooth_supported = hkey_handle &&
+ tp_features.bluetooth = hkey_handle &&
acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n",
acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n",
- str_supported(bluetooth_supported));
+ str_supported(tp_features.bluetooth));
- return (bluetooth_supported)? 0 : 1;
+ return (tp_features.bluetooth)? 0 : 1;
}
static int bluetooth_status(void)
{
int status;
}
static int bluetooth_status(void)
{
int status;
- if (!bluetooth_supported ||
+ if (!tp_features.bluetooth ||
!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
status = 0;
!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
status = 0;
int len = 0;
int status = bluetooth_status();
int len = 0;
int status = bluetooth_status();
- if (!bluetooth_supported)
+ if (!tp_features.bluetooth)
len += sprintf(p + len, "status:\t\tnot supported\n");
else if (!(status & 1))
len += sprintf(p + len, "status:\t\tnot installed\n");
len += sprintf(p + len, "status:\t\tnot supported\n");
else if (!(status & 1))
len += sprintf(p + len, "status:\t\tnot installed\n");
char *cmd;
int do_cmd = 0;
char *cmd;
int do_cmd = 0;
- if (!bluetooth_supported)
+ if (!tp_features.bluetooth)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
-static int wan_supported;
-
static int __init wan_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
IBM_HANDLE_INIT(hkey);
static int __init wan_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
IBM_HANDLE_INIT(hkey);
- wan_supported = hkey_handle &&
- acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
+ tp_features.wan = hkey_handle &&
+ acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n",
vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n",
- str_supported(wan_supported));
+ str_supported(tp_features.wan));
- return (wan_supported)? 0 : 1;
+ return (tp_features.wan)? 0 : 1;
}
static int wan_status(void)
{
int status;
}
static int wan_status(void)
{
int status;
- if (!wan_supported || !acpi_evalf(hkey_handle, &status, "GWAN", "d"))
+ if (!tp_features.wan ||
+ !acpi_evalf(hkey_handle, &status, "GWAN", "d"))
status = 0;
return status;
status = 0;
return status;
int len = 0;
int status = wan_status();
int len = 0;
int status = wan_status();
len += sprintf(p + len, "status:\t\tnot supported\n");
else if (!(status & 1))
len += sprintf(p + len, "status:\t\tnot installed\n");
len += sprintf(p + len, "status:\t\tnot supported\n");
else if (!(status & 1))
len += sprintf(p + len, "status:\t\tnot installed\n");
char *cmd;
int do_cmd = 0;
char *cmd;
int do_cmd = 0;
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
* Light (thinklight) subdriver
*/
* Light (thinklight) subdriver
*/
-static int light_supported;
-static int light_status_supported;
-
IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */
IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */
IBM_HANDLE_INIT(cmos);
/* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
IBM_HANDLE_INIT(cmos);
/* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
- light_supported = (cmos_handle || lght_handle) && !ledb_handle;
+ tp_features.light = (cmos_handle || lght_handle) && !ledb_handle;
/* light status not supported on
570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
/* light status not supported on
570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
- light_status_supported = acpi_evalf(ec_handle, NULL,
- "KBLT", "qv");
+ tp_features.light_status =
+ acpi_evalf(ec_handle, NULL, "KBLT", "qv");
vdbg_printk(TPACPI_DBG_INIT, "light is %s\n",
vdbg_printk(TPACPI_DBG_INIT, "light is %s\n",
- str_supported(light_supported));
+ str_supported(tp_features.light));
- return (light_supported)? 0 : 1;
+ return (tp_features.light)? 0 : 1;
}
static int light_read(char *p)
}
static int light_read(char *p)
int len = 0;
int status = 0;
int len = 0;
int status = 0;
- if (!light_supported) {
+ if (!tp_features.light) {
len += sprintf(p + len, "status:\t\tnot supported\n");
len += sprintf(p + len, "status:\t\tnot supported\n");
- } else if (!light_status_supported) {
+ } else if (!tp_features.light_status) {
len += sprintf(p + len, "status:\t\tunknown\n");
len += sprintf(p + len, "commands:\ton, off\n");
} else {
len += sprintf(p + len, "status:\t\tunknown\n");
len += sprintf(p + len, "commands:\ton, off\n");
} else {
+ if (!tp_features.light)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
*/
#ifdef CONFIG_THINKPAD_ACPI_BAY
*/
#ifdef CONFIG_THINKPAD_ACPI_BAY
-static int bay_status_supported;
-static int bay_status2_supported;
-static int bay_eject_supported;
-static int bay_eject2_supported;
-
IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
"\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
"\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
"\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
"\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
if (bay2_handle)
IBM_HANDLE_INIT(bay2_ej);
if (bay2_handle)
IBM_HANDLE_INIT(bay2_ej);
- bay_status_supported = bay_handle &&
- acpi_evalf(bay_handle, NULL, "_STA", "qv");
- bay_status2_supported = bay2_handle &&
- acpi_evalf(bay2_handle, NULL, "_STA", "qv");
+ tp_features.bay_status = bay_handle &&
+ acpi_evalf(bay_handle, NULL, "_STA", "qv");
+ tp_features.bay_status2 = bay2_handle &&
+ acpi_evalf(bay2_handle, NULL, "_STA", "qv");
- bay_eject_supported = bay_handle && bay_ej_handle &&
- (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental);
- bay_eject2_supported = bay2_handle && bay2_ej_handle &&
- (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
+ tp_features.bay_eject = bay_handle && bay_ej_handle &&
+ (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental);
+ tp_features.bay_eject2 = bay2_handle && bay2_ej_handle &&
+ (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
vdbg_printk(TPACPI_DBG_INIT,
"bay 1: status %s, eject %s; bay 2: status %s, eject %s\n",
vdbg_printk(TPACPI_DBG_INIT,
"bay 1: status %s, eject %s; bay 2: status %s, eject %s\n",
- str_supported(bay_status_supported),
- str_supported(bay_eject_supported),
- str_supported(bay_status2_supported),
- str_supported(bay_eject2_supported));
+ str_supported(tp_features.bay_status),
+ str_supported(tp_features.bay_eject),
+ str_supported(tp_features.bay_status2),
+ str_supported(tp_features.bay_eject2));
- return (bay_status_supported || bay_eject_supported ||
- bay_status2_supported || bay_eject2_supported)? 0 : 1;
+ return (tp_features.bay_status || tp_features.bay_eject ||
+ tp_features.bay_status2 || tp_features.bay_eject2)? 0 : 1;
}
static void bay_notify(struct ibm_struct *ibm, u32 event)
}
static void bay_notify(struct ibm_struct *ibm, u32 event)
int occupied2 = bay_occupied(bay2);
int eject, eject2;
int occupied2 = bay_occupied(bay2);
int eject, eject2;
- len += sprintf(p + len, "status:\t\t%s\n", bay_status_supported ?
- (occupied ? "occupied" : "unoccupied") :
- "not supported");
- if (bay_status2_supported)
+ len += sprintf(p + len, "status:\t\t%s\n",
+ tp_features.bay_status ?
+ (occupied ? "occupied" : "unoccupied") :
+ "not supported");
+ if (tp_features.bay_status2)
len += sprintf(p + len, "status2:\t%s\n", occupied2 ?
"occupied" : "unoccupied");
len += sprintf(p + len, "status2:\t%s\n", occupied2 ?
"occupied" : "unoccupied");
- eject = bay_eject_supported && occupied;
- eject2 = bay_eject2_supported && occupied2;
+ eject = tp_features.bay_eject && occupied;
+ eject2 = tp_features.bay_eject2 && occupied2;
if (eject && eject2)
len += sprintf(p + len, "commands:\teject, eject2\n");
if (eject && eject2)
len += sprintf(p + len, "commands:\teject, eject2\n");
- if (!bay_eject_supported && !bay_eject2_supported)
+ if (!tp_features.bay_eject && !tp_features.bay_eject2)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
- if (bay_eject_supported && strlencmp(cmd, "eject") == 0) {
+ if (tp_features.bay_eject && strlencmp(cmd, "eject") == 0) {
if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1))
return -EIO;
if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1))
return -EIO;
- } else if (bay_eject2_supported &&
+ } else if (tp_features.bay_eject2 &&
strlencmp(cmd, "eject2") == 0) {
if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1))
return -EIO;
strlencmp(cmd, "eject2") == 0) {
if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1))
return -EIO;
static enum fan_control_access_mode fan_control_access_mode;
static enum fan_control_commands fan_control_commands;
static enum fan_control_access_mode fan_control_access_mode;
static enum fan_control_commands fan_control_commands;
-static int fan_control_status_known;
static u8 fan_control_initial_status;
static void fan_watchdog_fire(struct work_struct *ignored);
static u8 fan_control_initial_status;
static void fan_watchdog_fire(struct work_struct *ignored);
fan_status_access_mode = TPACPI_FAN_NONE;
fan_control_access_mode = TPACPI_FAN_WR_NONE;
fan_control_commands = 0;
fan_status_access_mode = TPACPI_FAN_NONE;
fan_control_access_mode = TPACPI_FAN_WR_NONE;
fan_control_commands = 0;
- fan_control_status_known = 1;
fan_watchdog_maxinterval = 0;
fan_watchdog_maxinterval = 0;
+ tp_features.fan_ctrl_status_undef = 0;
IBM_HANDLE_INIT(fans);
IBM_HANDLE_INIT(gfan);
IBM_HANDLE_INIT(fans);
IBM_HANDLE_INIT(gfan);
"fan_init: initial fan status is "
"unknown, assuming it is in auto "
"mode\n");
"fan_init: initial fan status is "
"unknown, assuming it is in auto "
"mode\n");
- fan_control_status_known = 0;
+ tp_features.fan_ctrl_status_undef = 1;
}
} else {
printk(IBM_ERR
}
} else {
printk(IBM_ERR
if (!acpi_ec_write(fan_status_offset, level))
return -EIO;
else
if (!acpi_ec_write(fan_status_offset, level))
return -EIO;
else
- fan_control_status_known = 1;
+ tp_features.fan_ctrl_status_undef = 0;
if (!acpi_ec_write(fan_status_offset, s))
return -EIO;
else
if (!acpi_ec_write(fan_status_offset, s))
return -EIO;
else
- fan_control_status_known = 1;
+ tp_features.fan_ctrl_status_undef = 0;
break;
case TPACPI_FAN_WR_ACPI_SFAN:
break;
case TPACPI_FAN_WR_ACPI_SFAN:
if (!acpi_ec_write(fan_status_offset, 0x00))
return -EIO;
else
if (!acpi_ec_write(fan_status_offset, 0x00))
return -EIO;
else
- fan_control_status_known = 1;
+ tp_features.fan_ctrl_status_undef = 0;
break;
case TPACPI_FAN_WR_ACPI_SFAN:
break;
case TPACPI_FAN_WR_ACPI_SFAN:
if ((rc = fan_get_status(&status)) < 0)
return rc;
if ((rc = fan_get_status(&status)) < 0)
return rc;
- if (unlikely(!fan_control_status_known)) {
+ if (unlikely(tp_features.fan_ctrl_status_undef)) {
if (status != fan_control_initial_status)
if (status != fan_control_initial_status)
- fan_control_status_known = 1;
+ tp_features.fan_ctrl_status_undef = 0;
else
/* Return most likely status. In fact, it
* might be the only possible status */
else
/* Return most likely status. In fact, it
* might be the only possible status */
struct ibm_struct *data;
};
struct ibm_struct *data;
};
+static struct {
+#ifdef CONFIG_THINKPAD_ACPI_BAY
+ u16 bay_status:1;
+ u16 bay_eject:1;
+ u16 bay_status2:1;
+ u16 bay_eject2:1;
+#endif
+ u16 bluetooth:1;
+ u16 hotkey:1;
+ u16 hotkey_mask:1;
+ u16 light:1;
+ u16 light_status:1;
+ u16 wan:1;
+ u16 fan_ctrl_status_undef:1;
+} tp_features;
+
static struct list_head tpacpi_all_drivers;
static struct ibm_init_struct ibms_init[];
static struct list_head tpacpi_all_drivers;
static struct ibm_init_struct ibms_init[];
*/
#ifdef CONFIG_THINKPAD_ACPI_BAY
*/
#ifdef CONFIG_THINKPAD_ACPI_BAY
-static int bay_status_supported, bay_eject_supported;
-static int bay_status2_supported, bay_eject2_supported;
-
static acpi_handle bay_handle, bay_ej_handle;
static acpi_handle bay2_handle, bay2_ej_handle;
static acpi_handle bay_handle, bay_ej_handle;
static acpi_handle bay2_handle, bay2_ej_handle;
-static int bluetooth_supported;
-
static int bluetooth_init(struct ibm_init_struct *iibm);
static int bluetooth_status(void);
static int bluetooth_read(char *p);
static int bluetooth_init(struct ibm_init_struct *iibm);
static int bluetooth_status(void);
static int bluetooth_read(char *p);
static enum fan_status_access_mode fan_status_access_mode;
static enum fan_control_access_mode fan_control_access_mode;
static enum fan_control_commands fan_control_commands;
static enum fan_status_access_mode fan_status_access_mode;
static enum fan_control_access_mode fan_control_access_mode;
static enum fan_control_commands fan_control_commands;
-static int fan_control_status_known;
static u8 fan_control_initial_status;
static int fan_watchdog_maxinterval;
static u8 fan_control_initial_status;
static int fan_watchdog_maxinterval;
-static int hotkey_supported;
-static int hotkey_mask_supported;
static int hotkey_orig_status;
static int hotkey_orig_mask;
static int hotkey_orig_status;
static int hotkey_orig_mask;
* Light (thinklight) subdriver
*/
* Light (thinklight) subdriver
*/
-static int light_supported;
-static int light_status_supported;
static acpi_handle lght_handle, ledb_handle;
static int light_init(struct ibm_init_struct *iibm);
static acpi_handle lght_handle, ledb_handle;
static int light_init(struct ibm_init_struct *iibm);
-static int wan_supported;
-
static int wan_init(struct ibm_init_struct *iibm);
static int wan_status(void);
static int wan_read(char *p);
static int wan_init(struct ibm_init_struct *iibm);
static int wan_status(void);
static int wan_read(char *p);