* [PATCH 01/20] ACPI: thinkpad-acpi: rename register_ibmacpi_subdriver
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 02/20] ACPI: thinkpad-acpi: rename one stray use of ibm-acpi in a comment Henrique de Moraes Holschuh
` (15 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Rename register_ibmacpi_subdriver to register_tpacpi_subdriver, as
we are not called ibmacpi anymore.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 4 ++--
drivers/misc/thinkpad_acpi.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index ddaedf8..cac73e5 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -345,7 +345,7 @@ static int __init ibm_device_add(struct acpi_device *device)
return 0;
}
-static int __init register_ibmacpi_subdriver(struct ibm_struct *ibm)
+static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
{
int ret;
@@ -2574,7 +2574,7 @@ static int __init ibm_init(struct ibm_struct *ibm)
return 0;
if (ibm->hid) {
- ret = register_ibmacpi_subdriver(ibm);
+ ret = register_tpacpi_subdriver(ibm);
if (ret < 0)
return ret;
ibm->driver_registered = 1;
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 015c02b..b86e574 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -157,7 +157,7 @@ static void ibm_exit(struct ibm_struct *ibm);
static void dispatch_notify(acpi_handle handle, u32 event, void *data);
static int setup_notify(struct ibm_struct *ibm);
static int ibm_device_add(struct acpi_device *device);
-static int register_ibmacpi_subdriver(struct ibm_struct *ibm);
+static int register_tpacpi_subdriver(struct ibm_struct *ibm);
/*
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 02/20] ACPI: thinkpad-acpi: rename one stray use of ibm-acpi in a comment
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-04-21 14:08 ` [PATCH 01/20] ACPI: thinkpad-acpi: rename register_ibmacpi_subdriver Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 03/20] ACPI: thinkpad-acpi: rename module glue Henrique de Moraes Holschuh
` (14 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Rename a stray use of ibm-acpi on a comment, no functional changes.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index cac73e5..4b43486 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -459,7 +459,7 @@ static char *next_cmd(char **cmds)
****************************************************************************/
/*************************************************************************
- * ibm-acpi init subdriver
+ * thinkpad-acpi init subdriver
*/
static int thinkpad_acpi_driver_init(void)
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 03/20] ACPI: thinkpad-acpi: rename module glue
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-04-21 14:08 ` [PATCH 01/20] ACPI: thinkpad-acpi: rename register_ibmacpi_subdriver Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 02/20] ACPI: thinkpad-acpi: rename one stray use of ibm-acpi in a comment Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 06/20] ACPI: thinkpad-acpi: add debug mode Henrique de Moraes Holschuh
` (13 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Rename module init and exit functions, now that we are not called ibm-acpi
anymore.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 12 ++++++------
drivers/misc/thinkpad_acpi.h | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 4b43486..80ef195 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -2707,7 +2707,7 @@ IBM_PARAM(brightness);
IBM_PARAM(volume);
IBM_PARAM(fan);
-static int __init acpi_ibm_init(void)
+static int __init thinkpad_acpi_module_init(void)
{
int ret, i;
@@ -2754,7 +2754,7 @@ static int __init acpi_ibm_init(void)
proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
if (!proc_dir) {
printk(IBM_ERR "unable to create proc dir %s", IBM_DIR);
- acpi_ibm_exit();
+ thinkpad_acpi_module_exit();
return -ENODEV;
}
proc_dir->owner = THIS_MODULE;
@@ -2764,7 +2764,7 @@ static int __init acpi_ibm_init(void)
if (ret >= 0 && *ibms[i].param)
ret = ibms[i].write(ibms[i].param);
if (ret < 0) {
- acpi_ibm_exit();
+ thinkpad_acpi_module_exit();
return ret;
}
}
@@ -2772,7 +2772,7 @@ static int __init acpi_ibm_init(void)
return 0;
}
-static void acpi_ibm_exit(void)
+static void thinkpad_acpi_module_exit(void)
{
int i;
@@ -2786,5 +2786,5 @@ static void acpi_ibm_exit(void)
kfree(ibm_thinkpad_ec_found);
}
-module_init(acpi_ibm_init);
-module_exit(acpi_ibm_exit);
+module_init(thinkpad_acpi_module_init);
+module_exit(thinkpad_acpi_module_exit);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index b86e574..8b2fd1a 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -115,8 +115,8 @@ static int experimental;
static char *ibm_thinkpad_ec_found;
static char* check_dmi_for_ec(void);
-static int acpi_ibm_init(void);
-static void acpi_ibm_exit(void);
+static int thinkpad_acpi_module_init(void);
+static void thinkpad_acpi_module_exit(void);
/****************************************************************************
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 06/20] ACPI: thinkpad-acpi: add debug mode
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (2 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 03/20] ACPI: thinkpad-acpi: rename module glue Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 07/20] ACPI: thinkpad-acpi: clean up probing and move init to subdrivers Henrique de Moraes Holschuh
` (12 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Add a debug mode parameter and verbose debug mode Kconfig option.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
Documentation/thinkpad-acpi.txt | 13 +++++++++++++
drivers/misc/Kconfig | 10 ++++++++++
drivers/misc/thinkpad_acpi.c | 3 +++
drivers/misc/thinkpad_acpi.h | 13 +++++++++++++
4 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index af18d29..82fd822 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -699,3 +699,16 @@ for example:
modprobe thinkpad_acpi hotkey=enable,0xffff video=auto_disable
+Enabling debugging output
+-------------------------
+
+The module takes a debug paramater which can be used to selectively
+enable various classes of debugging output, for example:
+
+ modprobe ibm_acpi debug=0xffff
+
+will enable all debugging output classes. It takes a bitmask, so
+to enable more than one output class, just add their values.
+
+There is also a kernel build option to enable more debugging
+information, which may be necessary to debug driver problems.
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 2cd96a3..44e4c8f 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -137,6 +137,16 @@ config THINKPAD_ACPI
If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
+config THINKPAD_ACPI_DEBUG
+ bool "Verbose debug mode"
+ depends on THINKPAD_ACPI
+ default n
+ ---help---
+ Enables extra debugging information, at the expense of a slightly
+ increase in driver size.
+
+ If you are not sure, say N here.
+
config THINKPAD_ACPI_DOCK
bool "Legacy Docking Station Support"
depends on THINKPAD_ACPI
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 4131a78..7fa906f 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -2684,6 +2684,9 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
static int experimental;
module_param(experimental, int, 0);
+static u32 dbg_level;
+module_param_named(debug, dbg_level, uint, 0);
+
#define IBM_PARAM(feature) \
module_param_call(feature, set_ibm_param, NULL, NULL, 0)
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 02a297e..b2348d7 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -74,6 +74,18 @@
#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
#define strlencmp(a,b) (strncmp((a), (b), strlen(b)))
+/* Debugging */
+#define TPACPI_DBG_ALL 0xffff
+#define dbg_printk(a_dbg_level, format, arg...) \
+ do { if (dbg_level & a_dbg_level) \
+ printk(IBM_DEBUG "%s: " format, __func__ , ## arg); } while (0)
+#ifdef CONFIG_THINKPAD_ACPI_DEBUG
+#define vdbg_printk(a_dbg_level, format, arg...) \
+ dbg_printk(a_dbg_level, format, ## arg)
+#else
+#define vdbg_printk(a_dbg_level, format, arg...)
+#endif
+
/* ACPI HIDs */
#define IBM_HKEY_HID "IBM0068"
#define IBM_PCI_HID "PNP0A03"
@@ -112,6 +124,7 @@ static char *next_cmd(char **cmds);
/* Module */
static int experimental;
+static u32 dbg_level;
static char *ibm_thinkpad_ec_found;
static char* check_dmi_for_ec(void);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 07/20] ACPI: thinkpad-acpi: clean up probing and move init to subdrivers
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (3 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 06/20] ACPI: thinkpad-acpi: add debug mode Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 08/20] ACPI: thinkpad-acpi: add subdriver debug statements Henrique de Moraes Holschuh
` (11 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Move most of the probing code to its own function, and most of the
subdriver-specific init code into subdriver init functions.
This allows us to not define pci_handle unless the dock subdriver is
enabled, as well.
This patch causes a minor userland interface change: if a subdriver doesn't
detect a capability, /proc entries for it are not created anymore (as
opposed to a /proc entry that just returned "unsupported").
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 231 +++++++++++++++++++++++++++---------------
drivers/misc/thinkpad_acpi.h | 4 +-
2 files changed, 151 insertions(+), 84 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 7fa906f..eeab394 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -277,9 +277,9 @@ static int _sta(acpi_handle handle)
* ACPI device model
*/
-static void __init ibm_handle_init(char *name,
- acpi_handle * handle, acpi_handle parent,
- char **paths, int num_paths, char **path)
+static void ibm_handle_init(char *name,
+ acpi_handle *handle, acpi_handle parent,
+ char **paths, int num_paths, char **path)
{
int i;
acpi_status status;
@@ -351,8 +351,8 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
if (!ibm->driver) {
- printk(IBM_ERR "kmalloc(ibm->driver) failed\n");
- return -1;
+ printk(IBM_ERR "kzalloc(ibm->driver) failed\n");
+ return -ENOMEM;
}
sprintf(ibm->driver->name, "%s_%s", IBM_NAME, ibm->name);
@@ -364,7 +364,9 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
ibm->hid, ret);
kfree(ibm->driver);
- }
+ ibm->driver = NULL;
+ } else if (!ret)
+ ibm->driver_registered = 1;
return ret;
}
@@ -495,6 +497,8 @@ static int hotkey_orig_mask;
static int hotkey_init(void)
{
+ IBM_HANDLE_INIT(hkey);
+
/* hotkey not supported on 570 */
hotkey_supported = hkey_handle != NULL;
@@ -508,13 +512,14 @@ static int hotkey_init(void)
return -ENODEV;
}
- return 0;
+ return (hotkey_supported)? 0 : 1;
}
static void hotkey_exit(void)
{
- if (hotkey_supported)
+ if (hotkey_supported) {
hotkey_set(hotkey_orig_status, hotkey_orig_mask);
+ }
}
static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -628,12 +633,14 @@ static int bluetooth_supported;
static int bluetooth_init(void)
{
+ IBM_HANDLE_INIT(hkey);
+
/* 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 &&
acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
- return 0;
+ return (bluetooth_supported)? 0 : 1;
}
static int bluetooth_status(void)
@@ -697,10 +704,12 @@ static int wan_supported;
static int wan_init(void)
{
+ IBM_HANDLE_INIT(hkey);
+
wan_supported = hkey_handle &&
acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
- return 0;
+ return (wan_supported)? 0 : 1;
}
static int wan_status(void)
@@ -775,6 +784,9 @@ static int video_init(void)
{
int ivga;
+ IBM_HANDLE_INIT(vid);
+ IBM_HANDLE_INIT(vid2);
+
if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga)
/* G41, assume IVGA doesn't change */
vid_handle = vid2_handle;
@@ -792,7 +804,7 @@ static int video_init(void)
/* all others */
video_supported = TPACPI_VIDEO_NEW;
- return 0;
+ return (video_supported != TPACPI_VIDEO_NONE)? 0 : 1;
}
static void video_exit(void)
@@ -979,6 +991,10 @@ IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */
static int light_init(void)
{
+ IBM_HANDLE_INIT(ledb);
+ IBM_HANDLE_INIT(lght);
+ IBM_HANDLE_INIT(cmos);
+
/* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
light_supported = (cmos_handle || lght_handle) && !ledb_handle;
@@ -988,7 +1004,7 @@ static int light_init(void)
light_status_supported = acpi_evalf(ec_handle, NULL,
"KBLT", "qv");
- return 0;
+ return (light_supported)? 0 : 1;
}
static int light_read(char *p)
@@ -1044,9 +1060,6 @@ static int light_write(char *buf)
* Dock subdriver
*/
-/* don't list other alternatives as we install a notify handler on the 570 */
-IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
-
#ifdef CONFIG_THINKPAD_ACPI_DOCK
IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
@@ -1055,8 +1068,19 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
"\\_SB.PCI.ISA.SLCE", /* 570 */
); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
+/* don't list other alternatives as we install a notify handler on the 570 */
+IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
+
#define dock_docked() (_sta(dock_handle) & 1)
+static int dock_init(void)
+{
+ IBM_HANDLE_INIT(dock);
+ IBM_HANDLE_INIT(pci);
+
+ return (dock_handle)? 0 : 1;
+}
+
static void dock_notify(struct ibm_struct *ibm, u32 event)
{
int docked = dock_docked();
@@ -1147,6 +1171,13 @@ IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */
static int bay_init(void)
{
+ IBM_HANDLE_INIT(bay);
+ if (bay_handle)
+ IBM_HANDLE_INIT(bay_ej);
+ IBM_HANDLE_INIT(bay2);
+ 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 &&
@@ -1157,7 +1188,8 @@ static int bay_init(void)
bay_eject2_supported = bay2_handle && bay2_ej_handle &&
(strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
- return 0;
+ return (bay_status_supported || bay_eject_supported ||
+ bay_status2_supported || bay_eject2_supported)? 0 : 1;
}
static void bay_notify(struct ibm_struct *ibm, u32 event)
@@ -1221,6 +1253,13 @@ static int bay_write(char *buf)
* CMOS subdriver
*/
+static int cmos_init(void)
+{
+ IBM_HANDLE_INIT(cmos);
+
+ return (cmos_handle)? 0 : 1;
+}
+
static int cmos_eval(int cmos_cmd)
{
if (cmos_handle)
@@ -1281,6 +1320,8 @@ IBM_HANDLE(led, ec, "SLED", /* 570 */
static int led_init(void)
{
+ IBM_HANDLE_INIT(led);
+
if (!led_handle)
/* led not supported on R30, R31 */
led_supported = TPACPI_LED_NONE;
@@ -1294,7 +1335,7 @@ static int led_init(void)
/* all others */
led_supported = TPACPI_LED_NEW;
- return 0;
+ return (led_supported != TPACPI_LED_NONE)? 0 : 1;
}
#define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
@@ -1391,6 +1432,13 @@ static int led_write(char *buf)
IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */
+static int beep_init(void)
+{
+ IBM_HANDLE_INIT(beep);
+
+ return (beep_handle)? 0 : 1;
+}
+
static int beep_read(char *p)
{
int len = 0;
@@ -1436,7 +1484,9 @@ static int thermal_init(void)
{
u8 t, ta1, ta2;
int i;
- int acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
+ int acpi_tmp7;
+
+ acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
if (ibm_thinkpad_ec_found && experimental) {
/*
@@ -1492,7 +1542,7 @@ static int thermal_init(void)
thermal_read_mode = TPACPI_THERMAL_NONE;
}
- return 0;
+ return (thermal_read_mode != TPACPI_THERMAL_NONE)? 0 : 1;
}
static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s)
@@ -1973,6 +2023,10 @@ static int fan_init(void)
fan_control_status_known = 1;
fan_watchdog_maxinterval = 0;
+ IBM_HANDLE_INIT(fans);
+ IBM_HANDLE_INIT(gfan);
+ IBM_HANDLE_INIT(sfan);
+
if (gfan_handle) {
/* 570, 600e/x, 770e, 770x */
fan_status_access_mode = TPACPI_FAN_RD_ACPI_GFAN;
@@ -2010,7 +2064,7 @@ static int fan_init(void)
printk(IBM_ERR
"ThinkPad ACPI EC access misbehaving, "
"fan status and control unavailable\n");
- return 0;
+ return 1;
}
}
@@ -2041,7 +2095,9 @@ static int fan_init(void)
}
}
- return 0;
+ return (fan_status_access_mode != TPACPI_FAN_NONE ||
+ fan_control_access_mode != TPACPI_FAN_WR_NONE)?
+ 0 : 1;
}
static int fan_get_status(u8 *status)
@@ -2485,6 +2541,7 @@ static struct ibm_struct ibms[] = {
#ifdef CONFIG_THINKPAD_ACPI_DOCK
{
.name = "dock",
+ .init = dock_init,
.read = dock_read,
.write = dock_write,
.notify = dock_notify,
@@ -2512,6 +2569,7 @@ static struct ibm_struct ibms[] = {
#endif /* CONFIG_THINKPAD_ACPI_BAY */
{
.name = "cmos",
+ .init = cmos_init,
.read = cmos_read,
.write = cmos_write,
},
@@ -2523,6 +2581,7 @@ static struct ibm_struct ibms[] = {
},
{
.name = "beep",
+ .init = beep_init,
.read = beep_read,
.write = beep_write,
},
@@ -2571,20 +2630,33 @@ static int __init ibm_init(struct ibm_struct *ibm)
if (ibm->experimental && !experimental)
return 0;
- if (ibm->hid) {
- ret = register_tpacpi_subdriver(ibm);
- if (ret < 0)
- return ret;
- ibm->driver_registered = 1;
- }
-
if (ibm->init) {
ret = ibm->init();
- if (ret != 0)
+ if (ret > 0)
+ return 0; /* probe failed */
+ if (ret)
return ret;
ibm->init_called = 1;
}
+ if (ibm->hid) {
+ ret = register_tpacpi_subdriver(ibm);
+ if (ret)
+ goto err_out;
+ }
+
+ if (ibm->notify) {
+ ret = setup_notify(ibm);
+ if (ret == -ENODEV) {
+ printk(IBM_NOTICE "disabling subdriver %s\n",
+ ibm->name);
+ ret = 0;
+ goto err_out;
+ }
+ if (ret < 0)
+ goto err_out;
+ }
+
if (ibm->read) {
entry = create_proc_entry(ibm->name,
S_IFREG | S_IRUGO | S_IWUSR,
@@ -2592,7 +2664,8 @@ static int __init ibm_init(struct ibm_struct *ibm)
if (!entry) {
printk(IBM_ERR "unable to create proc entry %s\n",
ibm->name);
- return -ENODEV;
+ ret = -ENODEV;
+ goto err_out;
}
entry->owner = THIS_MODULE;
entry->data = ibm;
@@ -2602,36 +2675,36 @@ static int __init ibm_init(struct ibm_struct *ibm)
ibm->proc_created = 1;
}
- if (ibm->notify) {
- ret = setup_notify(ibm);
- if (ret == -ENODEV) {
- printk(IBM_NOTICE "disabling subdriver %s\n",
- ibm->name);
- ibm_exit(ibm);
- return 0;
- }
- if (ret < 0)
- return ret;
- }
-
return 0;
+
+err_out:
+ ibm_exit(ibm);
+ return (ret < 0)? ret : 0;
}
static void ibm_exit(struct ibm_struct *ibm)
{
- if (ibm->notify_installed)
+ if (ibm->notify_installed) {
acpi_remove_notify_handler(*ibm->handle, ibm->type,
dispatch_notify);
+ ibm->notify_installed = 0;
+ }
- if (ibm->proc_created)
+ if (ibm->proc_created) {
remove_proc_entry(ibm->name, proc_dir);
-
- if (ibm->init_called && ibm->exit)
- ibm->exit();
+ ibm->proc_created = 0;
+ }
if (ibm->driver_registered) {
acpi_bus_unregister_driver(ibm->driver);
kfree(ibm->driver);
+ ibm->driver = NULL;
+ ibm->driver_registered = 0;
+ }
+
+ if (ibm->init_called && ibm->exit) {
+ ibm->exit();
+ ibm->init_called = 0;
}
}
@@ -2663,6 +2736,32 @@ static char* __init check_dmi_for_ec(void)
return NULL;
}
+static int __init probe_for_thinkpad(void)
+{
+ int is_thinkpad;
+
+ if (acpi_disabled)
+ return -ENODEV;
+
+ /*
+ * Non-ancient models have better DMI tagging, but very old models
+ * don't.
+ */
+ is_thinkpad = dmi_name_in_vendors("ThinkPad");
+
+ /* ec is required because many other handles are relative to it */
+ IBM_HANDLE_INIT(ec);
+ if (!ec_handle) {
+ if (is_thinkpad)
+ printk(IBM_ERR
+ "Not yet supported ThinkPad detected!\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+
/* Module init, exit, parameters */
static int __init set_ibm_param(const char *val, struct kernel_param *kp)
@@ -2712,45 +2811,13 @@ static int __init thinkpad_acpi_module_init(void)
{
int ret, i;
- if (acpi_disabled)
- return -ENODEV;
+ ret = probe_for_thinkpad();
+ if (ret)
+ return ret;
- /* ec is required because many other handles are relative to it */
- IBM_HANDLE_INIT(ec);
- if (!ec_handle) {
- printk(IBM_ERR "ec object not found\n");
- return -ENODEV;
- }
-
- /* Models with newer firmware report the EC in DMI */
ibm_thinkpad_ec_found = check_dmi_for_ec();
-
- /* these handles are not required */
- IBM_HANDLE_INIT(vid);
- IBM_HANDLE_INIT(vid2);
- IBM_HANDLE_INIT(ledb);
- IBM_HANDLE_INIT(led);
- IBM_HANDLE_INIT(hkey);
- IBM_HANDLE_INIT(lght);
- IBM_HANDLE_INIT(cmos);
-#ifdef CONFIG_THINKPAD_ACPI_DOCK
- IBM_HANDLE_INIT(dock);
-#endif
- IBM_HANDLE_INIT(pci);
-#ifdef CONFIG_THINKPAD_ACPI_BAY
- IBM_HANDLE_INIT(bay);
- if (bay_handle)
- IBM_HANDLE_INIT(bay_ej);
- IBM_HANDLE_INIT(bay2);
- if (bay2_handle)
- IBM_HANDLE_INIT(bay2_ej);
-#endif /* CONFIG_THINKPAD_ACPI_BAY */
- IBM_HANDLE_INIT(beep);
IBM_HANDLE_INIT(ecrd);
IBM_HANDLE_INIT(ecwr);
- IBM_HANDLE_INIT(fans);
- IBM_HANDLE_INIT(gfan);
- IBM_HANDLE_INIT(sfan);
proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
if (!proc_dir) {
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index b2348d7..06d4c38 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -104,7 +104,7 @@ static acpi_handle ecrd_handle, ecwr_handle; /* 570 EC access */
static acpi_handle cmos_handle, hkey_handle; /* basic thinkpad handles */
static void ibm_handle_init(char *name,
- acpi_handle * handle, acpi_handle parent,
+ acpi_handle *handle, acpi_handle parent,
char **paths, int num_paths, char **path);
#define IBM_HANDLE_INIT(object) \
ibm_handle_init(#object, &object##_handle, *object##_parent, \
@@ -242,8 +242,8 @@ static int cmos_write(char *buf);
* Dock subdriver
*/
-static acpi_handle pci_handle;
#ifdef CONFIG_THINKPAD_ACPI_DOCK
+static acpi_handle pci_handle;
static acpi_handle dock_handle;
static void dock_notify(struct ibm_struct *ibm, u32 event);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 08/20] ACPI: thinkpad-acpi: add subdriver debug statements
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (4 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 07/20] ACPI: thinkpad-acpi: clean up probing and move init to subdrivers Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 10/20] ACPI: thinkpad-acpi: improve thinkpad detection Henrique de Moraes Holschuh
` (10 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Add debug messages to the subdriver initialization and exit code.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
Documentation/thinkpad-acpi.txt | 4 ++
drivers/misc/thinkpad_acpi.c | 111 +++++++++++++++++++++++++++++++++++++++
drivers/misc/thinkpad_acpi.h | 4 ++
3 files changed, 119 insertions(+), 0 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 82fd822..20d5ec3 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -710,5 +710,9 @@ enable various classes of debugging output, for example:
will enable all debugging output classes. It takes a bitmask, so
to enable more than one output class, just add their values.
+ Debug bitmask Description
+ 0x0001 Initialization and probing
+ 0x0002 Removal
+
There is also a kernel build option to enable more debugging
information, which may be necessary to debug driver problems.
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index eeab394..e8fc8da 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -313,6 +313,9 @@ static int __init setup_notify(struct ibm_struct *ibm)
if (!*ibm->handle)
return 0;
+ dbg_printk(TPACPI_DBG_INIT,
+ "setting up ACPI notify for %s\n", ibm->name);
+
ret = acpi_bus_get_device(*ibm->handle, &ibm->device);
if (ret < 0) {
printk(IBM_ERR "%s device not present\n", ibm->name);
@@ -349,6 +352,9 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
{
int ret;
+ dbg_printk(TPACPI_DBG_INIT,
+ "registering %s as an ACPI driver\n", ibm->name);
+
ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
if (!ibm->driver) {
printk(IBM_ERR "kzalloc(ibm->driver) failed\n");
@@ -497,17 +503,25 @@ static int hotkey_orig_mask;
static int hotkey_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
+
IBM_HANDLE_INIT(hkey);
/* hotkey not supported on 570 */
hotkey_supported = hkey_handle != NULL;
+ vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n",
+ str_supported(hotkey_supported));
+
if (hotkey_supported) {
/* 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");
+ vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
+ str_supported(hotkey_mask_supported));
+
if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask))
return -ENODEV;
}
@@ -518,6 +532,7 @@ static int hotkey_init(void)
static void hotkey_exit(void)
{
if (hotkey_supported) {
+ dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n");
hotkey_set(hotkey_orig_status, hotkey_orig_mask);
}
}
@@ -633,6 +648,8 @@ static int bluetooth_supported;
static int bluetooth_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
+
IBM_HANDLE_INIT(hkey);
/* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
@@ -640,6 +657,9 @@ static int bluetooth_init(void)
bluetooth_supported = hkey_handle &&
acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
+ vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n",
+ str_supported(bluetooth_supported));
+
return (bluetooth_supported)? 0 : 1;
}
@@ -704,11 +724,16 @@ static int wan_supported;
static int wan_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
+
IBM_HANDLE_INIT(hkey);
wan_supported = hkey_handle &&
acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
+ vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n",
+ str_supported(wan_supported));
+
return (wan_supported)? 0 : 1;
}
@@ -784,6 +809,8 @@ static int video_init(void)
{
int ivga;
+ vdbg_printk(TPACPI_DBG_INIT, "initializing video subdriver\n");
+
IBM_HANDLE_INIT(vid);
IBM_HANDLE_INIT(vid2);
@@ -804,11 +831,16 @@ static int video_init(void)
/* all others */
video_supported = TPACPI_VIDEO_NEW;
+ vdbg_printk(TPACPI_DBG_INIT, "video is %s, mode %d\n",
+ str_supported(video_supported != TPACPI_VIDEO_NONE),
+ video_supported);
+
return (video_supported != TPACPI_VIDEO_NONE)? 0 : 1;
}
static void video_exit(void)
{
+ dbg_printk(TPACPI_DBG_EXIT, "restoring original video autoswitch mode\n");
acpi_evalf(vid_handle, NULL, "_DOS", "vd", video_orig_autosw);
}
@@ -991,6 +1023,8 @@ IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */
static int light_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing light subdriver\n");
+
IBM_HANDLE_INIT(ledb);
IBM_HANDLE_INIT(lght);
IBM_HANDLE_INIT(cmos);
@@ -1004,6 +1038,9 @@ static int light_init(void)
light_status_supported = acpi_evalf(ec_handle, NULL,
"KBLT", "qv");
+ vdbg_printk(TPACPI_DBG_INIT, "light is %s\n",
+ str_supported(light_supported));
+
return (light_supported)? 0 : 1;
}
@@ -1075,9 +1112,14 @@ IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
static int dock_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n");
+
IBM_HANDLE_INIT(dock);
IBM_HANDLE_INIT(pci);
+ vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n",
+ str_supported(dock_handle != NULL));
+
return (dock_handle)? 0 : 1;
}
@@ -1171,6 +1213,8 @@ IBM_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */
static int bay_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing bay subdriver\n");
+
IBM_HANDLE_INIT(bay);
if (bay_handle)
IBM_HANDLE_INIT(bay_ej);
@@ -1188,6 +1232,13 @@ static int bay_init(void)
bay_eject2_supported = 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",
+ str_supported(bay_status_supported),
+ str_supported(bay_eject_supported),
+ str_supported(bay_status2_supported),
+ str_supported(bay_eject2_supported));
+
return (bay_status_supported || bay_eject_supported ||
bay_status2_supported || bay_eject2_supported)? 0 : 1;
}
@@ -1255,8 +1306,13 @@ static int bay_write(char *buf)
static int cmos_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT,
+ "initializing cmos commands subdriver\n");
+
IBM_HANDLE_INIT(cmos);
+ vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n",
+ str_supported(cmos_handle != NULL));
return (cmos_handle)? 0 : 1;
}
@@ -1320,6 +1376,8 @@ IBM_HANDLE(led, ec, "SLED", /* 570 */
static int led_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing LED subdriver\n");
+
IBM_HANDLE_INIT(led);
if (!led_handle)
@@ -1335,6 +1393,9 @@ static int led_init(void)
/* all others */
led_supported = TPACPI_LED_NEW;
+ vdbg_printk(TPACPI_DBG_INIT, "LED commands are %s, mode %d\n",
+ str_supported(led_supported), led_supported);
+
return (led_supported != TPACPI_LED_NONE)? 0 : 1;
}
@@ -1434,8 +1495,13 @@ IBM_HANDLE(beep, ec, "BEEP"); /* all except R30, R31 */
static int beep_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing beep subdriver\n");
+
IBM_HANDLE_INIT(beep);
+ vdbg_printk(TPACPI_DBG_INIT, "beep is %s\n",
+ str_supported(beep_handle != NULL));
+
return (beep_handle)? 0 : 1;
}
@@ -1486,6 +1552,8 @@ static int thermal_init(void)
int i;
int acpi_tmp7;
+ vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
+
acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
if (ibm_thinkpad_ec_found && experimental) {
@@ -1542,6 +1610,10 @@ static int thermal_init(void)
thermal_read_mode = TPACPI_THERMAL_NONE;
}
+ vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
+ str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
+ thermal_read_mode);
+
return (thermal_read_mode != TPACPI_THERMAL_NONE)? 0 : 1;
}
@@ -1698,6 +1770,8 @@ static int brightness_init(void)
{
int b;
+ vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
+
b = brightness_get(NULL);
if (b < 0)
return b;
@@ -1708,6 +1782,7 @@ static int brightness_init(void)
printk(IBM_ERR "Could not register backlight device\n");
return PTR_ERR(ibm_backlight_device);
}
+ vdbg_printk(TPACPI_DBG_INIT, "brightness is supported\n");
ibm_backlight_device->props.max_brightness = 7;
ibm_backlight_device->props.brightness = b;
@@ -1719,6 +1794,8 @@ static int brightness_init(void)
static void brightness_exit(void)
{
if (ibm_backlight_device) {
+ vdbg_printk(TPACPI_DBG_EXIT,
+ "calling backlight_device_unregister()\n");
backlight_device_unregister(ibm_backlight_device);
ibm_backlight_device = NULL;
}
@@ -2017,6 +2094,8 @@ IBM_HANDLE(sfan, ec, "SFAN", /* 570 */
static int fan_init(void)
{
+ vdbg_printk(TPACPI_DBG_INIT, "initializing fan subdriver\n");
+
fan_status_access_mode = TPACPI_FAN_NONE;
fan_control_access_mode = TPACPI_FAN_WR_NONE;
fan_control_commands = 0;
@@ -2095,6 +2174,11 @@ static int fan_init(void)
}
}
+ vdbg_printk(TPACPI_DBG_INIT, "fan is %s, modes %d, %d\n",
+ str_supported(fan_status_access_mode != TPACPI_FAN_NONE ||
+ fan_control_access_mode != TPACPI_FAN_WR_NONE),
+ fan_status_access_mode, fan_control_access_mode);
+
return (fan_status_access_mode != TPACPI_FAN_NONE ||
fan_control_access_mode != TPACPI_FAN_WR_NONE)?
0 : 1;
@@ -2138,6 +2222,7 @@ static int fan_get_status(u8 *status)
static void fan_exit(void)
{
+ vdbg_printk(TPACPI_DBG_EXIT, "cancelling any pending watchdogs\n");
cancel_delayed_work(&fan_watchdog_task);
flush_scheduled_work();
}
@@ -2622,6 +2707,15 @@ static struct ibm_struct ibms[] = {
* Module and infrastructure proble, init and exit handling
*/
+#ifdef CONFIG_THINKPAD_ACPI_DEBUG
+static const char * str_supported(int is_supported)
+{
+ static const char * const text_unsupported = "not supported";
+
+ return (is_supported)? text_unsupported + 4 : text_unsupported;
+}
+#endif /* CONFIG_THINKPAD_ACPI_DEBUG */
+
static int __init ibm_init(struct ibm_struct *ibm)
{
int ret;
@@ -2630,6 +2724,9 @@ static int __init ibm_init(struct ibm_struct *ibm)
if (ibm->experimental && !experimental)
return 0;
+ dbg_printk(TPACPI_DBG_INIT,
+ "probing for %s\n", ibm->name);
+
if (ibm->init) {
ret = ibm->init();
if (ret > 0)
@@ -2657,6 +2754,9 @@ static int __init ibm_init(struct ibm_struct *ibm)
goto err_out;
}
+ dbg_printk(TPACPI_DBG_INIT,
+ "%s installed\n", ibm->name);
+
if (ibm->read) {
entry = create_proc_entry(ibm->name,
S_IFREG | S_IRUGO | S_IWUSR,
@@ -2678,24 +2778,35 @@ static int __init ibm_init(struct ibm_struct *ibm)
return 0;
err_out:
+ dbg_printk(TPACPI_DBG_INIT,
+ "%s: at error exit path with result %d\n",
+ ibm->name, ret);
+
ibm_exit(ibm);
return (ret < 0)? ret : 0;
}
static void ibm_exit(struct ibm_struct *ibm)
{
+ dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name);
if (ibm->notify_installed) {
+ dbg_printk(TPACPI_DBG_EXIT,
+ "%s: acpi_remove_notify_handler\n", ibm->name);
acpi_remove_notify_handler(*ibm->handle, ibm->type,
dispatch_notify);
ibm->notify_installed = 0;
}
if (ibm->proc_created) {
+ dbg_printk(TPACPI_DBG_EXIT,
+ "%s: remove_proc_entry\n", ibm->name);
remove_proc_entry(ibm->name, proc_dir);
ibm->proc_created = 0;
}
if (ibm->driver_registered) {
+ dbg_printk(TPACPI_DBG_EXIT,
+ "%s: acpi_bus_unregister_driver\n", ibm->name);
acpi_bus_unregister_driver(ibm->driver);
kfree(ibm->driver);
ibm->driver = NULL;
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 06d4c38..beb1447 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -76,12 +76,16 @@
/* Debugging */
#define TPACPI_DBG_ALL 0xffff
+#define TPACPI_DBG_ALL 0xffff
+#define TPACPI_DBG_INIT 0x0001
+#define TPACPI_DBG_EXIT 0x0002
#define dbg_printk(a_dbg_level, format, arg...) \
do { if (dbg_level & a_dbg_level) \
printk(IBM_DEBUG "%s: " format, __func__ , ## arg); } while (0)
#ifdef CONFIG_THINKPAD_ACPI_DEBUG
#define vdbg_printk(a_dbg_level, format, arg...) \
dbg_printk(a_dbg_level, format, ## arg)
+static const char *str_supported(int is_supported);
#else
#define vdbg_printk(a_dbg_level, format, arg...)
#endif
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 10/20] ACPI: thinkpad-acpi: improve thinkpad detection
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (5 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 08/20] ACPI: thinkpad-acpi: add subdriver debug statements Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 12/20] ACPI: thinkpad-acpi: use bitfields for module flags Henrique de Moraes Holschuh
` (9 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Improve the detection of ThinkPads, so as to reduce the chances of false
positives.
Since this could potentially add false negatives on the very old models,
add a module parameter to force the detection of a thinkpad.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
Documentation/thinkpad-acpi.txt | 7 +++++++
drivers/misc/thinkpad_acpi.c | 13 +++++++++++++
drivers/misc/thinkpad_acpi.h | 1 +
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 20d5ec3..1a42b77 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -716,3 +716,10 @@ to enable more than one output class, just add their values.
There is also a kernel build option to enable more debugging
information, which may be necessary to debug driver problems.
+
+Force loading of module
+-----------------------
+
+If thinkpad-acpi refuses to detect your ThinkPad, you can try to specify
+the module parameter force_load=1. Regardless of whether this works or
+not, please contact ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org with a report.
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 5611268..cddf81b 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -2881,6 +2881,16 @@ static int __init probe_for_thinkpad(void)
return -ENODEV;
}
+ /*
+ * Risks a regression on very old machines, but reduces potential
+ * false positives a damn great deal
+ */
+ if (!is_thinkpad)
+ is_thinkpad = dmi_name_in_vendors("IBM");
+
+ if (!is_thinkpad && !force_load)
+ return -ENODEV;
+
return 0;
}
@@ -2986,6 +2996,9 @@ module_param(experimental, int, 0);
static u32 dbg_level;
module_param_named(debug, dbg_level, uint, 0);
+static int force_load;
+module_param(force_load, int, 0);
+
#define IBM_PARAM(feature) \
module_param_call(feature, set_ibm_param, NULL, NULL, 0)
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 97467b7..2020398 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -128,6 +128,7 @@ static char *next_cmd(char **cmds);
/* Module */
static int experimental;
static u32 dbg_level;
+static int force_load;
static char *ibm_thinkpad_ec_found;
static char* check_dmi_for_ec(void);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 12/20] ACPI: thinkpad-acpi: use bitfields for module flags
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (6 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 10/20] ACPI: thinkpad-acpi: improve thinkpad detection Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-22 3:52 ` Len Brown
2007-04-21 14:08 ` [PATCH 13/20] ACPI: thinkpad-acpi: prepare for device model conversion Henrique de Moraes Holschuh
` (8 subsequent siblings)
16 siblings, 1 reply; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
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-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 147 +++++++++++++++++++-----------------------
drivers/misc/thinkpad_acpi.h | 28 +++++----
2 files changed, 83 insertions(+), 92 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index a5efd06..e2a1b63 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -501,8 +501,6 @@ static struct ibm_struct thinkpad_acpi_driver_data = {
* Hotkey subdriver
*/
-static int hotkey_supported;
-static int hotkey_mask_supported;
static int hotkey_orig_status;
static int hotkey_orig_mask;
@@ -513,30 +511,30 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
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",
- 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 */
- 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",
- str_supported(hotkey_mask_supported));
+ str_supported(tp_features.hotkey_mask));
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)
{
- 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);
}
@@ -559,7 +557,7 @@ static int hotkey_get(int *status, int *mask)
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;
@@ -573,7 +571,7 @@ static int hotkey_set(int status, int mask)
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,
@@ -589,7 +587,7 @@ static int hotkey_read(char *p)
int status, mask;
int len = 0;
- if (!hotkey_supported) {
+ if (!tp_features.hotkey) {
len += sprintf(p + len, "status:\t\tnot supported\n");
return len;
}
@@ -598,7 +596,7 @@ static int hotkey_read(char *p)
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");
@@ -616,7 +614,7 @@ static int hotkey_write(char *buf)
char *cmd;
int do_cmd = 0;
- if (!hotkey_supported)
+ if (!tp_features.hotkey)
return -ENODEV;
if (!hotkey_get(&status, &mask))
@@ -660,8 +658,6 @@ static struct ibm_struct hotkey_driver_data = {
* Bluetooth subdriver
*/
-static int bluetooth_supported;
-
static int __init bluetooth_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
@@ -670,20 +666,20 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
/* 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",
- 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;
- if (!bluetooth_supported ||
+ if (!tp_features.bluetooth ||
!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
status = 0;
@@ -695,7 +691,7 @@ static int bluetooth_read(char *p)
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");
@@ -713,7 +709,7 @@ static int bluetooth_write(char *buf)
char *cmd;
int do_cmd = 0;
- if (!bluetooth_supported)
+ if (!tp_features.bluetooth)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
@@ -742,28 +738,27 @@ static struct ibm_struct bluetooth_driver_data = {
* Wan subdriver
*/
-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);
- 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",
- 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;
- 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;
@@ -774,7 +769,7 @@ static int wan_read(char *p)
int len = 0;
int status = wan_status();
- if (!wan_supported)
+ if (!tp_features.wan)
len += sprintf(p + len, "status:\t\tnot supported\n");
else if (!(status & 1))
len += sprintf(p + len, "status:\t\tnot installed\n");
@@ -792,7 +787,7 @@ static int wan_write(char *buf)
char *cmd;
int do_cmd = 0;
- if (!wan_supported)
+ if (!tp_features.wan)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
@@ -1051,9 +1046,6 @@ static struct ibm_struct video_driver_data = {
* 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 */
@@ -1066,18 +1058,18 @@ static int __init light_init(struct ibm_init_struct *iibm)
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;
- if (light_supported)
+ if (tp_features.light)
/* 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",
- 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)
@@ -1085,9 +1077,9 @@ static int light_read(char *p)
int len = 0;
int status = 0;
- if (!light_supported) {
+ if (!tp_features.light) {
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 {
@@ -1106,7 +1098,7 @@ static int light_write(char *buf)
char *cmd;
int success;
- if (!light_supported)
+ if (!tp_features.light)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
@@ -1251,11 +1243,6 @@ static struct ibm_struct dock_driver_data[2] = {
*/
#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 */
@@ -1282,25 +1269,25 @@ static int __init bay_init(struct ibm_init_struct *iibm)
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",
- 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)
@@ -1317,15 +1304,16 @@ static int bay_read(char *p)
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");
- 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");
@@ -1341,14 +1329,14 @@ static int bay_write(char *buf)
{
char *cmd;
- if (!bay_eject_supported && !bay_eject2_supported)
+ if (!tp_features.bay_eject && !tp_features.bay_eject2)
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;
- } 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;
@@ -2188,7 +2176,6 @@ 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 void fan_watchdog_fire(struct work_struct *ignored);
@@ -2210,8 +2197,8 @@ static int __init fan_init(struct ibm_init_struct *iibm)
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;
+ tp_features.fan_ctrl_status_undef = 0;
IBM_HANDLE_INIT(fans);
IBM_HANDLE_INIT(gfan);
@@ -2248,7 +2235,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
"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
@@ -2411,7 +2398,7 @@ static int fan_set_level(int level)
if (!acpi_ec_write(fan_status_offset, level))
return -EIO;
else
- fan_control_status_known = 1;
+ tp_features.fan_ctrl_status_undef = 0;
break;
default:
@@ -2438,7 +2425,7 @@ static int fan_set_enable(void)
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:
@@ -2469,7 +2456,7 @@ static int fan_set_disable(void)
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:
@@ -2524,9 +2511,9 @@ static int fan_read(char *p)
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)
- 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 */
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 8b72061..4d3ab40 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -173,6 +173,22 @@ struct ibm_init_struct {
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[];
@@ -193,9 +209,6 @@ static int thinkpad_acpi_driver_read(char *p);
*/
#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;
@@ -220,8 +233,6 @@ static int beep_write(char *buf);
* Bluetooth subdriver
*/
-static int bluetooth_supported;
-
static int bluetooth_init(struct ibm_init_struct *iibm);
static int bluetooth_status(void);
static int bluetooth_read(char *p);
@@ -311,7 +322,6 @@ enum 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;
@@ -340,8 +350,6 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc);
* Hotkey subdriver
*/
-static int hotkey_supported;
-static int hotkey_mask_supported;
static int hotkey_orig_status;
static int hotkey_orig_mask;
@@ -382,8 +390,6 @@ static int led_write(char *buf);
* 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);
@@ -453,8 +459,6 @@ static int volume_write(char *buf);
* Wan subdriver
*/
-static int wan_supported;
-
static int wan_init(struct ibm_init_struct *iibm);
static int wan_status(void);
static int wan_read(char *p);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 12/20] ACPI: thinkpad-acpi: use bitfields for module flags
2007-04-21 14:08 ` [PATCH 12/20] ACPI: thinkpad-acpi: use bitfields for module flags Henrique de Moraes Holschuh
@ 2007-04-22 3:52 ` Len Brown
2007-04-22 18:56 ` Henrique de Moraes Holschuh
0 siblings, 1 reply; 28+ messages in thread
From: Len Brown @ 2007-04-22 3:52 UTC (permalink / raw)
To: Henrique de Moraes Holschuh; +Cc: ibm-acpi-devel, linux-acpi
On Saturday 21 April 2007 10:08, Henrique de Moraes Holschuh wrote:
> 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.
I think that is an under-statement.
This plus the patch before it actually increase text size
for a static size change of 0.
-Len
before:
text data bss dec hex filename
24002 3286 728 28016 6d70 drivers/misc/thinkpad_acpi.o
after
text data bss dec hex filename
24082 3270 664 28016 6d70 drivers/misc/thinkpad_acpi.o
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 12/20] ACPI: thinkpad-acpi: use bitfields for module flags
2007-04-22 3:52 ` Len Brown
@ 2007-04-22 18:56 ` Henrique de Moraes Holschuh
0 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-22 18:56 UTC (permalink / raw)
To: Len Brown; +Cc: ibm-acpi-devel, linux-acpi
On Sat, 21 Apr 2007, Len Brown wrote:
> On Saturday 21 April 2007 10:08, Henrique de Moraes Holschuh wrote:
> > 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.
>
> I think that is an under-statement.
> This plus the patch before it actually increase text size
> for a static size change of 0.
>
> -Len
>
> before:
> text data bss dec hex filename
> 24002 3286 728 28016 6d70 drivers/misc/thinkpad_acpi.o
>
> after
> text data bss dec hex filename
> 24082 3270 664 28016 6d70 drivers/misc/thinkpad_acpi.o
Well, as module, same Debian gcc 4.1.2 pre-release I used before, and
objdump -w -h on the .ko file:
.bss: decreases from 0x22c to 0x20c
.data: decreases from 0x7a4 to 0x5b4
.init.data: no change
.text: decreases from 0x3658 to 0x3628
.init.text: increases from 0x174a to 0x1763
.rodata*: no change
Same remark as before: maybe I am mistaken on how these things work when the
linking is done at insmod time.
I really did not even consider checking what happens in a static build, it
is quite possible that size increases with these patches. One of the other
patches really causes an unamusing size increase due to data structure
alignment that I will address later (it is lower priority and would cause
too much rework on patches I did not submit yet). It happened when some
arrays were broken up to components and arrays of pointers to them.
--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 13/20] ACPI: thinkpad-acpi: prepare for device model conversion
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (7 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 12/20] ACPI: thinkpad-acpi: use bitfields for module flags Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 14/20] ACPI: thinkpad-acpi: mark acpi helper functions __must_check Henrique de Moraes Holschuh
` (7 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Prepare the thinkpad-acpi driver for the conversion to the device
model, by renaming variables and doing other glue work that shall
make the later patches much cleaner.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 231 +++++++++++++++++++++++-------------------
drivers/misc/thinkpad_acpi.h | 40 +++++---
2 files changed, 153 insertions(+), 118 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index e2a1b63..809ec84 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -277,7 +277,7 @@ static int _sta(acpi_handle handle)
* ACPI device model
*/
-static void ibm_handle_init(char *name,
+static void drv_acpi_handle_init(char *name,
acpi_handle *handle, acpi_handle parent,
char **paths, int num_paths, char **path)
{
@@ -295,40 +295,42 @@ static void ibm_handle_init(char *name,
*handle = NULL;
}
-static void dispatch_notify(acpi_handle handle, u32 event, void *data)
+static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
{
struct ibm_struct *ibm = data;
- if (!ibm || !ibm->notify)
+ if (!ibm || !ibm->acpi || !ibm->acpi->notify)
return;
- ibm->notify(ibm, event);
+ ibm->acpi->notify(ibm, event);
}
-static int __init setup_notify(struct ibm_struct *ibm)
+static int __init setup_acpi_notify(struct ibm_struct *ibm)
{
acpi_status status;
int ret;
- if (!*ibm->handle)
+ BUG_ON(!ibm->acpi);
+
+ if (!*ibm->acpi->handle)
return 0;
dbg_printk(TPACPI_DBG_INIT,
"setting up ACPI notify for %s\n", ibm->name);
- ret = acpi_bus_get_device(*ibm->handle, &ibm->device);
+ ret = acpi_bus_get_device(*ibm->acpi->handle, &ibm->acpi->device);
if (ret < 0) {
printk(IBM_ERR "%s device not present\n", ibm->name);
return -ENODEV;
}
- acpi_driver_data(ibm->device) = ibm;
- sprintf(acpi_device_class(ibm->device), "%s/%s",
+ acpi_driver_data(ibm->acpi->device) = ibm;
+ sprintf(acpi_device_class(ibm->acpi->device), "%s/%s",
IBM_ACPI_EVENT_PREFIX,
ibm->name);
- status = acpi_install_notify_handler(*ibm->handle, ibm->type,
- dispatch_notify, ibm);
+ status = acpi_install_notify_handler(*ibm->acpi->handle,
+ ibm->acpi->type, dispatch_acpi_notify, ibm);
if (ACPI_FAILURE(status)) {
if (status == AE_ALREADY_EXISTS) {
printk(IBM_NOTICE "another device driver is already handling %s events\n",
@@ -339,11 +341,11 @@ static int __init setup_notify(struct ibm_struct *ibm)
}
return -ENODEV;
}
- ibm->flags.notify_installed = 1;
+ ibm->flags.acpi_notify_installed = 1;
return 0;
}
-static int __init ibm_device_add(struct acpi_device *device)
+static int __init tpacpi_device_add(struct acpi_device *device)
{
return 0;
}
@@ -355,24 +357,26 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
dbg_printk(TPACPI_DBG_INIT,
"registering %s as an ACPI driver\n", ibm->name);
- ibm->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
- if (!ibm->driver) {
+ BUG_ON(!ibm->acpi);
+
+ ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL);
+ if (!ibm->acpi->driver) {
printk(IBM_ERR "kzalloc(ibm->driver) failed\n");
return -ENOMEM;
}
- sprintf(ibm->driver->name, "%s_%s", IBM_NAME, ibm->name);
- ibm->driver->ids = ibm->hid;
- ibm->driver->ops.add = &ibm_device_add;
+ sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
+ ibm->acpi->driver->ids = ibm->acpi->hid;
+ ibm->acpi->driver->ops.add = &tpacpi_device_add;
- ret = acpi_bus_register_driver(ibm->driver);
+ ret = acpi_bus_register_driver(ibm->acpi->driver);
if (ret < 0) {
printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
- ibm->hid, ret);
- kfree(ibm->driver);
- ibm->driver = NULL;
+ ibm->acpi->hid, ret);
+ kfree(ibm->acpi->driver);
+ ibm->acpi->driver = NULL;
} else if (!ret)
- ibm->flags.driver_registered = 1;
+ ibm->flags.acpi_driver_registered = 1;
return ret;
}
@@ -386,8 +390,8 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
****************************************************************************
****************************************************************************/
-static int dispatch_read(char *page, char **start, off_t off, int count,
- int *eof, void *data)
+static int dispatch_procfs_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
struct ibm_struct *ibm = data;
int len;
@@ -411,8 +415,9 @@ static int dispatch_read(char *page, char **start, off_t off, int count,
return len;
}
-static int dispatch_write(struct file *file, const char __user * userbuf,
- unsigned long count, void *data)
+static int dispatch_procfs_write(struct file *file,
+ const char __user * userbuf,
+ unsigned long count, void *data)
{
struct ibm_struct *ibm = data;
char *kernbuf;
@@ -508,7 +513,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
- IBM_HANDLE_INIT(hkey);
+ IBM_ACPIHANDLE_INIT(hkey);
/* hotkey not supported on 570 */
tp_features.hotkey = hkey_handle != NULL;
@@ -545,10 +550,10 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
int hkey;
if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d"))
- acpi_bus_generate_event(ibm->device, event, hkey);
+ acpi_bus_generate_event(ibm->acpi->device, event, hkey);
else {
printk(IBM_ERR "unknown hotkey event %d\n", event);
- acpi_bus_generate_event(ibm->device, event, 0);
+ acpi_bus_generate_event(ibm->acpi->device, event, 0);
}
}
@@ -643,15 +648,19 @@ static int hotkey_write(char *buf)
return 0;
}
+static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
+ .hid = IBM_HKEY_HID,
+ .notify = hotkey_notify,
+ .handle = &hkey_handle,
+ .type = ACPI_DEVICE_NOTIFY,
+};
+
static struct ibm_struct hotkey_driver_data = {
.name = "hotkey",
- .hid = IBM_HKEY_HID,
.read = hotkey_read,
.write = hotkey_write,
.exit = hotkey_exit,
- .notify = hotkey_notify,
- .handle = &hkey_handle,
- .type = ACPI_DEVICE_NOTIFY,
+ .acpi = &ibm_hotkey_acpidriver,
};
/*************************************************************************
@@ -662,7 +671,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
- IBM_HANDLE_INIT(hkey);
+ IBM_ACPIHANDLE_INIT(hkey);
/* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
@@ -742,7 +751,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
- IBM_HANDLE_INIT(hkey);
+ IBM_ACPIHANDLE_INIT(hkey);
tp_features.wan = hkey_handle &&
acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
@@ -835,8 +844,8 @@ static int __init video_init(struct ibm_init_struct *iibm)
vdbg_printk(TPACPI_DBG_INIT, "initializing video subdriver\n");
- IBM_HANDLE_INIT(vid);
- IBM_HANDLE_INIT(vid2);
+ IBM_ACPIHANDLE_INIT(vid);
+ IBM_ACPIHANDLE_INIT(vid2);
if (vid2_handle && acpi_evalf(NULL, &ivga, "\\IVGA", "d") && ivga)
/* G41, assume IVGA doesn't change */
@@ -1053,9 +1062,9 @@ static int __init light_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing light subdriver\n");
- IBM_HANDLE_INIT(ledb);
- IBM_HANDLE_INIT(lght);
- IBM_HANDLE_INIT(cmos);
+ IBM_ACPIHANDLE_INIT(ledb);
+ IBM_ACPIHANDLE_INIT(lght);
+ IBM_ACPIHANDLE_INIT(cmos);
/* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
tp_features.light = (cmos_handle || lght_handle) && !ledb_handle;
@@ -1148,8 +1157,8 @@ static int __init dock_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n");
- IBM_HANDLE_INIT(dock);
- IBM_HANDLE_INIT(pci);
+ IBM_ACPIHANDLE_INIT(dock);
+ IBM_ACPIHANDLE_INIT(pci);
vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n",
str_supported(dock_handle != NULL));
@@ -1160,22 +1169,22 @@ static int __init dock_init(struct ibm_init_struct *iibm)
static void dock_notify(struct ibm_struct *ibm, u32 event)
{
int docked = dock_docked();
- int pci = ibm->hid && strstr(ibm->hid, IBM_PCI_HID);
+ int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
if (event == 1 && !pci) /* 570 */
- acpi_bus_generate_event(ibm->device, event, 1); /* button */
+ acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */
else if (event == 1 && pci) /* 570 */
- acpi_bus_generate_event(ibm->device, event, 3); /* dock */
+ acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */
else if (event == 3 && docked)
- acpi_bus_generate_event(ibm->device, event, 1); /* button */
+ acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */
else if (event == 3 && !docked)
- acpi_bus_generate_event(ibm->device, event, 2); /* undock */
+ acpi_bus_generate_event(ibm->acpi->device, event, 2); /* undock */
else if (event == 0 && docked)
- acpi_bus_generate_event(ibm->device, event, 3); /* dock */
+ acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */
else {
printk(IBM_ERR "unknown dock event %d, status %d\n",
event, _sta(dock_handle));
- acpi_bus_generate_event(ibm->device, event, 0); /* unknown */
+ acpi_bus_generate_event(ibm->acpi->device, event, 0); /* unknown */
}
}
@@ -1218,17 +1227,13 @@ static int dock_write(char *buf)
return 0;
}
-static struct ibm_struct dock_driver_data[2] = {
+static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
{
- .name = "dock",
- .read = dock_read,
- .write = dock_write,
.notify = dock_notify,
.handle = &dock_handle,
.type = ACPI_SYSTEM_NOTIFY,
},
{
- .name = "dock",
.hid = IBM_PCI_HID,
.notify = dock_notify,
.handle = &pci_handle,
@@ -1236,6 +1241,19 @@ static struct ibm_struct dock_driver_data[2] = {
},
};
+static struct ibm_struct dock_driver_data[2] = {
+ {
+ .name = "dock",
+ .read = dock_read,
+ .write = dock_write,
+ .acpi = &ibm_dock_acpidriver[0],
+ },
+ {
+ .name = "dock",
+ .acpi = &ibm_dock_acpidriver[1],
+ },
+};
+
#endif /* CONFIG_THINKPAD_ACPI_DOCK */
/*************************************************************************
@@ -1262,12 +1280,12 @@ static int __init bay_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing bay subdriver\n");
- IBM_HANDLE_INIT(bay);
+ IBM_ACPIHANDLE_INIT(bay);
if (bay_handle)
- IBM_HANDLE_INIT(bay_ej);
- IBM_HANDLE_INIT(bay2);
+ IBM_ACPIHANDLE_INIT(bay_ej);
+ IBM_ACPIHANDLE_INIT(bay2);
if (bay2_handle)
- IBM_HANDLE_INIT(bay2_ej);
+ IBM_ACPIHANDLE_INIT(bay2_ej);
tp_features.bay_status = bay_handle &&
acpi_evalf(bay_handle, NULL, "_STA", "qv");
@@ -1292,7 +1310,7 @@ static int __init bay_init(struct ibm_init_struct *iibm)
static void bay_notify(struct ibm_struct *ibm, u32 event)
{
- acpi_bus_generate_event(ibm->device, event, 0);
+ acpi_bus_generate_event(ibm->acpi->device, event, 0);
}
#define bay_occupied(b) (_sta(b##_handle) & 1)
@@ -1347,13 +1365,17 @@ static int bay_write(char *buf)
return 0;
}
+static struct tp_acpi_drv_struct ibm_bay_acpidriver = {
+ .notify = bay_notify,
+ .handle = &bay_handle,
+ .type = ACPI_SYSTEM_NOTIFY,
+};
+
static struct ibm_struct bay_driver_data = {
.name = "bay",
.read = bay_read,
.write = bay_write,
- .notify = bay_notify,
- .handle = &bay_handle,
- .type = ACPI_SYSTEM_NOTIFY,
+ .acpi = &ibm_bay_acpidriver,
};
#endif /* CONFIG_THINKPAD_ACPI_BAY */
@@ -1367,7 +1389,7 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
vdbg_printk(TPACPI_DBG_INIT,
"initializing cmos commands subdriver\n");
- IBM_HANDLE_INIT(cmos);
+ IBM_ACPIHANDLE_INIT(cmos);
vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n",
str_supported(cmos_handle != NULL));
@@ -1441,7 +1463,7 @@ static int __init led_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing LED subdriver\n");
- IBM_HANDLE_INIT(led);
+ IBM_ACPIHANDLE_INIT(led);
if (!led_handle)
/* led not supported on R30, R31 */
@@ -1566,7 +1588,7 @@ static int __init beep_init(struct ibm_init_struct *iibm)
{
vdbg_printk(TPACPI_DBG_INIT, "initializing beep subdriver\n");
- IBM_HANDLE_INIT(beep);
+ IBM_ACPIHANDLE_INIT(beep);
vdbg_printk(TPACPI_DBG_INIT, "beep is %s\n",
str_supported(beep_handle != NULL));
@@ -2200,9 +2222,9 @@ static int __init fan_init(struct ibm_init_struct *iibm)
fan_watchdog_maxinterval = 0;
tp_features.fan_ctrl_status_undef = 0;
- IBM_HANDLE_INIT(fans);
- IBM_HANDLE_INIT(gfan);
- IBM_HANDLE_INIT(sfan);
+ IBM_ACPIHANDLE_INIT(fans);
+ IBM_ACPIHANDLE_INIT(gfan);
+ IBM_ACPIHANDLE_INIT(sfan);
if (gfan_handle) {
/* 570, 600e/x, 770e, 770x */
@@ -2728,22 +2750,24 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
ibm->flags.init_called = 1;
}
- if (ibm->hid) {
- ret = register_tpacpi_subdriver(ibm);
- if (ret)
- goto err_out;
- }
+ if (ibm->acpi) {
+ if (ibm->acpi->hid) {
+ ret = register_tpacpi_subdriver(ibm);
+ if (ret)
+ goto err_out;
+ }
- if (ibm->notify) {
- ret = setup_notify(ibm);
- if (ret == -ENODEV) {
- printk(IBM_NOTICE "disabling subdriver %s\n",
- ibm->name);
- ret = 0;
- goto err_out;
+ if (ibm->acpi->notify) {
+ ret = setup_acpi_notify(ibm);
+ if (ret == -ENODEV) {
+ printk(IBM_NOTICE "disabling subdriver %s\n",
+ ibm->name);
+ ret = 0;
+ goto err_out;
+ }
+ if (ret < 0)
+ goto err_out;
}
- if (ret < 0)
- goto err_out;
}
dbg_printk(TPACPI_DBG_INIT,
@@ -2761,9 +2785,9 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
}
entry->owner = THIS_MODULE;
entry->data = ibm;
- entry->read_proc = &dispatch_read;
+ entry->read_proc = &dispatch_procfs_read;
if (ibm->write)
- entry->write_proc = &dispatch_write;
+ entry->write_proc = &dispatch_procfs_write;
ibm->flags.proc_created = 1;
}
@@ -2786,12 +2810,15 @@ static void ibm_exit(struct ibm_struct *ibm)
list_del_init(&ibm->all_drivers);
- if (ibm->flags.notify_installed) {
+ if (ibm->flags.acpi_notify_installed) {
dbg_printk(TPACPI_DBG_EXIT,
"%s: acpi_remove_notify_handler\n", ibm->name);
- acpi_remove_notify_handler(*ibm->handle, ibm->type,
- dispatch_notify);
- ibm->flags.notify_installed = 0;
+ BUG_ON(!ibm->acpi);
+ acpi_remove_notify_handler(*ibm->acpi->handle,
+ ibm->acpi->type,
+ dispatch_acpi_notify);
+ ibm->flags.acpi_notify_installed = 0;
+ ibm->flags.acpi_notify_installed = 0;
}
if (ibm->flags.proc_created) {
@@ -2801,13 +2828,14 @@ static void ibm_exit(struct ibm_struct *ibm)
ibm->flags.proc_created = 0;
}
- if (ibm->flags.driver_registered) {
+ if (ibm->flags.acpi_driver_registered) {
dbg_printk(TPACPI_DBG_EXIT,
"%s: acpi_bus_unregister_driver\n", ibm->name);
- acpi_bus_unregister_driver(ibm->driver);
- kfree(ibm->driver);
- ibm->driver = NULL;
- ibm->flags.driver_registered = 0;
+ BUG_ON(!ibm->acpi);
+ acpi_bus_unregister_driver(ibm->acpi->driver);
+ kfree(ibm->acpi->driver);
+ ibm->acpi->driver = NULL;
+ ibm->flags.acpi_driver_registered = 0;
}
if (ibm->flags.init_called && ibm->exit) {
@@ -2860,7 +2888,7 @@ static int __init probe_for_thinkpad(void)
is_thinkpad = dmi_name_in_vendors("ThinkPad");
/* ec is required because many other handles are relative to it */
- IBM_HANDLE_INIT(ec);
+ IBM_ACPIHANDLE_INIT(ec);
if (!ec_handle) {
if (is_thinkpad)
printk(IBM_ERR
@@ -3016,12 +3044,12 @@ static int __init thinkpad_acpi_module_init(void)
return ret;
ibm_thinkpad_ec_found = check_dmi_for_ec();
- IBM_HANDLE_INIT(ecrd);
- IBM_HANDLE_INIT(ecwr);
+ IBM_ACPIHANDLE_INIT(ecrd);
+ IBM_ACPIHANDLE_INIT(ecwr);
- proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir);
+ proc_dir = proc_mkdir(IBM_PROC_DIR, acpi_root_dir);
if (!proc_dir) {
- printk(IBM_ERR "unable to create proc dir %s", IBM_DIR);
+ printk(IBM_ERR "unable to create proc dir " IBM_PROC_DIR);
thinkpad_acpi_module_exit();
return -ENODEV;
}
@@ -3053,10 +3081,9 @@ static void thinkpad_acpi_module_exit(void)
dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
if (proc_dir)
- remove_proc_entry(IBM_DIR, acpi_root_dir);
+ remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
- if (ibm_thinkpad_ec_found)
- kfree(ibm_thinkpad_ec_found);
+ kfree(ibm_thinkpad_ec_found);
}
module_init(thinkpad_acpi_module_init);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 4d3ab40..529528c 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -52,8 +52,9 @@
#define IBM_DESC "ThinkPad ACPI Extras"
#define IBM_FILE "thinkpad_acpi"
#define IBM_URL "http://ibm-acpi.sf.net/"
+#define IBM_MAIL "ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
-#define IBM_DIR "ibm"
+#define IBM_PROC_DIR "ibm"
#define IBM_ACPI_EVENT_PREFIX "ibm"
#define IBM_LOG IBM_FILE ": "
@@ -108,20 +109,21 @@ static acpi_handle ec_handle; /* EC */
static acpi_handle ecrd_handle, ecwr_handle; /* 570 EC access */
static acpi_handle cmos_handle, hkey_handle; /* basic thinkpad handles */
-static void ibm_handle_init(char *name,
+static void drv_acpi_handle_init(char *name,
acpi_handle *handle, acpi_handle parent,
char **paths, int num_paths, char **path);
-#define IBM_HANDLE_INIT(object) \
- ibm_handle_init(#object, &object##_handle, *object##_parent, \
+#define IBM_ACPIHANDLE_INIT(object) \
+ drv_acpi_handle_init(#object, &object##_handle, *object##_parent, \
object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
/* procfs support */
static struct proc_dir_entry *proc_dir;
/* procfs helpers */
-static int dispatch_read(char *page, char **start, off_t off, int count,
- int *eof, void *data);
-static int dispatch_write(struct file *file, const char __user * userbuf,
+static int dispatch_procfs_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+static int dispatch_procfs_write(struct file *file,
+ const char __user * userbuf,
unsigned long count, void *data);
static char *next_cmd(char **cmds);
@@ -140,28 +142,34 @@ static void thinkpad_acpi_module_exit(void);
* Subdrivers
*/
-struct ibm_struct {
- char *name;
+struct ibm_struct;
+struct tp_acpi_drv_struct {
char *hid;
struct acpi_driver *driver;
- int (*read) (char *);
- int (*write) (char *);
- void (*exit) (void);
-
void (*notify) (struct ibm_struct *, u32);
acpi_handle *handle;
- int type;
+ u32 type;
struct acpi_device *device;
+};
+
+struct ibm_struct {
+ char *name;
+
+ int (*read) (char *);
+ int (*write) (char *);
+ void (*exit) (void);
struct list_head all_drivers;
+ struct tp_acpi_drv_struct *acpi;
+
struct {
- u8 driver_registered:1;
+ u8 acpi_driver_registered:1;
+ u8 acpi_notify_installed:1;
u8 proc_created:1;
u8 init_called:1;
- u8 notify_installed:1;
u8 experimental:1;
} flags;
};
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 14/20] ACPI: thinkpad-acpi: mark acpi helper functions __must_check
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (8 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 13/20] ACPI: thinkpad-acpi: prepare for device model conversion Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 15/20] ACPI: thinkpad-acpi: clean up hotkey subdriver Henrique de Moraes Holschuh
` (6 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Mark acpi_evalf and friends __must_check.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 529528c..1b4cd16 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -97,11 +97,11 @@ static const char *str_supported(int is_supported);
#define IBM_PCI_HID "PNP0A03"
/* ACPI helpers */
-static int acpi_evalf(acpi_handle handle,
+static int __must_check acpi_evalf(acpi_handle handle,
void *res, char *method, char *fmt, ...);
-static int acpi_ec_read(int i, u8 * p);
-static int acpi_ec_write(int i, u8 v);
-static int _sta(acpi_handle handle);
+static int __must_check acpi_ec_read(int i, u8 * p);
+static int __must_check acpi_ec_write(int i, u8 v);
+static int __must_check _sta(acpi_handle handle);
/* ACPI handles */
static acpi_handle root_handle; /* root namespace */
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 15/20] ACPI: thinkpad-acpi: clean up hotkey subdriver
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (9 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 14/20] ACPI: thinkpad-acpi: mark acpi helper functions __must_check Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 16/20] ACPI: thinkpad-acpi: cleanup bluetooth and wan for sysfs conversion Henrique de Moraes Holschuh
` (5 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Cleanup hotkey subdriver code.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 46 ++++++++++++++++++++++++++---------------
1 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 809ec84..344eb55 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -511,6 +511,8 @@ static int hotkey_orig_mask;
static int __init hotkey_init(struct ibm_init_struct *iibm)
{
+ int res;
+
vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
IBM_ACPIHANDLE_INIT(hkey);
@@ -530,8 +532,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
str_supported(tp_features.hotkey_mask));
- if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask))
- return -ENODEV;
+ res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask);
+ if (res)
+ return res;
}
return (tp_features.hotkey)? 0 : 1;
@@ -539,9 +542,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
static void hotkey_exit(void)
{
+ int res;
+
if (tp_features.hotkey) {
dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n");
- hotkey_set(hotkey_orig_status, hotkey_orig_mask);
+ res = hotkey_set(hotkey_orig_status, hotkey_orig_mask);
+ if (res)
+ printk(IBM_ERR "failed to restore hotkey to BIOS defaults\n");
}
}
@@ -560,13 +567,13 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
static int hotkey_get(int *status, int *mask)
{
if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
- return 0;
+ return -EIO;
if (tp_features.hotkey_mask)
if (!acpi_evalf(hkey_handle, mask, "DHKN", "d"))
- return 0;
+ return -EIO;
- return 1;
+ return 0;
}
static int hotkey_set(int status, int mask)
@@ -574,22 +581,22 @@ static int hotkey_set(int status, int mask)
int i;
if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status))
- return 0;
+ return -EIO;
if (tp_features.hotkey_mask)
for (i = 0; i < 32; i++) {
int bit = ((1 << i) & mask) != 0;
if (!acpi_evalf(hkey_handle,
NULL, "MHKM", "vdd", i + 1, bit))
- return 0;
+ return -EIO;
}
- return 1;
+ return 0;
}
static int hotkey_read(char *p)
{
- int status, mask;
+ int res, status, mask;
int len = 0;
if (!tp_features.hotkey) {
@@ -597,8 +604,9 @@ static int hotkey_read(char *p)
return len;
}
- if (!hotkey_get(&status, &mask))
- return -EIO;
+ res = hotkey_get(&status, &mask);
+ if (res)
+ return res;
len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
if (tp_features.hotkey_mask) {
@@ -615,15 +623,16 @@ static int hotkey_read(char *p)
static int hotkey_write(char *buf)
{
- int status, mask;
+ int res, status, mask;
char *cmd;
int do_cmd = 0;
if (!tp_features.hotkey)
return -ENODEV;
- if (!hotkey_get(&status, &mask))
- return -EIO;
+ res = hotkey_get(&status, &mask);
+ if (res)
+ return res;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "enable") == 0) {
@@ -642,8 +651,11 @@ static int hotkey_write(char *buf)
do_cmd = 1;
}
- if (do_cmd && !hotkey_set(status, mask))
- return -EIO;
+ if (do_cmd) {
+ res = hotkey_set(status, mask);
+ if (res)
+ return res;
+ }
return 0;
}
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 16/20] ACPI: thinkpad-acpi: cleanup bluetooth and wan for sysfs conversion
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (10 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 15/20] ACPI: thinkpad-acpi: clean up hotkey subdriver Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 17/20] ACPI: thinkpad-acpi: cleanup video subdriver Henrique de Moraes Holschuh
` (4 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Prepare bluetooth and wan driver code to be more easily hooked into sysfs
helpers, by separating the procfs logic from the device attribute handling.
These changes also remove the entries from procfs on notebooks without the
bluetooth/wan hardware installed.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 130 +++++++++++++++++++++++++++++-------------
drivers/misc/thinkpad_acpi.h | 20 ++++++-
2 files changed, 108 insertions(+), 42 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 344eb55..a77368f 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -681,6 +681,8 @@ static struct ibm_struct hotkey_driver_data = {
static int __init bluetooth_init(struct ibm_init_struct *iibm)
{
+ int status = 0;
+
vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n");
IBM_ACPIHANDLE_INIT(hkey);
@@ -688,36 +690,65 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
/* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
tp_features.bluetooth = hkey_handle &&
- acpi_evalf(hkey_handle, NULL, "GBDC", "qv");
+ acpi_evalf(hkey_handle, &status, "GBDC", "qd");
- vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n",
- str_supported(tp_features.bluetooth));
+ vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s, status 0x%02x\n",
+ str_supported(tp_features.bluetooth),
+ status);
+
+ if (tp_features.bluetooth &&
+ !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) {
+ /* no bluetooth hardware present in system */
+ tp_features.bluetooth = 0;
+ dbg_printk(TPACPI_DBG_INIT,
+ "bluetooth hardware not installed\n");
+ }
return (tp_features.bluetooth)? 0 : 1;
}
-static int bluetooth_status(void)
+static int bluetooth_get_radiosw(void)
{
int status;
- if (!tp_features.bluetooth ||
- !acpi_evalf(hkey_handle, &status, "GBDC", "d"))
- status = 0;
+ if (!tp_features.bluetooth)
+ return -ENODEV;
- return status;
+ 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;
}
static int bluetooth_read(char *p)
{
int len = 0;
- int status = bluetooth_status();
+ int status = bluetooth_get_radiosw();
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");
else {
- len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 1));
+ len += sprintf(p + len, "status:\t\t%s\n",
+ (status)? "enabled" : "disabled");
len += sprintf(p + len, "commands:\tenable, disable\n");
}
@@ -726,26 +757,20 @@ static int bluetooth_read(char *p)
static int bluetooth_write(char *buf)
{
- int status = bluetooth_status();
char *cmd;
- int do_cmd = 0;
if (!tp_features.bluetooth)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "enable") == 0) {
- status |= 2;
+ bluetooth_set_radiosw(1);
} else if (strlencmp(cmd, "disable") == 0) {
- status &= ~2;
+ bluetooth_set_radiosw(0);
} else
return -EINVAL;
- do_cmd = 1;
}
- if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
- return -EIO;
-
return 0;
}
@@ -761,41 +786,72 @@ static struct ibm_struct bluetooth_driver_data = {
static int __init wan_init(struct ibm_init_struct *iibm)
{
+ int status = 0;
+
vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n");
IBM_ACPIHANDLE_INIT(hkey);
tp_features.wan = hkey_handle &&
- acpi_evalf(hkey_handle, NULL, "GWAN", "qv");
+ acpi_evalf(hkey_handle, &status, "GWAN", "qd");
- vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n",
- str_supported(tp_features.wan));
+ vdbg_printk(TPACPI_DBG_INIT, "wan is %s, status 0x%02x\n",
+ str_supported(tp_features.wan),
+ status);
+
+ if (tp_features.wan &&
+ !(status & TP_ACPI_WANCARD_HWPRESENT)) {
+ /* no wan hardware present in system */
+ tp_features.wan = 0;
+ dbg_printk(TPACPI_DBG_INIT,
+ "wan hardware not installed\n");
+ }
return (tp_features.wan)? 0 : 1;
}
-static int wan_status(void)
+static int wan_get_radiosw(void)
{
int status;
- if (!tp_features.wan ||
- !acpi_evalf(hkey_handle, &status, "GWAN", "d"))
- status = 0;
+ if (!tp_features.wan)
+ return -ENODEV;
- return status;
+ 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;
}
static int wan_read(char *p)
{
int len = 0;
- int status = wan_status();
+ int status = wan_get_radiosw();
if (!tp_features.wan)
len += sprintf(p + len, "status:\t\tnot supported\n");
- else if (!(status & 1))
- len += sprintf(p + len, "status:\t\tnot installed\n");
else {
- len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 1));
+ len += sprintf(p + len, "status:\t\t%s\n",
+ (status)? "enabled" : "disabled");
len += sprintf(p + len, "commands:\tenable, disable\n");
}
@@ -804,26 +860,20 @@ static int wan_read(char *p)
static int wan_write(char *buf)
{
- int status = wan_status();
char *cmd;
- int do_cmd = 0;
if (!tp_features.wan)
return -ENODEV;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "enable") == 0) {
- status |= 2;
+ wan_set_radiosw(1);
} else if (strlencmp(cmd, "disable") == 0) {
- status &= ~2;
+ wan_set_radiosw(0);
} else
return -EINVAL;
- do_cmd = 1;
}
- if (do_cmd && !acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
- return -EIO;
-
return 0;
}
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 1b4cd16..e06bad5 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -241,8 +241,16 @@ static int beep_write(char *buf);
* Bluetooth subdriver
*/
+enum {
+ /* ACPI GBDC/SBDC bits */
+ TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */
+ TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */
+ TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */
+};
+
static int bluetooth_init(struct ibm_init_struct *iibm);
-static int bluetooth_status(void);
+static int bluetooth_get_radiosw(void);
+static int bluetooth_set_radiosw(int radio_on);
static int bluetooth_read(char *p);
static int bluetooth_write(char *buf);
@@ -467,8 +475,16 @@ static int volume_write(char *buf);
* Wan subdriver
*/
+enum {
+ /* ACPI GWAN/SWAN bits */
+ TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */
+ TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */
+ TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */
+};
+
static int wan_init(struct ibm_init_struct *iibm);
-static int wan_status(void);
+static int wan_get_radiosw(void);
+static int wan_set_radiosw(int radio_on);
static int wan_read(char *p);
static int wan_write(char *buf);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 17/20] ACPI: thinkpad-acpi: cleanup video subdriver
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (11 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 16/20] ACPI: thinkpad-acpi: cleanup bluetooth and wan for sysfs conversion Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 18/20] ACPI: thinkpad-acpi: clean up CMOS commands subdriver Henrique de Moraes Holschuh
` (3 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Cleanup video subdriver for sysfs conversion, and properly check
result status of acpi_evalf.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 262 ++++++++++++++++++++++++++++--------------
drivers/misc/thinkpad_acpi.h | 25 +++-
2 files changed, 197 insertions(+), 90 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index a77368f..19c14bb 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -935,111 +935,194 @@ static int __init video_init(struct ibm_init_struct *iibm)
static void video_exit(void)
{
- dbg_printk(TPACPI_DBG_EXIT, "restoring original video autoswitch mode\n");
- acpi_evalf(vid_handle, NULL, "_DOS", "vd", video_orig_autosw);
+ dbg_printk(TPACPI_DBG_EXIT,
+ "restoring original video autoswitch mode\n");
+ if (video_autosw_set(video_orig_autosw))
+ printk(IBM_ERR "error while trying to restore original "
+ "video autoswitch mode\n");
}
-static int video_status(void)
+static int video_outputsw_get(void)
{
int status = 0;
int i;
- if (video_supported == TPACPI_VIDEO_570) {
- if (acpi_evalf(NULL, &i, "\\_SB.PHS", "dd", 0x87))
- status = i & 3;
- } else if (video_supported == TPACPI_VIDEO_770) {
- if (acpi_evalf(NULL, &i, "\\VCDL", "d"))
- status |= 0x01 * i;
- if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
- status |= 0x02 * i;
- } else if (video_supported == TPACPI_VIDEO_NEW) {
- acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1);
- if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
- status |= 0x02 * i;
-
- acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0);
- if (acpi_evalf(NULL, &i, "\\VCDL", "d"))
- status |= 0x01 * i;
- if (acpi_evalf(NULL, &i, "\\VCDD", "d"))
- status |= 0x08 * i;
+ switch (video_supported) {
+ case TPACPI_VIDEO_570:
+ if (!acpi_evalf(NULL, &i, "\\_SB.PHS", "dd",
+ TP_ACPI_VIDEO_570_PHSCMD))
+ return -EIO;
+ status = i & TP_ACPI_VIDEO_570_PHSMASK;
+ break;
+ case TPACPI_VIDEO_770:
+ if (!acpi_evalf(NULL, &i, "\\VCDL", "d"))
+ return -EIO;
+ if (i)
+ status |= TP_ACPI_VIDEO_S_LCD;
+ if (!acpi_evalf(NULL, &i, "\\VCDC", "d"))
+ return -EIO;
+ if (i)
+ status |= TP_ACPI_VIDEO_S_CRT;
+ break;
+ case TPACPI_VIDEO_NEW:
+ if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1) ||
+ !acpi_evalf(NULL, &i, "\\VCDC", "d"))
+ return -EIO;
+ if (i)
+ status |= TP_ACPI_VIDEO_S_CRT;
+
+ if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0) ||
+ !acpi_evalf(NULL, &i, "\\VCDL", "d"))
+ return -EIO;
+ if (i)
+ status |= TP_ACPI_VIDEO_S_LCD;
+ if (!acpi_evalf(NULL, &i, "\\VCDD", "d"))
+ return -EIO;
+ if (i)
+ status |= TP_ACPI_VIDEO_S_DVI;
+ break;
+ default:
+ return -ENOSYS;
}
return status;
}
-static int video_autosw(void)
+static int video_outputsw_set(int status)
{
- int autosw = 0;
+ int autosw;
+ int res = 0;
- if (video_supported == TPACPI_VIDEO_570)
- acpi_evalf(vid_handle, &autosw, "SWIT", "d");
- else if (video_supported == TPACPI_VIDEO_770 ||
- video_supported == TPACPI_VIDEO_NEW)
- acpi_evalf(vid_handle, &autosw, "^VDEE", "d");
+ switch (video_supported) {
+ case TPACPI_VIDEO_570:
+ res = acpi_evalf(NULL, NULL,
+ "\\_SB.PHS2", "vdd",
+ TP_ACPI_VIDEO_570_PHS2CMD,
+ status | TP_ACPI_VIDEO_570_PHS2SET);
+ break;
+ case TPACPI_VIDEO_770:
+ autosw = video_autosw_get();
+ if (autosw < 0)
+ return autosw;
- return autosw & 1;
+ res = video_autosw_set(1);
+ if (res)
+ return res;
+ res = acpi_evalf(vid_handle, NULL,
+ "ASWT", "vdd", status * 0x100, 0);
+ if (!autosw && video_autosw_set(autosw)) {
+ printk(IBM_ERR "video auto-switch left enabled due to error\n");
+ return -EIO;
+ }
+ break;
+ case TPACPI_VIDEO_NEW:
+ res = acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80) &&
+ acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1);
+ break;
+ default:
+ return -ENOSYS;
+ }
+
+ return (res)? 0 : -EIO;
}
-static int video_switch(void)
+static int video_autosw_get(void)
{
- int autosw = video_autosw();
- int ret;
+ int autosw = 0;
- if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
- return -EIO;
- ret = video_supported == TPACPI_VIDEO_570 ?
- acpi_evalf(ec_handle, NULL, "_Q16", "v") :
- acpi_evalf(vid_handle, NULL, "VSWT", "v");
- acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw);
+ switch (video_supported) {
+ case TPACPI_VIDEO_570:
+ if (!acpi_evalf(vid_handle, &autosw, "SWIT", "d"))
+ return -EIO;
+ break;
+ case TPACPI_VIDEO_770:
+ case TPACPI_VIDEO_NEW:
+ if (!acpi_evalf(vid_handle, &autosw, "^VDEE", "d"))
+ return -EIO;
+ break;
+ default:
+ return -ENOSYS;
+ }
- return ret;
+ return autosw & 1;
}
-static int video_expand(void)
+static int video_autosw_set(int enable)
{
- if (video_supported == TPACPI_VIDEO_570)
- return acpi_evalf(ec_handle, NULL, "_Q17", "v");
- else if (video_supported == TPACPI_VIDEO_770)
- return acpi_evalf(vid_handle, NULL, "VEXP", "v");
- else
- return acpi_evalf(NULL, NULL, "\\VEXP", "v");
+ if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", (enable)? 1 : 0))
+ return -EIO;
+ return 0;
}
-static int video_switch2(int status)
+static int video_outputsw_cycle(void)
{
- int ret;
-
- if (video_supported == TPACPI_VIDEO_570) {
- ret = acpi_evalf(NULL, NULL,
- "\\_SB.PHS2", "vdd", 0x8b, status | 0x80);
- } else if (video_supported == TPACPI_VIDEO_770) {
- int autosw = video_autosw();
- if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
- return -EIO;
+ int autosw = video_autosw_get();
+ int res;
- ret = acpi_evalf(vid_handle, NULL,
- "ASWT", "vdd", status * 0x100, 0);
+ if (autosw < 0)
+ return autosw;
- acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw);
- } else {
- ret = acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80) &&
- acpi_evalf(NULL, NULL, "\\VSDS", "vdd", status, 1);
+ switch (video_supported) {
+ case TPACPI_VIDEO_570:
+ res = video_autosw_set(1);
+ if (res)
+ return res;
+ res = acpi_evalf(ec_handle, NULL, "_Q16", "v");
+ break;
+ case TPACPI_VIDEO_770:
+ case TPACPI_VIDEO_NEW:
+ res = video_autosw_set(1);
+ if (res)
+ return res;
+ res = acpi_evalf(vid_handle, NULL, "VSWT", "v");
+ break;
+ default:
+ return -ENOSYS;
+ }
+ if (!autosw && video_autosw_set(autosw)) {
+ printk(IBM_ERR "video auto-switch left enabled due to error\n");
+ return -EIO;
}
- return ret;
+ return (res)? 0 : -EIO;
+}
+
+static int video_expand_toggle(void)
+{
+ switch (video_supported) {
+ case TPACPI_VIDEO_570:
+ return acpi_evalf(ec_handle, NULL, "_Q17", "v")?
+ 0 : -EIO;
+ case TPACPI_VIDEO_770:
+ return acpi_evalf(vid_handle, NULL, "VEXP", "v")?
+ 0 : -EIO;
+ case TPACPI_VIDEO_NEW:
+ return acpi_evalf(NULL, NULL, "\\VEXP", "v")?
+ 0 : -EIO;
+ default:
+ return -ENOSYS;
+ }
+ /* not reached */
}
static int video_read(char *p)
{
- int status = video_status();
- int autosw = video_autosw();
+ int status, autosw;
int len = 0;
- if (!video_supported) {
+ if (video_supported == TPACPI_VIDEO_NONE) {
len += sprintf(p + len, "status:\t\tnot supported\n");
return len;
}
+ status = video_outputsw_get();
+ if (status < 0)
+ return status;
+
+ autosw = video_autosw_get();
+ if (autosw < 0)
+ return autosw;
+
len += sprintf(p + len, "status:\t\tsupported\n");
len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0));
len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1));
@@ -1060,47 +1143,56 @@ static int video_write(char *buf)
{
char *cmd;
int enable, disable, status;
+ int res;
- if (!video_supported)
+ if (video_supported == TPACPI_VIDEO_NONE)
return -ENODEV;
- enable = disable = 0;
+ enable = 0;
+ disable = 0;
while ((cmd = next_cmd(&buf))) {
if (strlencmp(cmd, "lcd_enable") == 0) {
- enable |= 0x01;
+ enable |= TP_ACPI_VIDEO_S_LCD;
} else if (strlencmp(cmd, "lcd_disable") == 0) {
- disable |= 0x01;
+ disable |= TP_ACPI_VIDEO_S_LCD;
} else if (strlencmp(cmd, "crt_enable") == 0) {
- enable |= 0x02;
+ enable |= TP_ACPI_VIDEO_S_CRT;
} else if (strlencmp(cmd, "crt_disable") == 0) {
- disable |= 0x02;
+ disable |= TP_ACPI_VIDEO_S_CRT;
} else if (video_supported == TPACPI_VIDEO_NEW &&
strlencmp(cmd, "dvi_enable") == 0) {
- enable |= 0x08;
+ enable |= TP_ACPI_VIDEO_S_DVI;
} else if (video_supported == TPACPI_VIDEO_NEW &&
strlencmp(cmd, "dvi_disable") == 0) {
- disable |= 0x08;
+ disable |= TP_ACPI_VIDEO_S_DVI;
} else if (strlencmp(cmd, "auto_enable") == 0) {
- if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
- return -EIO;
+ res = video_autosw_set(1);
+ if (res)
+ return res;
} else if (strlencmp(cmd, "auto_disable") == 0) {
- if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 0))
- return -EIO;
+ res = video_autosw_set(0);
+ if (res)
+ return res;
} else if (strlencmp(cmd, "video_switch") == 0) {
- if (!video_switch())
- return -EIO;
+ res = video_outputsw_cycle();
+ if (res)
+ return res;
} else if (strlencmp(cmd, "expand_toggle") == 0) {
- if (!video_expand())
- return -EIO;
+ res = video_expand_toggle();
+ if (res)
+ return res;
} else
return -EINVAL;
}
if (enable || disable) {
- status = (video_status() & 0x0f & ~disable) | enable;
- if (!video_switch2(status))
- return -EIO;
+ status = video_outputsw_get();
+ if (status < 0)
+ return status;
+ res = video_outputsw_set((status & ~disable) | enable);
+ if (res)
+ return res;
}
return 0;
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index e06bad5..3a8718a 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -446,17 +446,32 @@ enum video_access_mode {
TPACPI_VIDEO_NEW, /* all others */
};
+enum { /* video status flags, based on VIDEO_570 */
+ TP_ACPI_VIDEO_S_LCD = 0x01, /* LCD output enabled */
+ TP_ACPI_VIDEO_S_CRT = 0x02, /* CRT output enabled */
+ TP_ACPI_VIDEO_S_DVI = 0x08, /* DVI output enabled */
+};
+
+enum { /* TPACPI_VIDEO_570 constants */
+ TP_ACPI_VIDEO_570_PHSCMD = 0x87, /* unknown magic constant :( */
+ TP_ACPI_VIDEO_570_PHSMASK = 0x03, /* PHS bits that map to
+ * video_status_flags */
+ TP_ACPI_VIDEO_570_PHS2CMD = 0x8b, /* unknown magic constant :( */
+ TP_ACPI_VIDEO_570_PHS2SET = 0x80, /* unknown magic constant :( */
+};
+
static enum video_access_mode video_supported;
static int video_orig_autosw;
static acpi_handle vid_handle, vid2_handle;
static int video_init(struct ibm_init_struct *iibm);
static void video_exit(void);
-static int video_status(void);
-static int video_autosw(void);
-static int video_switch(void);
-static int video_switch2(int status);
-static int video_expand(void);
+static int video_outputsw_get(void);
+static int video_outputsw_set(int status);
+static int video_autosw_get(void);
+static int video_autosw_set(int enable);
+static int video_outputsw_cycle(void);
+static int video_expand_toggle(void);
static int video_read(char *p);
static int video_write(char *buf);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 18/20] ACPI: thinkpad-acpi: clean up CMOS commands subdriver
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (12 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 17/20] ACPI: thinkpad-acpi: cleanup video subdriver Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 19/20] ACPI: thinkpad-acpi: cleanup thermal subdriver for sysfs conversion Henrique de Moraes Holschuh
` (2 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Some ThinkPad CMOS commands subdriver cleanups, and also rename/promote
cmos_eval to a ACPI helper function, as it is used by many other
subdrivers.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 39 ++++++++++++++++++++-------------------
drivers/misc/thinkpad_acpi.h | 4 +++-
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 19c14bb..8829d3c 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -273,6 +273,17 @@ static int _sta(acpi_handle handle)
return status;
}
+static int issue_thinkpad_cmos_command(int cmos_cmd)
+{
+ if (!cmos_handle)
+ return -ENXIO;
+
+ if (!acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd))
+ return -EIO;
+
+ return 0;
+}
+
/*************************************************************************
* ACPI device model
*/
@@ -1550,14 +1561,6 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
return (cmos_handle)? 0 : 1;
}
-static int cmos_eval(int cmos_cmd)
-{
- if (cmos_handle)
- return acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd);
- else
- return 1;
-}
-
static int cmos_read(char *p)
{
int len = 0;
@@ -1577,10 +1580,7 @@ static int cmos_read(char *p)
static int cmos_write(char *buf)
{
char *cmd;
- int cmos_cmd;
-
- if (!cmos_handle)
- return -EINVAL;
+ int cmos_cmd, res;
while ((cmd = next_cmd(&buf))) {
if (sscanf(cmd, "%u", &cmos_cmd) == 1 &&
@@ -1589,8 +1589,9 @@ static int cmos_write(char *buf)
} else
return -EINVAL;
- if (!cmos_eval(cmos_cmd))
- return -EIO;
+ res = issue_thinkpad_cmos_command(cmos_cmd);
+ if (res)
+ return res;
}
return 0;
@@ -2093,7 +2094,7 @@ static int brightness_set(int value)
cmos_cmd = value > current_value ? TP_CMOS_BRIGHTNESS_UP : TP_CMOS_BRIGHTNESS_DOWN;
inc = value > current_value ? 1 : -1;
for (i = current_value; i != value; i += inc) {
- if (!cmos_eval(cmos_cmd))
+ if (issue_thinkpad_cmos_command(cmos_cmd))
return -EIO;
if (!acpi_ec_write(brightness_offset, i + inc))
return -EIO;
@@ -2210,16 +2211,16 @@ static int volume_write(char *buf)
cmos_cmd = new_level > level ? TP_CMOS_VOLUME_UP : TP_CMOS_VOLUME_DOWN;
inc = new_level > level ? 1 : -1;
- if (mute && (!cmos_eval(cmos_cmd) ||
+ if (mute && (issue_thinkpad_cmos_command(cmos_cmd) ||
!acpi_ec_write(volume_offset, level)))
return -EIO;
for (i = level; i != new_level; i += inc)
- if (!cmos_eval(cmos_cmd) ||
+ if (issue_thinkpad_cmos_command(cmos_cmd) ||
!acpi_ec_write(volume_offset, i + inc))
return -EIO;
- if (mute && (!cmos_eval(TP_CMOS_VOLUME_MUTE) ||
+ if (mute && (issue_thinkpad_cmos_command(TP_CMOS_VOLUME_MUTE) ||
!acpi_ec_write(volume_offset,
new_level + mute)))
return -EIO;
@@ -2228,7 +2229,7 @@ static int volume_write(char *buf)
if (new_mute != mute) { /* level doesn't change */
cmos_cmd = new_mute ? TP_CMOS_VOLUME_MUTE : TP_CMOS_VOLUME_UP;
- if (!cmos_eval(cmos_cmd) ||
+ if (issue_thinkpad_cmos_command(cmos_cmd) ||
!acpi_ec_write(volume_offset, level + new_mute))
return -EIO;
}
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 3a8718a..fb0abb0 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -116,6 +116,9 @@ static void drv_acpi_handle_init(char *name,
drv_acpi_handle_init(#object, &object##_handle, *object##_parent, \
object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
+/* ThinkPad ACPI helpers */
+static int issue_thinkpad_cmos_command(int cmos_cmd);
+
/* procfs support */
static struct proc_dir_entry *proc_dir;
@@ -275,7 +278,6 @@ static int brightness_write(char *buf);
* CMOS subdriver
*/
-static int cmos_eval(int cmos_cmd);
static int cmos_read(char *p);
static int cmos_write(char *buf);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 19/20] ACPI: thinkpad-acpi: cleanup thermal subdriver for sysfs conversion
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (13 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 18/20] ACPI: thinkpad-acpi: clean up CMOS commands subdriver Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` [PATCH 20/20] ACPI: thinkpad-acpi: improve fan watchdog messages Henrique de Moraes Holschuh
2007-04-21 14:08 ` Henrique de Moraes Holschuh
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Clean-up the thermal subdriver for sysfs conversion. Make thermal_get_*
reentrancy-safe while at it, and add the missing thermal_read_mode variable
to the header file.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 79 ++++++++++++++++++++++++++++--------------
drivers/misc/thinkpad_acpi.h | 8 ++++
2 files changed, 61 insertions(+), 26 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 8829d3c..e9aec87 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1818,13 +1818,13 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
ta1 = ta2 = 0;
for (i = 0; i < 8; i++) {
- if (likely(acpi_ec_read(0x78 + i, &t))) {
+ if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
ta1 |= t;
} else {
ta1 = 0;
break;
}
- if (likely(acpi_ec_read(0xC0 + i, &t))) {
+ if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
ta2 |= t;
} else {
ta1 = 0;
@@ -1869,57 +1869,84 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
return (thermal_read_mode != TPACPI_THERMAL_NONE)? 0 : 1;
}
-static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s)
+/* idx is zero-based */
+static int thermal_get_sensor(int idx, s32 *value)
{
- int i, t;
+ int t;
s8 tmp;
- char tmpi[] = "TMPi";
+ char tmpi[5];
- if (!s)
- return -EINVAL;
+ t = TP_EC_THERMAL_TMP0;
switch (thermal_read_mode) {
#if TPACPI_MAX_THERMAL_SENSORS >= 16
case TPACPI_THERMAL_TPEC_16:
- for (i = 0; i < 8; i++) {
- if (!acpi_ec_read(0xC0 + i, &tmp))
- return -EIO;
- s->temp[i + 8] = tmp * 1000;
+ if (idx >= 8 && idx <= 15) {
+ t = TP_EC_THERMAL_TMP8;
+ idx -= 8;
}
/* fallthrough */
#endif
case TPACPI_THERMAL_TPEC_8:
- for (i = 0; i < 8; i++) {
- if (!acpi_ec_read(0x78 + i, &tmp))
+ if (idx <= 7) {
+ if (!acpi_ec_read(t + idx, &tmp))
return -EIO;
- s->temp[i] = tmp * 1000;
+ *value = tmp * 1000;
+ return 0;
}
- return (thermal_read_mode == TPACPI_THERMAL_TPEC_16) ? 16 : 8;
+ break;
case TPACPI_THERMAL_ACPI_UPDT:
- if (!acpi_evalf(ec_handle, NULL, "UPDT", "v"))
- return -EIO;
- for (i = 0; i < 8; i++) {
- tmpi[3] = '0' + i;
+ if (idx <= 7) {
+ snprintf(tmpi, sizeof(tmpi), "TMP%c", '0' + idx);
+ if (!acpi_evalf(ec_handle, NULL, "UPDT", "v"))
+ return -EIO;
if (!acpi_evalf(ec_handle, &t, tmpi, "d"))
return -EIO;
- s->temp[i] = (t - 2732) * 100;
+ *value = (t - 2732) * 100;
+ return 0;
}
- return 8;
+ break;
case TPACPI_THERMAL_ACPI_TMP07:
- for (i = 0; i < 8; i++) {
- tmpi[3] = '0' + i;
+ if (idx <= 7) {
+ snprintf(tmpi, sizeof(tmpi), "TMP%c", '0' + idx);
if (!acpi_evalf(ec_handle, &t, tmpi, "d"))
return -EIO;
- s->temp[i] = t * 1000;
+ *value = t * 1000;
+ return 0;
}
- return 8;
+ break;
case TPACPI_THERMAL_NONE:
default:
- return 0;
+ return -ENOSYS;
}
+
+ return -EINVAL;
+}
+
+static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s)
+{
+ int res, i;
+ int n;
+
+ n = 8;
+ i = 0;
+
+ if (!s)
+ return -EINVAL;
+
+ if (thermal_read_mode == TPACPI_THERMAL_TPEC_16)
+ n = 16;
+
+ for(i = 0 ; i < n; i++) {
+ res = thermal_get_sensor(i, &s->temp[i]);
+ if (res)
+ return res;
+ }
+
+ return n;
}
static int thermal_read(char *p)
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index fb0abb0..6432b28 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -427,12 +427,20 @@ enum thermal_access_mode {
TPACPI_THERMAL_TPEC_16, /* Use ACPI EC regs, 16 sensors */
};
+enum { /* TPACPI_THERMAL_TPEC_* */
+ TP_EC_THERMAL_TMP0 = 0x78, /* ACPI EC regs TMP 0..7 */
+ TP_EC_THERMAL_TMP8 = 0xC0, /* ACPI EC regs TMP 8..15 */
+};
+
#define TPACPI_MAX_THERMAL_SENSORS 16 /* Max thermal sensors supported */
struct ibm_thermal_sensors_struct {
s32 temp[TPACPI_MAX_THERMAL_SENSORS];
};
+static enum thermal_access_mode thermal_read_mode;
+
static int thermal_init(struct ibm_init_struct *iibm);
+static int thermal_get_sensor(int idx, s32 *value);
static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s);
static int thermal_read(char *p);
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 20/20] ACPI: thinkpad-acpi: improve fan watchdog messages
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (14 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 19/20] ACPI: thinkpad-acpi: cleanup thermal subdriver for sysfs conversion Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
2007-04-21 14:08 ` Henrique de Moraes Holschuh
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
Henrique de Moraes Holschuh, linux-acpi-u79uwXL29TY76Z2rM5mHXA
Improve some of the fan watchdog error messages to be a little more
helpful.
Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
---
drivers/misc/thinkpad_acpi.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index e9aec87..9b4eea4 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -2524,7 +2524,7 @@ static int fan_get_status(u8 *status)
static void fan_exit(void)
{
- vdbg_printk(TPACPI_DBG_EXIT, "cancelling any pending watchdogs\n");
+ vdbg_printk(TPACPI_DBG_EXIT, "cancelling any pending fan watchdog tasks\n");
cancel_delayed_work(&fan_watchdog_task);
flush_scheduled_work();
}
@@ -2554,9 +2554,13 @@ static int fan_get_speed(unsigned int *speed)
static void fan_watchdog_fire(struct work_struct *ignored)
{
+ int rc;
+
printk(IBM_NOTICE "fan watchdog: enabling fan\n");
- if (fan_set_enable()) {
- printk(IBM_ERR "fan watchdog: error while enabling fan\n");
+ rc = fan_set_enable();
+ if (rc < 0) {
+ printk(IBM_ERR "fan watchdog: error %d while enabling fan, "
+ "will try again later...\n", -rc);
/* reschedule for later */
fan_watchdog_reset();
}
--
1.5.1
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 20/20] ACPI: thinkpad-acpi: improve fan watchdog messages
[not found] ` <11771645253042-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
` (15 preceding siblings ...)
2007-04-21 14:08 ` [PATCH 20/20] ACPI: thinkpad-acpi: improve fan watchdog messages Henrique de Moraes Holschuh
@ 2007-04-21 14:08 ` Henrique de Moraes Holschuh
16 siblings, 0 replies; 28+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-04-21 14:08 UTC (permalink / raw)
To: lenb-DgEjT+Ai2ygdnm+yROfE0A
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-acpi-u79uwXL29TY76Z2rM5mHXA
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply [flat|nested] 28+ messages in thread