aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Starikovskiy <astarikovskiy@suse.de>2007-09-26 11:43:16 -0400
committerLen Brown <len.brown@intel.com>2007-09-27 15:50:22 -0400
commit8db85d4c9a0cc131242c80ef8456362d66561dc2 (patch)
treec5f945ed1bc8b2ff9ba099a09d737bec5c776028
parent3e58ea0d31659b22ba5753f7abf3d7db346eab81 (diff)
ACPI: Add acpi_bus_generate_event4() function
acpi_bus_generate_event() takes two strings out of passed device object. SBS needs to supply these strings directly. Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/bus.c23
-rw-r--r--drivers/acpi/sbs.c46
-rw-r--r--include/acpi/acpi_bus.h1
3 files changed, 30 insertions, 40 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 9ba778a2b484..a54234d3aac1 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -284,15 +284,11 @@ DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
284 284
285extern int event_is_open; 285extern int event_is_open;
286 286
287int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) 287int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data)
288{ 288{
289 struct acpi_bus_event *event = NULL; 289 struct acpi_bus_event *event;
290 unsigned long flags = 0; 290 unsigned long flags = 0;
291 291
292
293 if (!device)
294 return -EINVAL;
295
296 /* drop event on the floor if no one's listening */ 292 /* drop event on the floor if no one's listening */
297 if (!event_is_open) 293 if (!event_is_open)
298 return 0; 294 return 0;
@@ -301,8 +297,8 @@ int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
301 if (!event) 297 if (!event)
302 return -ENOMEM; 298 return -ENOMEM;
303 299
304 strcpy(event->device_class, device->pnp.device_class); 300 strcpy(event->device_class, device_class);
305 strcpy(event->bus_id, device->pnp.bus_id); 301 strcpy(event->bus_id, bus_id);
306 event->type = type; 302 event->type = type;
307 event->data = data; 303 event->data = data;
308 304
@@ -313,6 +309,17 @@ int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
313 wake_up_interruptible(&acpi_bus_event_queue); 309 wake_up_interruptible(&acpi_bus_event_queue);
314 310
315 return 0; 311 return 0;
312
313}
314
315EXPORT_SYMBOL_GPL(acpi_bus_generate_proc_event4);
316
317int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
318{
319 if (!device)
320 return -EINVAL;
321 return acpi_bus_generate_proc_event4(device->pnp.device_class,
322 device->pnp.bus_id, type, data);
316} 323}
317 324
318EXPORT_SYMBOL(acpi_bus_generate_proc_event); 325EXPORT_SYMBOL(acpi_bus_generate_proc_event);
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index a578986e3214..33ba4bf551ef 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -427,28 +427,6 @@ static int acpi_check_update_proc(struct acpi_sbs *sbs)
427 return 0; 427 return 0;
428} 428}
429 429
430static int acpi_sbs_generate_event(struct acpi_device *device,
431 int event, int state, char *bid, char *class)
432{
433 char bid_saved[5];
434 char class_saved[20];
435 int result = 0;
436
437 strcpy(bid_saved, acpi_device_bid(device));
438 strcpy(class_saved, acpi_device_class(device));
439
440 strcpy(acpi_device_bid(device), bid);
441 strcpy(acpi_device_class(device), class);
442
443 result = acpi_bus_generate_proc_event(device, event, state);
444
445 strcpy(acpi_device_bid(device), bid_saved);
446 strcpy(acpi_device_class(device), class_saved);
447
448 acpi_bus_generate_netlink_event(class, bid, event, state);
449 return result;
450}
451
452static int acpi_battery_get_present(struct acpi_battery *battery) 430static int acpi_battery_get_present(struct acpi_battery *battery)
453{ 431{
454 s16 state; 432 s16 state;
@@ -1452,15 +1430,17 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int id, int data_type)
1452 } 1430 }
1453 1431
1454 if (do_ac_init) { 1432 if (do_ac_init) {
1455 result = acpi_sbs_generate_event(sbs->device, 1433 result = acpi_bus_generate_proc_event4(ACPI_AC_CLASS,
1456 ACPI_SBS_AC_NOTIFY_STATUS,
1457 new_ac_present,
1458 ACPI_AC_DIR_NAME, 1434 ACPI_AC_DIR_NAME,
1459 ACPI_AC_CLASS); 1435 ACPI_SBS_AC_NOTIFY_STATUS,
1436 new_ac_present);
1460 if (result) { 1437 if (result) {
1461 ACPI_EXCEPTION((AE_INFO, AE_ERROR, 1438 ACPI_EXCEPTION((AE_INFO, AE_ERROR,
1462 "acpi_sbs_generate_event() failed")); 1439 "acpi_bus_generate_event4() failed"));
1463 } 1440 }
1441 acpi_bus_generate_netlink_event(ACPI_AC_CLASS, ACPI_AC_DIR_NAME,
1442 ACPI_SBS_AC_NOTIFY_STATUS,
1443 new_ac_present);
1464 } 1444 }
1465 1445
1466 if (data_type == DATA_TYPE_COMMON) { 1446 if (data_type == DATA_TYPE_COMMON) {
@@ -1568,14 +1548,16 @@ static int acpi_sbs_update_run(struct acpi_sbs *sbs, int id, int data_type)
1568 old_remaining_capacity != 1548 old_remaining_capacity !=
1569 battery->state.remaining_capacity) { 1549 battery->state.remaining_capacity) {
1570 sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id); 1550 sprintf(dir_name, ACPI_BATTERY_DIR_NAME, id);
1571 result = acpi_sbs_generate_event(sbs->device, 1551 result = acpi_bus_generate_proc_event4(ACPI_BATTERY_CLASS,
1572 ACPI_SBS_BATTERY_NOTIFY_STATUS,
1573 new_battery_present,
1574 dir_name, 1552 dir_name,
1575 ACPI_BATTERY_CLASS); 1553 ACPI_SBS_BATTERY_NOTIFY_STATUS,
1554 new_battery_present);
1555 acpi_bus_generate_netlink_event(ACPI_BATTERY_CLASS, dir_name,
1556 ACPI_SBS_BATTERY_NOTIFY_STATUS,
1557 new_battery_present);
1576 if (result) { 1558 if (result) {
1577 ACPI_EXCEPTION((AE_INFO, AE_ERROR, 1559 ACPI_EXCEPTION((AE_INFO, AE_ERROR,
1578 "acpi_sbs_generate_event() " 1560 "acpi_bus_generate_proc_event4() "
1579 "failed")); 1561 "failed"));
1580 } 1562 }
1581 } 1563 }
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 86aea44ce6d4..8a388e766162 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -333,6 +333,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state);
333int acpi_bus_set_power(acpi_handle handle, int state); 333int acpi_bus_set_power(acpi_handle handle, int state);
334#ifdef CONFIG_ACPI_PROC_EVENT 334#ifdef CONFIG_ACPI_PROC_EVENT
335int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data); 335int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data);
336int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 type, int data);
336int acpi_bus_receive_event(struct acpi_bus_event *event); 337int acpi_bus_receive_event(struct acpi_bus_event *event);
337#else 338#else
338static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) 339static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)