[PATCH 4/6] move the event member from InputData to event_io()

Guillem Jover guillem.jover at nokia.com
Fri Oct 31 17:29:33 PDT 2008


As the addon does not support partial reads anymore we can move
the event member to the event_io function were it belongs.
---
 hald/linux/addons/addon-input.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 548df9f..e0b8a27 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -165,7 +165,6 @@ static char *key_name[KEY_MAX + 1] = {
 typedef struct _InputData InputData;
 struct _InputData
 {
-	struct input_event event;
 	gboolean button_has_state;
 	gboolean button_state;
 	char udi[1];			/*variable size*/
@@ -180,6 +179,7 @@ static gboolean
 event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 {
 	InputData *input_data = (InputData*) data;
+	struct input_event event;
 	DBusError error;
 	GError *gerror = NULL;
 	gsize read_bytes;
@@ -189,8 +189,7 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 
 	/* The kernel guarantees to always provide a complete event. */
 	while (g_io_channel_read_chars (channel,
-			((gchar*)&input_data->event),
-			sizeof (struct input_event),
+			((gchar *)&event), sizeof (struct input_event),
 			&read_bytes, &gerror) == G_IO_STATUS_NORMAL) {
 
 		if (read_bytes < sizeof (struct input_event)) {
@@ -199,16 +198,15 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 		}
 
 		if (input_data->button_has_state &&
-		    input_data->event.type == EV_SW) {
+		    event.type == EV_SW) {
 			char *name = NULL;
 
 			HAL_INFO (("%s: event.value=%d ; event.code=%d (0x%02x)",
-				   input_data->udi, input_data->event.value,
-				   input_data->event.code,
-				   input_data->event.code));
+				   input_data->udi,
+				   event.value, event.code, event.code));
 
 
-			switch (input_data->event.code) {
+			switch (event.code) {
 			case SW_LID:
 				name = "lid";
 				break;
@@ -244,7 +242,7 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 				if (ioctl (g_io_channel_unix_get_fd(channel), EVIOCGSW(sizeof (bitmask)), bitmask) < 0) {
 					HAL_DEBUG (("ioctl EVIOCGSW failed"));
 				} else {
-					int new_state = test_bit (input_data->event.code, bitmask);
+					int new_state = test_bit (event.code, bitmask);
 					if (new_state != input_data->button_state) {
 						input_data->button_state = new_state;
 
@@ -261,11 +259,11 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 					}
 				}
 			}
-		} else if (input_data->event.type == EV_KEY && key_name[input_data->event.code] != NULL && input_data->event.value) {
+		} else if (event.type == EV_KEY && key_name[event.code] != NULL && event.value) {
 			dbus_error_init (&error);
 			libhal_device_emit_condition (ctx, input_data->udi,
 						      "ButtonPressed",
-						      key_name[input_data->event.code],
+						      key_name[event.code],
 						      &error);
 			dbus_error_free (&error);
 		}
-- 
1.6.0.2



More information about the hal mailing list