aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/container.c')
-rw-r--r--drivers/acpi/container.c128
1 files changed, 56 insertions, 72 deletions
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 97013ddfa202..10dd695a1dd9 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -44,9 +44,9 @@
44 44
45#define ACPI_CONTAINER_COMPONENT 0x01000000 45#define ACPI_CONTAINER_COMPONENT 0x01000000
46#define _COMPONENT ACPI_CONTAINER_COMPONENT 46#define _COMPONENT ACPI_CONTAINER_COMPONENT
47ACPI_MODULE_NAME ("acpi_container") 47ACPI_MODULE_NAME("acpi_container")
48 48
49MODULE_AUTHOR("Anil S Keshavamurthy"); 49 MODULE_AUTHOR("Anil S Keshavamurthy");
50MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME); 50MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME);
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52 52
@@ -56,41 +56,38 @@ static int acpi_container_add(struct acpi_device *device);
56static int acpi_container_remove(struct acpi_device *device, int type); 56static int acpi_container_remove(struct acpi_device *device, int type);
57 57
58static struct acpi_driver acpi_container_driver = { 58static struct acpi_driver acpi_container_driver = {
59 .name = ACPI_CONTAINER_DRIVER_NAME, 59 .name = ACPI_CONTAINER_DRIVER_NAME,
60 .class = ACPI_CONTAINER_CLASS, 60 .class = ACPI_CONTAINER_CLASS,
61 .ids = "ACPI0004,PNP0A05,PNP0A06", 61 .ids = "ACPI0004,PNP0A05,PNP0A06",
62 .ops = { 62 .ops = {
63 .add = acpi_container_add, 63 .add = acpi_container_add,
64 .remove = acpi_container_remove, 64 .remove = acpi_container_remove,
65 }, 65 },
66}; 66};
67 67
68
69/*******************************************************************/ 68/*******************************************************************/
70 69
71static int 70static int is_device_present(acpi_handle handle)
72is_device_present(acpi_handle handle)
73{ 71{
74 acpi_handle temp; 72 acpi_handle temp;
75 acpi_status status; 73 acpi_status status;
76 unsigned long sta; 74 unsigned long sta;
77 75
78 ACPI_FUNCTION_TRACE("is_device_present"); 76 ACPI_FUNCTION_TRACE("is_device_present");
79 77
80 status = acpi_get_handle(handle, "_STA", &temp); 78 status = acpi_get_handle(handle, "_STA", &temp);
81 if (ACPI_FAILURE(status)) 79 if (ACPI_FAILURE(status))
82 return_VALUE(1); /* _STA not found, assmue device present */ 80 return_VALUE(1); /* _STA not found, assmue device present */
83 81
84 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 82 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
85 if (ACPI_FAILURE(status)) 83 if (ACPI_FAILURE(status))
86 return_VALUE(0); /* Firmware error */ 84 return_VALUE(0); /* Firmware error */
87 85
88 return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); 86 return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
89} 87}
90 88
91/*******************************************************************/ 89/*******************************************************************/
92static int 90static int acpi_container_add(struct acpi_device *device)
93acpi_container_add(struct acpi_device *device)
94{ 91{
95 struct acpi_container *container; 92 struct acpi_container *container;
96 93
@@ -102,28 +99,26 @@ acpi_container_add(struct acpi_device *device)
102 } 99 }
103 100
104 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); 101 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
105 if(!container) 102 if (!container)
106 return_VALUE(-ENOMEM); 103 return_VALUE(-ENOMEM);
107 104
108 memset(container, 0, sizeof(struct acpi_container)); 105 memset(container, 0, sizeof(struct acpi_container));
109 container->handle = device->handle; 106 container->handle = device->handle;
110 strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME); 107 strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
111 strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS); 108 strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
112 acpi_driver_data(device) = container; 109 acpi_driver_data(device) = container;
113 110
114 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", \ 111 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
115 acpi_device_name(device), acpi_device_bid(device))); 112 acpi_device_name(device), acpi_device_bid(device)));
116
117 113
118 return_VALUE(0); 114 return_VALUE(0);
119} 115}
120 116
121static int 117static int acpi_container_remove(struct acpi_device *device, int type)
122acpi_container_remove(struct acpi_device *device, int type)
123{ 118{
124 acpi_status status = AE_OK; 119 acpi_status status = AE_OK;
125 struct acpi_container *pc = NULL; 120 struct acpi_container *pc = NULL;
126 pc = (struct acpi_container*) acpi_driver_data(device); 121 pc = (struct acpi_container *)acpi_driver_data(device);
127 122
128 if (pc) 123 if (pc)
129 kfree(pc); 124 kfree(pc);
@@ -131,9 +126,7 @@ acpi_container_remove(struct acpi_device *device, int type)
131 return status; 126 return status;
132} 127}
133 128
134 129static int container_device_add(struct acpi_device **device, acpi_handle handle)
135static int
136container_device_add(struct acpi_device **device, acpi_handle handle)
137{ 130{
138 acpi_handle phandle; 131 acpi_handle phandle;
139 struct acpi_device *pdev; 132 struct acpi_device *pdev;
@@ -158,10 +151,9 @@ container_device_add(struct acpi_device **device, acpi_handle handle)
158 return_VALUE(result); 151 return_VALUE(result);
159} 152}
160 153
161static void 154static void container_notify_cb(acpi_handle handle, u32 type, void *context)
162container_notify_cb(acpi_handle handle, u32 type, void *context)
163{ 155{
164 struct acpi_device *device = NULL; 156 struct acpi_device *device = NULL;
165 int result; 157 int result;
166 int present; 158 int present;
167 acpi_status status; 159 acpi_status status;
@@ -169,14 +161,14 @@ container_notify_cb(acpi_handle handle, u32 type, void *context)
169 ACPI_FUNCTION_TRACE("container_notify_cb"); 161 ACPI_FUNCTION_TRACE("container_notify_cb");
170 162
171 present = is_device_present(handle); 163 present = is_device_present(handle);
172 164
173 switch (type) { 165 switch (type) {
174 case ACPI_NOTIFY_BUS_CHECK: 166 case ACPI_NOTIFY_BUS_CHECK:
175 /* Fall through */ 167 /* Fall through */
176 case ACPI_NOTIFY_DEVICE_CHECK: 168 case ACPI_NOTIFY_DEVICE_CHECK:
177 printk("Container driver received %s event\n", 169 printk("Container driver received %s event\n",
178 (type == ACPI_NOTIFY_BUS_CHECK)? 170 (type == ACPI_NOTIFY_BUS_CHECK) ?
179 "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); 171 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
180 status = acpi_bus_get_device(handle, &device); 172 status = acpi_bus_get_device(handle, &device);
181 if (present) { 173 if (present) {
182 if (ACPI_FAILURE(status) || !device) { 174 if (ACPI_FAILURE(status) || !device) {
@@ -207,15 +199,13 @@ container_notify_cb(acpi_handle handle, u32 type, void *context)
207 199
208static acpi_status 200static acpi_status
209container_walk_namespace_cb(acpi_handle handle, 201container_walk_namespace_cb(acpi_handle handle,
210 u32 lvl, 202 u32 lvl, void *context, void **rv)
211 void *context,
212 void **rv)
213{ 203{
214 char *hid = NULL; 204 char *hid = NULL;
215 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 205 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
216 struct acpi_device_info *info; 206 struct acpi_device_info *info;
217 acpi_status status; 207 acpi_status status;
218 int *action = context; 208 int *action = context;
219 209
220 ACPI_FUNCTION_TRACE("container_walk_namespace_cb"); 210 ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
221 211
@@ -233,66 +223,60 @@ container_walk_namespace_cb(acpi_handle handle,
233 } 223 }
234 224
235 if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") && 225 if (strcmp(hid, "ACPI0004") && strcmp(hid, "PNP0A05") &&
236 strcmp(hid, "PNP0A06")) { 226 strcmp(hid, "PNP0A06")) {
237 goto end; 227 goto end;
238 } 228 }
239 229
240 switch(*action) { 230 switch (*action) {
241 case INSTALL_NOTIFY_HANDLER: 231 case INSTALL_NOTIFY_HANDLER:
242 acpi_install_notify_handler(handle, 232 acpi_install_notify_handler(handle,
243 ACPI_SYSTEM_NOTIFY, 233 ACPI_SYSTEM_NOTIFY,
244 container_notify_cb, 234 container_notify_cb, NULL);
245 NULL);
246 break; 235 break;
247 case UNINSTALL_NOTIFY_HANDLER: 236 case UNINSTALL_NOTIFY_HANDLER:
248 acpi_remove_notify_handler(handle, 237 acpi_remove_notify_handler(handle,
249 ACPI_SYSTEM_NOTIFY, 238 ACPI_SYSTEM_NOTIFY,
250 container_notify_cb); 239 container_notify_cb);
251 break; 240 break;
252 default: 241 default:
253 break; 242 break;
254 } 243 }
255 244
256end: 245 end:
257 acpi_os_free(buffer.pointer); 246 acpi_os_free(buffer.pointer);
258 247
259 return_ACPI_STATUS(AE_OK); 248 return_ACPI_STATUS(AE_OK);
260} 249}
261 250
262 251static int __init acpi_container_init(void)
263static int __init
264acpi_container_init(void)
265{ 252{
266 int result = 0; 253 int result = 0;
267 int action = INSTALL_NOTIFY_HANDLER; 254 int action = INSTALL_NOTIFY_HANDLER;
268 255
269 result = acpi_bus_register_driver(&acpi_container_driver); 256 result = acpi_bus_register_driver(&acpi_container_driver);
270 if (result < 0) { 257 if (result < 0) {
271 return(result); 258 return (result);
272 } 259 }
273 260
274 /* register notify handler to every container device */ 261 /* register notify handler to every container device */
275 acpi_walk_namespace(ACPI_TYPE_DEVICE, 262 acpi_walk_namespace(ACPI_TYPE_DEVICE,
276 ACPI_ROOT_OBJECT, 263 ACPI_ROOT_OBJECT,
277 ACPI_UINT32_MAX, 264 ACPI_UINT32_MAX,
278 container_walk_namespace_cb, 265 container_walk_namespace_cb, &action, NULL);
279 &action, NULL);
280 266
281 return(0); 267 return (0);
282} 268}
283 269
284static void __exit 270static void __exit acpi_container_exit(void)
285acpi_container_exit(void)
286{ 271{
287 int action = UNINSTALL_NOTIFY_HANDLER; 272 int action = UNINSTALL_NOTIFY_HANDLER;
288 273
289 ACPI_FUNCTION_TRACE("acpi_container_exit"); 274 ACPI_FUNCTION_TRACE("acpi_container_exit");
290 275
291 acpi_walk_namespace(ACPI_TYPE_DEVICE, 276 acpi_walk_namespace(ACPI_TYPE_DEVICE,
292 ACPI_ROOT_OBJECT, 277 ACPI_ROOT_OBJECT,
293 ACPI_UINT32_MAX, 278 ACPI_UINT32_MAX,
294 container_walk_namespace_cb, 279 container_walk_namespace_cb, &action, NULL);
295 &action, NULL);
296 280
297 acpi_bus_unregister_driver(&acpi_container_driver); 281 acpi_bus_unregister_driver(&acpi_container_driver);
298 282