Add patches accepted for 2.6.30-rc1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.30-rc1 / 0008-thinkpad-acpi-add-new-debug-helpers-and-warn-of-dep.patch
blob76a889104847c1d0662d74cdd473bac5745f58d2
1 From 73a94d86a8625371f76de0ee12dc5bacd3ed42c0 Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sat, 4 Apr 2009 04:25:47 +0000
4 Subject: thinkpad-acpi: add new debug helpers and warn of deprecated atts
6 Add a debug helper that discloses the TGID of the userspace task
7 attempting to access the driver. This is highly useful when dealing
8 with bug reports, since often the user has no idea that some userspace
9 application is accessing thinkpad-acpi...
11 Also add a helper to log warnings about sysfs attributes that are
12 deprecated.
14 Use the new helpers to issue deprecation warnings for bluetooth_enable
15 and wwan_enabled, that have been deprecated for a while, now.
17 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
18 Signed-off-by: Len Brown <len.brown@intel.com>
19 ---
20 Documentation/laptops/thinkpad-acpi.txt | 2 +
21 drivers/platform/x86/thinkpad_acpi.c | 40 +++++++++++++++++++++++++++++++
22 2 files changed, 42 insertions(+), 0 deletions(-)
24 diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
25 index f6e6bc6..e8f52fb 100644
26 --- a/Documentation/laptops/thinkpad-acpi.txt
27 +++ b/Documentation/laptops/thinkpad-acpi.txt
28 @@ -1484,6 +1484,8 @@ will enable all debugging output classes. It takes a bitmask, so
29 to enable more than one output class, just add their values.
31 Debug bitmask Description
32 + 0x8000 Disclose PID of userspace programs
33 + accessing some functions of the driver
34 0x0001 Initialization and probing
35 0x0002 Removal
37 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
38 index 6331b88..852be7c 100644
39 --- a/drivers/platform/x86/thinkpad_acpi.c
40 +++ b/drivers/platform/x86/thinkpad_acpi.c
41 @@ -54,6 +54,7 @@
42 #include <linux/string.h>
43 #include <linux/list.h>
44 #include <linux/mutex.h>
45 +#include <linux/sched.h>
46 #include <linux/kthread.h>
47 #include <linux/freezer.h>
48 #include <linux/delay.h>
49 @@ -185,6 +186,7 @@ enum {
51 /* Debugging printk groups */
52 #define TPACPI_DBG_ALL 0xffff
53 +#define TPACPI_DBG_DISCLOSETASK 0x8000
54 #define TPACPI_DBG_INIT 0x0001
55 #define TPACPI_DBG_EXIT 0x0002
57 @@ -335,6 +337,21 @@ static const char *str_supported(int is_supported);
58 do { } while (0)
59 #endif
61 +static void tpacpi_log_usertask(const char * const what)
63 + printk(TPACPI_DEBUG "%s: access by process with PID %d\n",
64 + what, task_tgid_vnr(current));
67 +#define tpacpi_disclose_usertask(what, format, arg...) \
68 + do { \
69 + if (unlikely( \
70 + (dbg_level & TPACPI_DBG_DISCLOSETASK) && \
71 + (tpacpi_lifecycle == TPACPI_LIFE_RUNNING))) { \
72 + printk(TPACPI_DEBUG "%s: PID %d: " format, \
73 + what, task_tgid_vnr(current), ## arg); \
74 + } \
75 + } while (0)
77 /****************************************************************************
78 ****************************************************************************
79 @@ -1030,6 +1047,21 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
80 return 0;
83 +static void printk_deprecated_attribute(const char * const what,
84 + const char * const details)
86 + tpacpi_log_usertask("deprecated sysfs attribute");
87 + printk(TPACPI_WARN "WARNING: sysfs attribute %s is deprecated and "
88 + "will be removed. %s\n",
89 + what, details);
92 +static void printk_deprecated_rfkill_attribute(const char * const what)
94 + printk_deprecated_attribute(what,
95 + "Please switch to generic rfkill before year 2010");
98 /*************************************************************************
99 * thinkpad-acpi driver attributes
101 @@ -3070,6 +3102,8 @@ static ssize_t bluetooth_enable_show(struct device *dev,
103 int status;
105 + printk_deprecated_rfkill_attribute("bluetooth_enable");
107 status = bluetooth_get_radiosw();
108 if (status < 0)
109 return status;
110 @@ -3085,6 +3119,8 @@ static ssize_t bluetooth_enable_store(struct device *dev,
111 unsigned long t;
112 int res;
114 + printk_deprecated_rfkill_attribute("bluetooth_enable");
116 if (parse_strtoul(buf, 1, &t))
117 return -EINVAL;
119 @@ -3347,6 +3383,8 @@ static ssize_t wan_enable_show(struct device *dev,
121 int status;
123 + printk_deprecated_rfkill_attribute("wwan_enable");
125 status = wan_get_radiosw();
126 if (status < 0)
127 return status;
128 @@ -3362,6 +3400,8 @@ static ssize_t wan_enable_store(struct device *dev,
129 unsigned long t;
130 int res;
132 + printk_deprecated_rfkill_attribute("wwan_enable");
134 if (parse_strtoul(buf, 1, &t))
135 return -EINVAL;
138 1.6.2.1