Skip to contentSkip to conversation

ACPI: don't send netlink events for those that go into input layer

PATCH Applied Zhang Rui 3 participants 6 messages Aug 22, 2007 – Aug 25, 2007

Subsystems (7)
lore
Share & tools
lore

Zhang Rui

author reviewer
#0 lore raw

PATCH 1/1 ACPI: don't send netlink events for those that go into input layer

As a replacement of /prco/acpi/event, all ACPI events are exported to user space either via netlink or via input layer.
Events that go into input layer should not be sent to netlink at the same time.

This patch introduces a new interface acpi_bus_generate_netlink_event which is called by devices that want to export events via netlink rather than input layer.

events that are sent via netlink:
ac/battery/sbs events
thermal events
processor events
thinkpad_acpi dock/bay events

events that are sent via input layer:
video hotkey events
thinkpad_acpi hotkey events
button events
asus_acpi/asus-laptop hotkey events
sonypi/sonylaptop events

---
 drivers/acpi/ac.c                 |    3 +++
 drivers/acpi/battery.c            |    3 +++
 drivers/acpi/bus.c                |    4 ----
 drivers/acpi/event.c              |   13 +++++++++----
 drivers/acpi/processor_core.c     |    7 +++++++
 drivers/acpi/sbs.c                |    1 +
 drivers/acpi/thermal.c            |   12 ++++++++++++
 drivers/misc/thinkpad_acpi.c      |   20 ++++++++++++++------
 drivers/pci/hotplug/acpiphp_ibm.c |    3 +++
 include/acpi/acpi_bus.h           |    3 +--
 10 files changed, 53 insertions(+), 16 deletions(-)
drivers/acpi/bus.c +0 -4
Index: linux-2.6.23-rc3/drivers/acpi/bus.c
===================================================================
@@ -292,10 +292,6 @@ int acpi_bus_generate_event(struct acpi_
 	if (!device)
 		return -EINVAL;
 
-	if (acpi_bus_generate_genetlink_event(device, type, data))
-		printk(KERN_WARNING PREFIX
-			"Failed to generate an ACPI event via genetlink!\n");
-
 	/* drop event on the floor if no one's listening */
 	if (!event_is_open)
 		return 0;
drivers/acpi/event.c +9 -4
Index: linux-2.6.23-rc3/drivers/acpi/event.c
===================================================================
@@ -147,7 +147,8 @@ static struct genl_multicast_group acpi_
 	.name = ACPI_GENL_MCAST_GROUP_NAME,
 };
 
-int acpi_bus_generate_genetlink_event(struct acpi_device *device,
+int acpi_bus_generate_netlink_event(const char *device_class,
+				      const char *bus_id,
 				      u8 type, int data)
 {
 	struct sk_buff *skb;
@@ -191,8 +192,8 @@ int acpi_bus_generate_genetlink_event(st
 
 	memset(event, 0, sizeof(struct acpi_genl_event));
 
-	strcpy(event->device_class, device->pnp.device_class);
-	strcpy(event->bus_id, device->dev.bus_id);
+	strcpy(event->device_class, device_class);
+	strcpy(event->bus_id, bus_id);
 	event->type = type;
 	event->data = data;
 
@@ -211,6 +212,8 @@ int acpi_bus_generate_genetlink_event(st
 	return 0;
 }
 
+EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
+
 static int acpi_event_genetlink_init(void)
 {
 	int result;
@@ -228,12 +231,14 @@ static int acpi_event_genetlink_init(voi
 }
 
 #else
-int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type,
+int acpi_bus_generate_netlink_event(struct acpi_device *device, u8 type,
 				      int data)
 {
 	return 0;
 }
 
+EXPORT_SYMBOL(acpi_generate_netlink_event);
+
 static int acpi_event_genetlink_init(void)
 {
 	return -ENODEV;
drivers/acpi/ac.c +3 -0
Index: linux-2.6.23-rc3/drivers/acpi/ac.c
===================================================================
@@ -205,6 +205,9 @@ static void acpi_ac_notify(acpi_handle h
 	case ACPI_NOTIFY_DEVICE_CHECK:
 		acpi_ac_get_state(ac);
 		acpi_bus_generate_event(device, event, (u32) ac->state);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event,
+						  (u32) ac->state);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
include/acpi/acpi_bus.h +1 -2
Index: linux-2.6.23-rc3/include/acpi/acpi_bus.h
===================================================================
@@ -321,8 +321,7 @@ struct acpi_bus_event {
 };
 
 extern struct kset acpi_subsys;
-extern int acpi_bus_generate_genetlink_event(struct acpi_device *device,
-						u8 type, int data);
+extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
 /*
  * External Functions
  */
drivers/acpi/battery.c +3 -0
Index: linux-2.6.23-rc3/drivers/acpi/battery.c
===================================================================
@@ -869,6 +869,9 @@ static void acpi_battery_notify(acpi_han
 		acpi_battery_notify_update(battery);
 		acpi_bus_generate_event(device, event,
 					acpi_battery_present(battery));
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event,
+						  acpi_battery_present(battery));
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
drivers/acpi/processor_core.c +7 -0
Index: linux-2.6.23-rc3/drivers/acpi/processor_core.c
===================================================================
@@ -700,14 +700,21 @@ static void acpi_processor_notify(acpi_h
 		acpi_processor_ppc_has_changed(pr);
 		acpi_bus_generate_event(device, event,
 					pr->performance_platform_limit);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event,
+						  pr->performance_platform_limit);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_POWER:
 		acpi_processor_cst_has_changed(pr);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
 		acpi_processor_tstate_has_changed(pr);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				  "Unsupported event [0x%x]\n", event));
drivers/acpi/thermal.c +12 -0
Index: linux-2.6.23-rc3/drivers/acpi/thermal.c
===================================================================
@@ -487,6 +487,10 @@ static int acpi_thermal_critical(struct 
 	       KELVIN_TO_CELSIUS(tz->temperature));
 	acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
 				tz->trips.critical.flags.enabled);
+	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
+					  tz->device->dev.bus_id,
+					  ACPI_THERMAL_NOTIFY_CRITICAL,
+					  tz->trips.critical.flags.enabled);
 
 	orderly_poweroff(true);
 
@@ -506,6 +510,10 @@ static int acpi_thermal_hot(struct acpi_
 
 	acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
 				tz->trips.hot.flags.enabled);
+	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
+					  tz->device->dev.bus_id,
+					  ACPI_THERMAL_NOTIFY_HOT,
+					  tz->trips.hot.flags.enabled);
 
 	/* TBD: Call user-mode "sleep(S4)" function */
 
@@ -1150,11 +1158,15 @@ static void acpi_thermal_notify(acpi_han
 		acpi_thermal_get_trip_points(tz);
 		acpi_thermal_check(tz);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 		break;
 	case ACPI_THERMAL_NOTIFY_DEVICES:
 		if (tz->flags.devices)
 			acpi_thermal_get_devices(tz);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
drivers/misc/thinkpad_acpi.c +14 -6
Index: linux-2.6.23-rc3/drivers/misc/thinkpad_acpi.c
===================================================================
@@ -2162,22 +2162,27 @@ static void dock_notify(struct ibm_struc
 	int docked = dock_docked();
 	int pci = ibm->acpi->hid && ibm->acpi->device &&
 		acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
+	int data;
 
 	if (event == 1 && !pci)	/* 570 */
-		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
+		data = 1;	/* button */
 	else if (event == 1 && pci)	/* 570 */
-		acpi_bus_generate_event(ibm->acpi->device, event, 3);	/* dock */
+		data = 3;	/* dock */
 	else if (event == 3 && docked)
-		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
+		data = 1;	/* button */
 	else if (event == 3 && !docked)
-		acpi_bus_generate_event(ibm->acpi->device, event, 2);	/* undock */
+		data = 2;	/* undock */
 	else if (event == 0 && docked)
-		acpi_bus_generate_event(ibm->acpi->device, event, 3);	/* dock */
+		data = 3;	/* dock */
 	else {
 		printk(IBM_ERR "unknown dock event %d, status %d\n",
 		       event, _sta(dock_handle));
-		acpi_bus_generate_event(ibm->acpi->device, event, 0);	/* unknown */
+		data = 0;	/* unknown */
 	}
+	acpi_bus_generate_event(ibm->acpi->device, event, data);
+	acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+					  ibm->acpi->device->dev.bus_id,
+					  event, data);
 }
 
 static int dock_read(char *p)
@@ -2276,6 +2281,9 @@ static int __init bay_init(struct ibm_in
 static void bay_notify(struct ibm_struct *ibm, u32 event)
 {
 	acpi_bus_generate_event(ibm->acpi->device, event, 0);
+	acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+					  ibm->acpi->device->dev.bus_id,
+					  event, 0);
 }
 
 #define bay_occupied(b) (_sta(b##_handle) & 1)
drivers/pci/hotplug/acpiphp_ibm.c +3 -0
Index: linux-2.6.23-rc3/drivers/pci/hotplug/acpiphp_ibm.c
===================================================================
@@ -268,6 +268,9 @@ static void ibm_handle_events(acpi_handl
 	if (subevent == 0x80) {
 		dbg("%s: generationg bus event\n", __FUNCTION__);
 		acpi_bus_generate_event(note->device, note->event, detail);
+		acpi_bus_generate_netlink_event(note->device->pnp.device_class,
+						  note->device->dev.bus_id,
+						  note->event, detail);
 	} else
 		note->event = event;
 }
drivers/acpi/sbs.c +1 -0
Index: linux-2.6.23-rc3/drivers/acpi/sbs.c
===================================================================
@@ -445,6 +445,7 @@ static int acpi_sbs_generate_event(struc
 	strcpy(acpi_device_bid(device), bid_saved);
 	strcpy(acpi_device_class(device), class_saved);
 
+	acpi_bus_generate_netlink_event(class, bid, event, state);
 	return result;
 }
 
reviewer Applied
#1 lore raw

I like it, Rui.

I think that upon this patch, we can start to deprecate acpi_bus_generate_event, as every user of it is now handled by the input layer or netlink.

applied.

thanks,
-Len

Quoted 284 lines · Zhang Rui

As a replacement of /prco/acpi/event, all ACPI events are exported to user space either via netlink or via input layer.
Events that go into input layer should not be sent to netlink at the same time.

This patch introduces a new interface acpi_bus_generate_netlink_event which is called by devices that want to export events via netlink rather than input layer.

events that are sent via netlink:
ac/battery/sbs events
thermal events
processor events
thinkpad_acpi dock/bay events

events that are sent via input layer:
video hotkey events
thinkpad_acpi hotkey events
button events
asus_acpi/asus-laptop hotkey events
sonypi/sonylaptop events

---
 drivers/acpi/ac.c                 |    3 +++
 drivers/acpi/battery.c            |    3 +++
 drivers/acpi/bus.c                |    4 ----
 drivers/acpi/event.c              |   13 +++++++++----
 drivers/acpi/processor_core.c     |    7 +++++++
 drivers/acpi/sbs.c                |    1 +
 drivers/acpi/thermal.c            |   12 ++++++++++++
 drivers/misc/thinkpad_acpi.c      |   20 ++++++++++++++------
 drivers/pci/hotplug/acpiphp_ibm.c |    3 +++
 include/acpi/acpi_bus.h           |    3 +--
 10 files changed, 53 insertions(+), 16 deletions(-)

Index: linux-2.6.23-rc3/drivers/acpi/bus.c
===================================================================

drivers/acpi/bus.c +0 -4
@@ -292,10 +292,6 @@ int acpi_bus_generate_event(struct acpi_
 	if (!device)
 		return -EINVAL;
 
-	if (acpi_bus_generate_genetlink_event(device, type, data))
-		printk(KERN_WARNING PREFIX
-			"Failed to generate an ACPI event via genetlink!\n");
-
 	/* drop event on the floor if no one's listening */
 	if (!event_is_open)
 		return 0;

Index: linux-2.6.23-rc3/drivers/acpi/event.c
===================================================================

drivers/acpi/event.c +9 -4
@@ -147,7 +147,8 @@ static struct genl_multicast_group acpi_
 	.name = ACPI_GENL_MCAST_GROUP_NAME,
 };
 
-int acpi_bus_generate_genetlink_event(struct acpi_device *device,
+int acpi_bus_generate_netlink_event(const char *device_class,
+				      const char *bus_id,
 				      u8 type, int data)
 {
 	struct sk_buff *skb;
@@ -191,8 +192,8 @@ int acpi_bus_generate_genetlink_event(st
 
 	memset(event, 0, sizeof(struct acpi_genl_event));
 
-	strcpy(event->device_class, device->pnp.device_class);
-	strcpy(event->bus_id, device->dev.bus_id);
+	strcpy(event->device_class, device_class);
+	strcpy(event->bus_id, bus_id);
 	event->type = type;
 	event->data = data;
 
@@ -211,6 +212,8 @@ int acpi_bus_generate_genetlink_event(st
 	return 0;
 }
 
+EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
+
 static int acpi_event_genetlink_init(void)
 {
 	int result;
@@ -228,12 +231,14 @@ static int acpi_event_genetlink_init(voi
 }
 
 #else
-int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type,
+int acpi_bus_generate_netlink_event(struct acpi_device *device, u8 type,
 				      int data)
 {
 	return 0;
 }
 
+EXPORT_SYMBOL(acpi_generate_netlink_event);
+
 static int acpi_event_genetlink_init(void)
 {
 	return -ENODEV;

Index: linux-2.6.23-rc3/drivers/acpi/ac.c
===================================================================

drivers/acpi/ac.c +3 -0
@@ -205,6 +205,9 @@ static void acpi_ac_notify(acpi_handle h
 	case ACPI_NOTIFY_DEVICE_CHECK:
 		acpi_ac_get_state(ac);
 		acpi_bus_generate_event(device, event, (u32) ac->state);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event,
+						  (u32) ac->state);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,

Index: linux-2.6.23-rc3/include/acpi/acpi_bus.h
===================================================================

include/acpi/acpi_bus.h +1 -2
@@ -321,8 +321,7 @@ struct acpi_bus_event {
 };
 
 extern struct kset acpi_subsys;
-extern int acpi_bus_generate_genetlink_event(struct acpi_device *device,
-						u8 type, int data);
+extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
 /*
  * External Functions
  */

Index: linux-2.6.23-rc3/drivers/acpi/battery.c
===================================================================

drivers/acpi/battery.c +3 -0
@@ -869,6 +869,9 @@ static void acpi_battery_notify(acpi_han
 		acpi_battery_notify_update(battery);
 		acpi_bus_generate_event(device, event,
 					acpi_battery_present(battery));
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event,
+						  acpi_battery_present(battery));
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,

Index: linux-2.6.23-rc3/drivers/acpi/processor_core.c
===================================================================

drivers/acpi/processor_core.c +7 -0
@@ -700,14 +700,21 @@ static void acpi_processor_notify(acpi_h
 		acpi_processor_ppc_has_changed(pr);
 		acpi_bus_generate_event(device, event,
 					pr->performance_platform_limit);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event,
+						  pr->performance_platform_limit);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_POWER:
 		acpi_processor_cst_has_changed(pr);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
 		acpi_processor_tstate_has_changed(pr);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				  "Unsupported event [0x%x]\n", event));

Index: linux-2.6.23-rc3/drivers/acpi/thermal.c
===================================================================

drivers/acpi/thermal.c +12 -0
@@ -487,6 +487,10 @@ static int acpi_thermal_critical(struct 
 	       KELVIN_TO_CELSIUS(tz->temperature));
 	acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
 				tz->trips.critical.flags.enabled);
+	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
+					  tz->device->dev.bus_id,
+					  ACPI_THERMAL_NOTIFY_CRITICAL,
+					  tz->trips.critical.flags.enabled);
 
 	orderly_poweroff(true);
 
@@ -506,6 +510,10 @@ static int acpi_thermal_hot(struct acpi_
 
 	acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
 				tz->trips.hot.flags.enabled);
+	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
+					  tz->device->dev.bus_id,
+					  ACPI_THERMAL_NOTIFY_HOT,
+					  tz->trips.hot.flags.enabled);
 
 	/* TBD: Call user-mode "sleep(S4)" function */
 
@@ -1150,11 +1158,15 @@ static void acpi_thermal_notify(acpi_han
 		acpi_thermal_get_trip_points(tz);
 		acpi_thermal_check(tz);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 		break;
 	case ACPI_THERMAL_NOTIFY_DEVICES:
 		if (tz->flags.devices)
 			acpi_thermal_get_devices(tz);
 		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  device->dev.bus_id, event, 0);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,

Index: linux-2.6.23-rc3/drivers/misc/thinkpad_acpi.c
===================================================================

drivers/misc/thinkpad_acpi.c +14 -6
@@ -2162,22 +2162,27 @@ static void dock_notify(struct ibm_struc
 	int docked = dock_docked();
 	int pci = ibm->acpi->hid && ibm->acpi->device &&
 		acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
+	int data;
 
 	if (event == 1 && !pci)	/* 570 */
-		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
+		data = 1;	/* button */
 	else if (event == 1 && pci)	/* 570 */
-		acpi_bus_generate_event(ibm->acpi->device, event, 3);	/* dock */
+		data = 3;	/* dock */
 	else if (event == 3 && docked)
-		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
+		data = 1;	/* button */
 	else if (event == 3 && !docked)
-		acpi_bus_generate_event(ibm->acpi->device, event, 2);	/* undock */
+		data = 2;	/* undock */
 	else if (event == 0 && docked)
-		acpi_bus_generate_event(ibm->acpi->device, event, 3);	/* dock */
+		data = 3;	/* dock */
 	else {
 		printk(IBM_ERR "unknown dock event %d, status %d\n",
 		       event, _sta(dock_handle));
-		acpi_bus_generate_event(ibm->acpi->device, event, 0);	/* unknown */
+		data = 0;	/* unknown */
 	}
+	acpi_bus_generate_event(ibm->acpi->device, event, data);
+	acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+					  ibm->acpi->device->dev.bus_id,
+					  event, data);
 }
 
 static int dock_read(char *p)
@@ -2276,6 +2281,9 @@ static int __init bay_init(struct ibm_in
 static void bay_notify(struct ibm_struct *ibm, u32 event)
 {
 	acpi_bus_generate_event(ibm->acpi->device, event, 0);
+	acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
+					  ibm->acpi->device->dev.bus_id,
+					  event, 0);
 }
 
 #define bay_occupied(b) (_sta(b##_handle) & 1)

Index: linux-2.6.23-rc3/drivers/pci/hotplug/acpiphp_ibm.c
===================================================================

drivers/pci/hotplug/acpiphp_ibm.c +3 -0
@@ -268,6 +268,9 @@ static void ibm_handle_events(acpi_handl
 	if (subevent == 0x80) {
 		dbg("%s: generationg bus event\n", __FUNCTION__);
 		acpi_bus_generate_event(note->device, note->event, detail);
+		acpi_bus_generate_netlink_event(note->device->pnp.device_class,
+						  note->device->dev.bus_id,
+						  note->event, detail);
 	} else
 		note->event = event;
 }

Index: linux-2.6.23-rc3/drivers/acpi/sbs.c
===================================================================

drivers/acpi/sbs.c +1 -0
@@ -445,6 +445,7 @@ static int acpi_sbs_generate_event(struc
 	strcpy(acpi_device_bid(device), bid_saved);
 	strcpy(acpi_device_class(device), class_saved);
 
+	acpi_bus_generate_netlink_event(class, bid, event, state);
 	return result;
 }
 
#2 lore raw

Hi Len!

Quoted 6 lines · Len Brown

I like it, Rui.

I think that upon this patch, we can start to deprecate acpi_bus_generate_event, as every user of it is now handled by the input layer or netlink.

applied.

This calls for (good!) changes in thinkpad-acpi and some issues I had with exactly the same problem.

Len, to which tree is that change targeted? I will have to target some thinkpad-acpi changes that depend on it.

Signature · 4 lines
  "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
reviewer
#3 lore raw
Quoted 9 lines · Henrique de Moraes Holschuh

Hi Len!

Quoted 5 lines · Len Brown

I like it, Rui.

I think that upon this patch, we can start to deprecate acpi_bus_generate_event, as every user of it is now handled by the input layer or netlink.

Quoted 7 lines
Quoted 1 line

applied.

This calls for (good!) changes in thinkpad-acpi and some issues I had with exactly the same problem.

Len, to which tree is that change targeted? I will have to target some thinkpad-acpi changes that depend on it.

Since Rui's patch is an incremental to netlink events, which are new in 2.6.23, I'm going to request Rui's patch for inclusion in 2.6.23. I'm also going to include "[PATCH] ACPI: Schedule /proc/acpi/event for removal" with it.

They'll both be in the acpi-test tree upon my next push, probably tonight. maybe go to Linus as soon as tomorrow since delay in the -rc3 timeframe would be folly.

thanks,
-Len

#4 lore raw
Quoted 4 lines · Len Brown
Quoted 3 lines · Henrique de Moraes Holschuh

This calls for (good!) changes in thinkpad-acpi and some issues I had with exactly the same problem.

Quoted 8 lines
Quoted 2 lines

Len, to which tree is that change targeted? I will have to target some thinkpad-acpi changes that depend on it.

Since Rui's patch is an incremental to netlink events, which are new in 2.6.23, I'm going to request Rui's patch for inclusion in 2.6.23. I'm also going to include "[PATCH] ACPI: Schedule /proc/acpi/event for removal" with it.

Thanks. That means I should start working on the thinkpad-acpi angle, then.

I hope its thinkpad-acpi counterpart can be accepted into -rc4, it will do away with that pesky Kconfig INPUT_ENABLE thing I had to add to get some measure of backward compatibility when I added the input device to thinkpad-acpi.

Signature · 4 lines
  "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
reviewer
#5 lore raw

PATCH 1/1 ACPI: Schedule /proc/acpi/event for removal

In reply to Zhang Rui

From: Len Brown <[email protected]>

Schedule /proc/acpi/event for removal in 6 months.

Re-name acpi_bus_generate_event() to acpi_bus_generate_proc_event() to make sure there is no confusion that it is for /proc/acpi/event only.

Add CONFIG_ACPI_PROC_EVENT to allow removal of /proc/acpi/event. There is no functional change if CONFIG_ACPI_PROC_EVENT=y

---
 Documentation/feature-removal-schedule.txt |    8 +++++
 drivers/acpi/Kconfig                       |   14 ++++++++++
 drivers/acpi/ac.c                          |    2 -
 drivers/acpi/asus_acpi.c                   |    2 -
 drivers/acpi/battery.c                     |    2 -
 drivers/acpi/bus.c                         |    6 ++--
 drivers/acpi/button.c                      |    2 -
 drivers/acpi/event.c                       |    6 ++++
 drivers/acpi/processor_core.c              |    6 ++--
 drivers/acpi/sbs.c                         |    2 -
 drivers/acpi/thermal.c                     |    8 ++---
 drivers/acpi/video.c                       |   10 +++----
 drivers/char/sonypi.c                      |    2 -
 drivers/misc/asus-laptop.c                 |    2 -
 drivers/misc/sony-laptop.c                 |    4 +-
 drivers/misc/thinkpad_acpi.c               |    8 ++---
 drivers/pci/hotplug/acpiphp_ibm.c          |    2 -
 include/acpi/acpi_bus.h                    |    7 ++++-
 18 files changed, 64 insertions(+), 29 deletions(-)
Documentation/feature-removal-schedule.txt +8 -0
index a43d287..b9a3fdc 100644
@@ -197,6 +197,14 @@ Who:	Len Brown <[email protected]>
 
 ---------------------------
 
+What:	/proc/acpi/event
+When:	February 2008
+Why:	/proc/acpi/event has been replaced by events via the input layer
+	and netlink since 2.6.23.
+Who:	Len Brown <[email protected]>
+
+---------------------------
+
 What:	Compaq touchscreen device emulation
 When:	Oct 2007
 Files:	drivers/input/tsdev.c
drivers/acpi/Kconfig +14 -0
index f1372de..5742594 100644
@@ -68,6 +68,20 @@ config ACPI_PROCFS
 
 	  Say N to delete /proc/acpi/ files that have moved to /sys/
 
+config ACPI_PROC_EVENT
+	bool "Deprecated /proc/acpi/event support"
+	depends on PROC_FS
+	---help---
+	  A user-space daemon, acpi, typically read /proc/acpi/event
+	  and handled all ACPI sub-system generated events.
+
+	  These events are now delivered to user-space via
+	  either the input layer, or as netlink events.
+
+	  This build option enables the old code for for legacy
+	  user-space implementation.  After some time, this will
+	  be moved under CONFIG_ACPI_PROCFS, and then deleted.
+
 config ACPI_AC
 	tristate "AC Adapter"
 	depends on X86
drivers/acpi/ac.c +1 -1
index b53c2cf..26d7070 100644
@@ -204,7 +204,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
 	case ACPI_NOTIFY_BUS_CHECK:
 	case ACPI_NOTIFY_DEVICE_CHECK:
 		acpi_ac_get_state(ac);
-		acpi_bus_generate_event(device, event, (u32) ac->state);
+		acpi_bus_generate_proc_event(device, event, (u32) ac->state);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event,
 						  (u32) ac->state);
drivers/acpi/asus_acpi.c +1 -1
index 86fd142..d915fec 100644
@@ -1069,7 +1069,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
 		hotk->brightness = (event & ~((u32) BR_DOWN));
 	}
 
-	acpi_bus_generate_event(hotk->device, event,
+	acpi_bus_generate_proc_event(hotk->device, event,
 				hotk->event_count[event % 128]++);
 
 	return;
drivers/acpi/battery.c +1 -1
index 9f0bf90..91dc4b3 100644
@@ -867,7 +867,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
 	case ACPI_NOTIFY_DEVICE_CHECK:
 		device = battery->device;
 		acpi_battery_notify_update(battery);
-		acpi_bus_generate_event(device, event,
+		acpi_bus_generate_proc_event(device, event,
 					acpi_battery_present(battery));
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event,
drivers/acpi/bus.c +4 -2
index e5084ec..9ba778a 100644
@@ -276,6 +276,7 @@ EXPORT_SYMBOL(acpi_bus_set_power);
                                 Event Management
    -------------------------------------------------------------------------- */
 
+#ifdef CONFIG_ACPI_PROC_EVENT
 static DEFINE_SPINLOCK(acpi_bus_event_lock);
 
 LIST_HEAD(acpi_bus_event_list);
@@ -283,7 +284,7 @@ DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
 
 extern int event_is_open;
 
-int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
+int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
 {
 	struct acpi_bus_event *event = NULL;
 	unsigned long flags = 0;
@@ -314,7 +315,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
 	return 0;
 }
 
-EXPORT_SYMBOL(acpi_bus_generate_event);
+EXPORT_SYMBOL(acpi_bus_generate_proc_event);
 
 int acpi_bus_receive_event(struct acpi_bus_event *event)
 {
@@ -360,6 +361,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
 }
 
 EXPORT_SYMBOL(acpi_bus_receive_event);
+#endif	/* CONFIG_ACPI_PROC_EVENT */
 
 /* --------------------------------------------------------------------------
                              Notification Handling
drivers/acpi/button.c +1 -1
index 5405813..2e79a33 100644
@@ -284,7 +284,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
 		}
 		input_sync(input);
 
-		acpi_bus_generate_event(button->device, event,
+		acpi_bus_generate_proc_event(button->device, event,
 					++button->pushed);
 		break;
 	default:
drivers/acpi/event.c +6 -0
index b7b1432..cf6d516 100644
@@ -17,6 +17,7 @@
 #define _COMPONENT		ACPI_SYSTEM_COMPONENT
 ACPI_MODULE_NAME("event");
 
+#ifdef CONFIG_ACPI_PROC_EVENT
 /* Global vars for handling event proc entry */
 static DEFINE_SPINLOCK(acpi_system_event_lock);
 int event_is_open = 0;
@@ -106,6 +107,7 @@ static const struct file_operations acpi_system_event_ops = {
 	.release = acpi_system_close_event,
 	.poll = acpi_system_poll_event,
 };
+#endif	/* CONFIG_ACPI_PROC_EVENT */
 
 #ifdef CONFIG_NET
 static unsigned int acpi_event_seqnum;
@@ -247,7 +249,9 @@ static int acpi_event_genetlink_init(void)
 
 static int __init acpi_event_init(void)
 {
+#ifdef CONFIG_ACPI_PROC_EVENT
 	struct proc_dir_entry *entry;
+#endif
 	int error = 0;
 
 	if (acpi_disabled)
@@ -259,12 +263,14 @@ static int __init acpi_event_init(void)
 		printk(KERN_WARNING PREFIX
 		       "Failed to create genetlink family for ACPI event\n");
 
+#ifdef CONFIG_ACPI_PROC_EVENT
 	/* 'event' [R] */
 	entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
 	if (entry)
 		entry->proc_fops = &acpi_system_event_ops;
 	else
 		return -ENODEV;
+#endif
 
 	return 0;
 }
drivers/acpi/processor_core.c +3 -3
index dbc2e5d..e944aae 100644
@@ -698,7 +698,7 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
 	switch (event) {
 	case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
 		acpi_processor_ppc_has_changed(pr);
-		acpi_bus_generate_event(device, event,
+		acpi_bus_generate_proc_event(device, event,
 					pr->performance_platform_limit);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event,
@@ -706,13 +706,13 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
 		break;
 	case ACPI_PROCESSOR_NOTIFY_POWER:
 		acpi_processor_cst_has_changed(pr);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event, 0);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
 		acpi_processor_tstate_has_changed(pr);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event, 0);
 	default:
drivers/acpi/sbs.c +1 -1
index 2d67e92..a578986 100644
@@ -440,7 +440,7 @@ static int acpi_sbs_generate_event(struct acpi_device *device,
 	strcpy(acpi_device_bid(device), bid);
 	strcpy(acpi_device_class(device), class);
 
-	result = acpi_bus_generate_event(device, event, state);
+	result = acpi_bus_generate_proc_event(device, event, state);
 
 	strcpy(acpi_device_bid(device), bid_saved);
 	strcpy(acpi_device_class(device), class_saved);
drivers/acpi/thermal.c +4 -4
index 291758c..2c9cfe2 100644
@@ -485,7 +485,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
 	printk(KERN_EMERG
 	       "Critical temperature reached (%ld C), shutting down.\n",
 	       KELVIN_TO_CELSIUS(tz->temperature));
-	acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
+	acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
 				tz->trips.critical.flags.enabled);
 	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
 					  tz->device->dev.bus_id,
@@ -508,7 +508,7 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
 	} else if (tz->trips.hot.flags.enabled)
 		tz->trips.hot.flags.enabled = 0;
 
-	acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
+	acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
 				tz->trips.hot.flags.enabled);
 	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
 					  tz->device->dev.bus_id,
@@ -1157,14 +1157,14 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
 	case ACPI_THERMAL_NOTIFY_THRESHOLDS:
 		acpi_thermal_get_trip_points(tz);
 		acpi_thermal_check(tz);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event, 0);
 		break;
 	case ACPI_THERMAL_NOTIFY_DEVICES:
 		if (tz->flags.devices)
 			acpi_thermal_get_devices(tz);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		acpi_bus_generate_netlink_event(device->pnp.device_class,
 						  device->dev.bus_id, event, 0);
 		break;
drivers/acpi/video.c +5 -5
index d987019..9a5cfcf 100644
@@ -1775,7 +1775,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
 	switch (event) {
 	case ACPI_VIDEO_NOTIFY_SWITCH:	/* User requested a switch,
 					 * most likely via hotkey. */
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		break;
 
 	case ACPI_VIDEO_NOTIFY_PROBE:	/* User plugged in or removed a video
@@ -1783,14 +1783,14 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
 		acpi_video_device_enumerate(video);
 		acpi_video_device_rebind(video);
 		acpi_video_switch_output(video, event);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		break;
 
 	case ACPI_VIDEO_NOTIFY_CYCLE:	/* Cycle Display output hotkey pressed. */
 	case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT:	/* Next Display output hotkey pressed. */
 	case ACPI_VIDEO_NOTIFY_PREV_OUTPUT:	/* previous Display output hotkey pressed. */
 		acpi_video_switch_output(video, event);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		break;
 
 	default:
@@ -1815,7 +1815,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
 	switch (event) {
 	case ACPI_VIDEO_NOTIFY_SWITCH:	/* change in status (cycle output device) */
 	case ACPI_VIDEO_NOTIFY_PROBE:	/* change in status (output device status) */
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		break;
 	case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:	/* Cycle brightness */
 	case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:	/* Increase brightness */
@@ -1823,7 +1823,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
 	case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:	/* zero brightnesss */
 	case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:	/* display device off */
 		acpi_video_switch_brightness(video_device, event);
-		acpi_bus_generate_event(device, event, 0);
+		acpi_bus_generate_proc_event(device, event, 0);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
drivers/char/sonypi.c +1 -1
index aeec67e..8598585 100644
@@ -875,7 +875,7 @@ found:
 
 #ifdef CONFIG_ACPI
 	if (sonypi_acpi_device)
-		acpi_bus_generate_event(sonypi_acpi_device, 1, event);
+		acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
 #endif
 
 	kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
drivers/misc/asus-laptop.c +1 -1
index d0fc4fd..f8ae58f 100644
@@ -732,7 +732,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
 		lcd_blank(FB_BLANK_POWERDOWN);
 	}
 
-	acpi_bus_generate_event(hotk->device, event,
+	acpi_bus_generate_proc_event(hotk->device, event,
 				hotk->event_count[event % 128]++);
 
 	return;
drivers/misc/sony-laptop.c +2 -2
index 91da688..743bd49 100644
@@ -904,7 +904,7 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
 
 	dprintk("sony_acpi_notify, event: 0x%.2x\n", ev);
 	sony_laptop_report_input_event(ev);
-	acpi_bus_generate_event(sony_nc_acpi_device, 1, ev);
+	acpi_bus_generate_proc_event(sony_nc_acpi_device, 1, ev);
 }
 
 static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -2292,7 +2292,7 @@ static irqreturn_t sony_pic_irq(int irq, void *dev_id)
 
 found:
 	sony_laptop_report_input_event(device_event);
-	acpi_bus_generate_event(spic_dev.acpi_dev, 1, device_event);
+	acpi_bus_generate_proc_event(spic_dev.acpi_dev, 1, device_event);
 	sonypi_compat_report_event(device_event);
 
 	return IRQ_HANDLED;
drivers/misc/thinkpad_acpi.c +4 -4
index d0825a3..bb8956d 100644
@@ -1190,10 +1190,10 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
 		}
 
 		if (sendacpi)
-			acpi_bus_generate_event(ibm->acpi->device, event, hkey);
+			acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
 	} else {
 		printk(IBM_ERR "unknown hotkey notification event %d\n", event);
-		acpi_bus_generate_event(ibm->acpi->device, event, 0);
+		acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
 	}
 }
 
@@ -2179,7 +2179,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
 		       event, _sta(dock_handle));
 		data = 0;	/* unknown */
 	}
-	acpi_bus_generate_event(ibm->acpi->device, event, data);
+	acpi_bus_generate_proc_event(ibm->acpi->device, event, data);
 	acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
 					  ibm->acpi->device->dev.bus_id,
 					  event, data);
@@ -2280,7 +2280,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->acpi->device, event, 0);
+	acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
 	acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
 					  ibm->acpi->device->dev.bus_id,
 					  event, 0);
drivers/pci/hotplug/acpiphp_ibm.c +1 -1
index 3609024..d2c410c 100644
@@ -267,7 +267,7 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
 
 	if (subevent == 0x80) {
 		dbg("%s: generationg bus event\n", __FUNCTION__);
-		acpi_bus_generate_event(note->device, note->event, detail);
+		acpi_bus_generate_proc_event(note->device, note->event, detail);
 		acpi_bus_generate_netlink_event(note->device->pnp.device_class,
 						  note->device->dev.bus_id,
 						  note->event, detail);
include/acpi/acpi_bus.h +6 -1
index 8203cdd..86aea44 100644
@@ -331,8 +331,13 @@ void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context);
 int acpi_bus_get_status(struct acpi_device *device);
 int acpi_bus_get_power(acpi_handle handle, int *state);
 int acpi_bus_set_power(acpi_handle handle, int state);
-int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data);
+#ifdef CONFIG_ACPI_PROC_EVENT
+int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data);
 int acpi_bus_receive_event(struct acpi_bus_event *event);
+#else
+static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
+	{ return 0; }
+#endif
 int acpi_bus_register_driver(struct acpi_driver *driver);
 void acpi_bus_unregister_driver(struct acpi_driver *driver);
 int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,