summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2018-06-26 19:09:34 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-07-31 15:56:42 +0300
commit9b647bd4e3b1d8c87e1efcf4dd9ea6ed9fb93e1b (patch)
treea811990dc133113c2fb8acda34e1aa58d5e2bf6f /lib
parent29994a50817d67c289277ef296215cbbffb7c19d (diff)
lib: configfs: Globalize nested configfs callback functions
Android now uses clang as the default C compiler, and gcc support is deprecated. clang doesn't support nested functions, which were used to implement callback functions in the ConfigFS code. We thus move the callbacks to the global scope. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/configfs.c146
1 files changed, 73 insertions, 73 deletions
diff --git a/lib/configfs.c b/lib/configfs.c
index 5de7079..0a8d8e5 100644
--- a/lib/configfs.c
+++ b/lib/configfs.c
@@ -346,20 +346,20 @@ static const struct uvc_function_config g_webcam_config = {
},
};
-static int parse_legacy_g_webcam(const char *udc,
- struct uvc_function_config *fc)
+static void *memdup(const void *src, size_t size)
{
- void *memdup(const void *src, size_t size)
- {
- void *dst;
+ void *dst;
- dst = malloc(size);
- if (!dst)
- return NULL;
- memcpy(dst, src, size);
- return dst;
- }
+ dst = malloc(size);
+ if (!dst)
+ return NULL;
+ memcpy(dst, src, size);
+ return dst;
+}
+static int parse_legacy_g_webcam(const char *udc,
+ struct uvc_function_config *fc)
+{
unsigned int i, j;
size_t size;
@@ -547,34 +547,34 @@ static int configfs_parse_streaming_frame(const char *path,
return ret;
}
-static int configfs_parse_streaming_format(const char *path,
- struct uvc_function_config_format *format)
+static int frame_filter(const struct dirent *ent)
{
- int frame_filter(const struct dirent *ent)
- {
- /* Accept all directories but "." and "..". */
- if (ent->d_type != DT_DIR)
- return 0;
- if (!strcmp(ent->d_name, "."))
- return 0;
- if (!strcmp(ent->d_name, ".."))
- return 0;
- return 1;
- }
+ /* Accept all directories but "." and "..". */
+ if (ent->d_type != DT_DIR)
+ return 0;
+ if (!strcmp(ent->d_name, "."))
+ return 0;
+ if (!strcmp(ent->d_name, ".."))
+ return 0;
+ return 1;
+}
- int frame_compare(const void *a, const void *b)
- {
- const struct uvc_function_config_frame *fa = a;
- const struct uvc_function_config_frame *fb = b;
-
- if (fa->index < fb->index)
- return -1;
- else if (fa->index == fb->index)
- return 0;
- else
- return 1;
- }
+static int frame_compare(const void *a, const void *b)
+{
+ const struct uvc_function_config_frame *fa = a;
+ const struct uvc_function_config_frame *fb = b;
+ if (fa->index < fb->index)
+ return -1;
+ else if (fa->index == fb->index)
+ return 0;
+ else
+ return 1;
+}
+
+static int configfs_parse_streaming_format(const char *path,
+ struct uvc_function_config_format *format)
+{
struct dirent **entries;
unsigned int i;
int n_entries;
@@ -640,43 +640,43 @@ done:
return ret;
}
-static int configfs_parse_streaming_header(const char *path,
- struct uvc_function_config_streaming *cfg)
+static int format_filter(const struct dirent *ent)
{
- int format_filter(const struct dirent *ent)
- {
- char *path;
- bool valid;
+ char *path;
+ bool valid;
- /*
- * Accept all links that point to a directory containing a
- * "bFormatIndex" file.
- */
- if (ent->d_type != DT_LNK)
- return 0;
+ /*
+ * Accept all links that point to a directory containing a
+ * "bFormatIndex" file.
+ */
+ if (ent->d_type != DT_LNK)
+ return 0;
- path = path_join(ent->d_name, "bFormatIndex");
- if (!path)
- return 0;
+ path = path_join(ent->d_name, "bFormatIndex");
+ if (!path)
+ return 0;
- valid = access(path, R_OK);
- free(path);
- return valid;
- }
+ valid = access(path, R_OK);
+ free(path);
+ return valid;
+}
- int format_compare(const void *a, const void *b)
- {
- const struct uvc_function_config_format *fa = a;
- const struct uvc_function_config_format *fb = b;
-
- if (fa->index < fb->index)
- return -1;
- else if (fa->index == fb->index)
- return 0;
- else
- return 1;
- }
+static int format_compare(const void *a, const void *b)
+{
+ const struct uvc_function_config_format *fa = a;
+ const struct uvc_function_config_format *fb = b;
+ if (fa->index < fb->index)
+ return -1;
+ else if (fa->index == fb->index)
+ return 0;
+ else
+ return 1;
+}
+
+static int configfs_parse_streaming_header(const char *path,
+ struct uvc_function_config_streaming *cfg)
+{
struct dirent **entries;
unsigned int i;
int n_entries;
@@ -724,15 +724,15 @@ done:
return ret;
}
+static int link_filter(const struct dirent *ent)
+{
+ /* Accept all links. */
+ return ent->d_type == DT_LNK;
+}
+
static int configfs_parse_streaming(const char *path,
struct uvc_function_config_streaming *cfg)
{
- int link_filter(const struct dirent *ent)
- {
- /* Accept all links. */
- return ent->d_type == DT_LNK;
- }
-
char *header;
char *class;
int ret;