Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 962ce8ca authored by Zhang Rui's avatar Zhang Rui Committed by Len Brown
Browse files

ACPI: don't duplicate input events on netlink



The previous events patch added a netlink event for every
user of the legacy /proc/acpi/event interface.

However, some users of /proc/acpi/event are really input events,
and they already report their events via the input layer.

Introduce a new interface, acpi_bus_generate_netlink_event(),
which is explicitly called by devices that want to repoprt
events via netlink.  This allows the input-like events
to opt-out of generating netlink events.  In summary:

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

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

Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent b377fd39
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -205,6 +205,9 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
	case ACPI_NOTIFY_DEVICE_CHECK:
	case ACPI_NOTIFY_DEVICE_CHECK:
		acpi_ac_get_state(ac);
		acpi_ac_get_state(ac);
		acpi_bus_generate_event(device, event, (u32) ac->state);
		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;
		break;
	default:
	default:
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+3 −0
Original line number Original line Diff line number Diff line
@@ -869,6 +869,9 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
		acpi_battery_notify_update(battery);
		acpi_battery_notify_update(battery);
		acpi_bus_generate_event(device, event,
		acpi_bus_generate_event(device, event,
					acpi_battery_present(battery));
					acpi_battery_present(battery));
		acpi_bus_generate_netlink_event(device->pnp.device_class,
						  device->dev.bus_id, event,
						  acpi_battery_present(battery));
		break;
		break;
	default:
	default:
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+0 −4
Original line number Original line Diff line number Diff line
@@ -292,10 +292,6 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
	if (!device)
	if (!device)
		return -EINVAL;
		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 */
	/* drop event on the floor if no one's listening */
	if (!event_is_open)
	if (!event_is_open)
		return 0;
		return 0;
+9 −4
Original line number Original line Diff line number Diff line
@@ -147,7 +147,8 @@ static struct genl_multicast_group acpi_event_mcgrp = {
	.name = ACPI_GENL_MCAST_GROUP_NAME,
	.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)
				      u8 type, int data)
{
{
	struct sk_buff *skb;
	struct sk_buff *skb;
@@ -191,8 +192,8 @@ int acpi_bus_generate_genetlink_event(struct acpi_device *device,


	memset(event, 0, sizeof(struct acpi_genl_event));
	memset(event, 0, sizeof(struct acpi_genl_event));


	strcpy(event->device_class, device->pnp.device_class);
	strcpy(event->device_class, device_class);
	strcpy(event->bus_id, device->dev.bus_id);
	strcpy(event->bus_id, bus_id);
	event->type = type;
	event->type = type;
	event->data = data;
	event->data = data;


@@ -211,6 +212,8 @@ int acpi_bus_generate_genetlink_event(struct acpi_device *device,
	return 0;
	return 0;
}
}


EXPORT_SYMBOL(acpi_bus_generate_netlink_event);

static int acpi_event_genetlink_init(void)
static int acpi_event_genetlink_init(void)
{
{
	int result;
	int result;
@@ -228,12 +231,14 @@ static int acpi_event_genetlink_init(void)
}
}


#else
#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)
				      int data)
{
{
	return 0;
	return 0;
}
}


EXPORT_SYMBOL(acpi_generate_netlink_event);

static int acpi_event_genetlink_init(void)
static int acpi_event_genetlink_init(void)
{
{
	return -ENODEV;
	return -ENODEV;
+7 −0
Original line number Original line Diff line number Diff line
@@ -700,14 +700,21 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
		acpi_processor_ppc_has_changed(pr);
		acpi_processor_ppc_has_changed(pr);
		acpi_bus_generate_event(device, event,
		acpi_bus_generate_event(device, event,
					pr->performance_platform_limit);
					pr->performance_platform_limit);
		acpi_bus_generate_netlink_event(device->pnp.device_class,
						  device->dev.bus_id, event,
						  pr->performance_platform_limit);
		break;
		break;
	case ACPI_PROCESSOR_NOTIFY_POWER:
	case ACPI_PROCESSOR_NOTIFY_POWER:
		acpi_processor_cst_has_changed(pr);
		acpi_processor_cst_has_changed(pr);
		acpi_bus_generate_event(device, event, 0);
		acpi_bus_generate_event(device, event, 0);
		acpi_bus_generate_netlink_event(device->pnp.device_class,
						  device->dev.bus_id, event, 0);
		break;
		break;
	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
		acpi_processor_tstate_has_changed(pr);
		acpi_processor_tstate_has_changed(pr);
		acpi_bus_generate_event(device, event, 0);
		acpi_bus_generate_event(device, event, 0);
		acpi_bus_generate_netlink_event(device->pnp.device_class,
						  device->dev.bus_id, event, 0);
	default:
	default:
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
				  "Unsupported event [0x%x]\n", event));
				  "Unsupported event [0x%x]\n", event));
Loading