[PATCH weston 5/6] evdev: do not pass a list to evdev_led_update()

Pekka Paalanen ppaalanen at gmail.com
Mon Aug 6 04:57:07 PDT 2012


evdev_led_update() does not really need the whole list of device at
once, it can be called one device at a time.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 src/compositor-android.c |    4 +++-
 src/compositor-drm.c     |    4 +++-
 src/evdev.c              |   13 ++++++-------
 src/evdev.h              |    2 +-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/compositor-android.c b/src/compositor-android.c
index 5d1eeee..71b38cf 100644
--- a/src/compositor-android.c
+++ b/src/compositor-android.c
@@ -247,8 +247,10 @@ static void
 android_led_update(struct weston_seat *seat_base, enum weston_led leds)
 {
 	struct android_seat *seat = to_android_seat(seat_base);
+	struct evdev_input_device *device;
 
-	evdev_led_update(&seat->devices_list, leds);
+	wl_list_for_each(device, &seat->devices_list, link)
+		evdev_led_update(device, leds);
 }
 
 static void
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index d35588c..4f350f0 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1971,8 +1971,10 @@ static void
 drm_led_update(struct weston_seat *seat_base, enum weston_led leds)
 {
 	struct drm_seat *seat = (struct drm_seat *) seat_base;
+	struct evdev_input_device *device;
 
-	evdev_led_update(&seat->devices_list, leds);
+	wl_list_for_each(device, &seat->devices_list, link)
+		evdev_led_update(device, leds);
 }
 
 static void
diff --git a/src/evdev.c b/src/evdev.c
index 7d93564..dba33ba 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -31,7 +31,7 @@
 #include "evdev.h"
 
 void
-evdev_led_update(struct wl_list *evdev_devices, enum weston_led leds)
+evdev_led_update(struct evdev_input_device *device, enum weston_led leds)
 {
 	static const struct {
 		enum weston_led weston;
@@ -41,10 +41,12 @@ evdev_led_update(struct wl_list *evdev_devices, enum weston_led leds)
 		{ LED_CAPS_LOCK, LED_CAPSL },
 		{ LED_SCROLL_LOCK, LED_SCROLLL },
 	};
-	struct evdev_input_device *device;
 	struct input_event ev[ARRAY_LENGTH(map)];
 	unsigned int i;
 
+	if (!device->caps & EVDEV_KEYBOARD)
+		return;
+
 	memset(ev, 0, sizeof(ev));
 	for (i = 0; i < ARRAY_LENGTH(map); i++) {
 		ev[i].type = EV_LED;
@@ -52,11 +54,8 @@ evdev_led_update(struct wl_list *evdev_devices, enum weston_led leds)
 		ev[i].value = !!(leds & map[i].weston);
 	}
 
-	wl_list_for_each(device, evdev_devices, link) {
-		if (device->caps & EVDEV_KEYBOARD)
-			i = write(device->fd, ev, sizeof ev);
-		(void)i; /* no, we really don't care about the return value */
-	}
+	i = write(device->fd, ev, sizeof ev);
+	(void)i; /* no, we really don't care about the return value */
 }
 
 static inline void
diff --git a/src/evdev.h b/src/evdev.h
index 379838a..003b362 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -106,7 +106,7 @@ struct evdev_dispatch *
 evdev_touchpad_create(struct evdev_input_device *device);
 
 void
-evdev_led_update(struct wl_list *evdev_devices, enum weston_led leds);
+evdev_led_update(struct evdev_input_device *device, enum weston_led leds);
 
 struct evdev_input_device *
 evdev_input_device_create(struct weston_seat *seat,
-- 
1.7.8.6



More information about the wayland-devel mailing list