[PATCH libevdev 2/3] Replace ID getter implementation with a define

Peter Hutterer peter.hutterer at who-t.net
Mon Jul 29 21:36:41 PDT 2013


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index 39ab445..f8d7fb6 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -689,25 +689,16 @@ PRODUCT_SETTER(vendor_id, vendor);
 PRODUCT_SETTER(bustype, bustype);
 PRODUCT_SETTER(version, version);
 
-int libevdev_get_product_id(const struct libevdev *dev)
-{
-	return dev->ids.product;
+#define PRODUCT_GETTER(name, field) \
+int libevdev_get_##name(const struct libevdev *dev) \
+{ \
+	return dev->ids.field; \
 }
 
-int libevdev_get_vendor_id(const struct libevdev *dev)
-{
-	return dev->ids.vendor;
-}
-
-int libevdev_get_bustype(const struct libevdev *dev)
-{
-	return dev->ids.bustype;
-}
-
-int libevdev_get_version(const struct libevdev *dev)
-{
-	return dev->ids.version;
-}
+PRODUCT_GETTER(product_id, product);
+PRODUCT_GETTER(vendor_id, vendor);
+PRODUCT_GETTER(bustype, bustype);
+PRODUCT_GETTER(version, version);
 
 int libevdev_get_driver_version(const struct libevdev *dev)
 {
-- 
1.8.2.1



More information about the Input-tools mailing list