uvc-gadget: Use macros from tools.h
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 21 May 2018 18:43:21 +0000 (21:43 +0300)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 21 May 2018 18:43:21 +0000 (21:43 +0300)
The tools.h header defines clamp and ARRAY_SIZE macros. Use the header
to replace the private implementation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
uvc-gadget.c

index 7d6c20a..12a361d 100644 (file)
 #include <linux/videodev2.h>
 
 #include "events.h"
+#include "tools.h"
 
 #define UVC_INTF_CONTROL       0
 #define UVC_INTF_STREAMING     1
 
-#define clamp(val, min, max) ({                 \
-        typeof(val) __val = (val);              \
-        typeof(min) __min = (min);              \
-        typeof(max) __max = (max);              \
-        (void) (&__val == &__min);              \
-        (void) (&__val == &__max);              \
-        __val = __val < __min ? __min: __val;   \
-        __val > __max ? __max: __val; })
-
-#define ARRAY_SIZE(a)  ((sizeof(a) / sizeof(a[0])))
-
 struct uvc_device
 {
        int fd;