summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2017-03-03 17:39:21 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2017-03-03 17:48:44 +0100
commit5d0962ed41d359d56ec6ada0894719e07bc950de (patch)
tree97725e73ad50d652c0c6e66a5cb9d891c58c65c4
parent651177558b7be6d91bf12420bfd8b2fd42727755 (diff)
downloadlibusbg-5d0962ed41d359d56ec6ada0894719e07bc950de.tar.gz
libusbg-5d0962ed41d359d56ec6ada0894719e07bc950de.tar.bz2
libusbg-5d0962ed41d359d56ec6ada0894719e07bc950de.zip
libusbgx: Fix meaning of HAS_LIBCONFIG and HAS_GADGET_SCHEMES
We have two configure options related to libconfig: 1) --disable-gadget-schemes 2) --without-libconfig Option #1 means that libusbgx itself should be compiled without gadget schemes support. Option #2 means that everything what requires libconfig should be turned off. So option #2 is wider than #1 as libconfig us used also in our testing program. To fix this meaning let's use HAS_GADGET_SCHEMES inside library source code to determine if we should use libconfig or not and HAS_LIBCONFIG inside our tests source code. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r--include/usbg/usbg_internal.h2
-rw-r--r--include/usbg/usbg_internal_none.h8
-rw-r--r--src/function/ether.c6
-rw-r--r--src/function/ffs.c2
-rw-r--r--src/function/hid.c10
-rw-r--r--src/function/loopback.c8
-rw-r--r--src/function/midi.c8
-rw-r--r--src/function/ms.c8
-rw-r--r--src/function/phonet.c2
-rw-r--r--src/function/serial.c2
10 files changed, 32 insertions, 24 deletions
diff --git a/include/usbg/usbg_internal.h b/include/usbg/usbg_internal.h
index f0cca68..5634134 100644
--- a/include/usbg/usbg_internal.h
+++ b/include/usbg/usbg_internal.h
@@ -18,7 +18,7 @@
#include <usbg/usbg.h>
#include <malloc.h>
#include <sys/types.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include "usbg_internal_libconfig.h"
#else
#include "usbg_internal_none.h"
diff --git a/include/usbg/usbg_internal_none.h b/include/usbg/usbg_internal_none.h
index a4aed92..2a3bed3 100644
--- a/include/usbg/usbg_internal_none.h
+++ b/include/usbg/usbg_internal_none.h
@@ -27,9 +27,17 @@ extern "C" {
#define usbg_set_config_node_ether_addr NULL
#define usbg_set_config_node_dev NULL
+/*
+ * This define comes from libconfig header.
+ *
+ * This is a kind of hack to allow compile libusbgx without
+ * gadget schemes support but our test with libconfig support.
+ */
+#ifndef __libconfig_h
typedef struct _should_not_be_used config_t;
typedef struct _should_not_be_used config_setting_t;
void config_destroy(config_t *config);
+#endif /* __libconfig_h */
#ifdef __cplusplus
}
diff --git a/src/function/ether.c b/src/function/ether.c
index df5d18a..010b9fb 100644
--- a/src/function/ether.c
+++ b/src/function/ether.c
@@ -15,7 +15,7 @@
#include "usbg/function/net.h"
#include <malloc.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
@@ -99,7 +99,7 @@ static void ether_cleanup_attrs(struct usbg_function *f, void *f_attrs)
usbg_f_net_cleanup_attrs(f_attrs);
}
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
static int ether_libconfig_import(struct usbg_function *f,
config_setting_t *root)
@@ -161,7 +161,7 @@ static int ether_libconfig_export(struct usbg_function *f,
#define ETHER_LIBCONFIG_DEP_OPS
-#endif /* HAS_LIBCONFIG */
+#endif /* HAS_GADGET_SCHEMES */
#define ETHER_FUNCTION_OPTS \
.alloc_inst = ether_alloc_inst, \
diff --git a/src/function/ffs.c b/src/function/ffs.c
index 4df3a3c..6a579d6 100644
--- a/src/function/ffs.c
+++ b/src/function/ffs.c
@@ -15,7 +15,7 @@
#include "usbg/function/ffs.h"
#include <malloc.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
diff --git a/src/function/hid.c b/src/function/hid.c
index 43f4ac8..d1f8039 100644
--- a/src/function/hid.c
+++ b/src/function/hid.c
@@ -16,7 +16,7 @@
#include <malloc.h>
#include <assert.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
@@ -44,7 +44,7 @@ struct usbg_f_hid {
.export = usbg_set_config_node_dev, \
}
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
static int hid_get_report(const char *path, const char *name, const char *attr,
void *val)
{
@@ -219,7 +219,7 @@ static void hid_cleanup_attrs(struct usbg_function *f, void *f_attrs)
usbg_f_hid_cleanup_attrs(f_attrs);
}
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
static int hid_libconfig_import(struct usbg_function *f,
config_setting_t *root)
@@ -270,7 +270,7 @@ static int hid_libconfig_export(struct usbg_function *f,
return ret;
}
-#endif /* HAS_LIBCONFIG */
+#endif /* HAS_GADGET_SCHEMES */
struct usbg_function_type usbg_f_type_hid = {
.name = "hid",
@@ -280,7 +280,7 @@ struct usbg_function_type usbg_f_type_hid = {
.get_attrs = hid_get_attrs,
.cleanup_attrs = hid_cleanup_attrs,
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
.import = hid_libconfig_import,
.export = hid_libconfig_export,
#endif
diff --git a/src/function/loopback.c b/src/function/loopback.c
index 795b2f6..069c3fb 100644
--- a/src/function/loopback.c
+++ b/src/function/loopback.c
@@ -14,7 +14,7 @@
#include "usbg/usbg_internal.h"
#include "usbg/function/loopback.h"
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
@@ -48,7 +48,7 @@ static int loopback_get_attrs(struct usbg_function *f, void *f_attrs)
return usbg_f_loopback_get_attrs(usbg_to_loopback_function(f), f_attrs);
}
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
static int loopback_libconfig_export(struct usbg_function *f,
config_setting_t *root)
@@ -111,7 +111,7 @@ static int loopback_libconfig_import(struct usbg_function *f,
return ret;
}
-#endif /* HAS_LIBCONFIG */
+#endif /* HAS_GADGET_SCHEMES */
struct usbg_function_type usbg_f_type_loopback = {
.name = "Loopback",
@@ -119,7 +119,7 @@ struct usbg_function_type usbg_f_type_loopback = {
.free_inst = loopback_free_inst,
.set_attrs = loopback_set_attrs,
.get_attrs = loopback_get_attrs,
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
.import = loopback_libconfig_import,
.export = loopback_libconfig_export,
#endif
diff --git a/src/function/midi.c b/src/function/midi.c
index 1ca4c2c..aab7ad8 100644
--- a/src/function/midi.c
+++ b/src/function/midi.c
@@ -15,7 +15,7 @@
#include "usbg/function/midi.h"
#include <malloc.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
@@ -81,7 +81,7 @@ static void midi_cleanup_attrs(struct usbg_function *f, void *f_attrs)
usbg_f_midi_cleanup_attrs(f_attrs);
}
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
static int midi_libconfig_import(struct usbg_function *f,
config_setting_t *root)
@@ -129,7 +129,7 @@ static int midi_libconfig_export(struct usbg_function *f,
return ret;
}
-#endif /* HAS_LIBCONFIG */
+#endif /* HAS_GADGET_SCHEMES */
struct usbg_function_type usbg_f_type_midi = {
.name = "midi",
@@ -139,7 +139,7 @@ struct usbg_function_type usbg_f_type_midi = {
.get_attrs = midi_get_attrs,
.cleanup_attrs = midi_cleanup_attrs,
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
.import = midi_libconfig_import,
.export = midi_libconfig_export,
#endif
diff --git a/src/function/ms.c b/src/function/ms.c
index 194ef73..519b012 100644
--- a/src/function/ms.c
+++ b/src/function/ms.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
@@ -189,7 +189,7 @@ static int ms_get_attrs(struct usbg_function *f, void *f_attrs)
(struct usbg_f_ms_attrs *)f_attrs);
}
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
static int ms_import_lun_attrs(struct usbg_f_ms *mf, int lun_id,
config_setting_t *root)
@@ -329,7 +329,7 @@ out:
return ret;
}
-#endif /* HAS_LIBCONFIG */
+#endif /* HAS_GADGET_SCHEMES */
static int ms_remove(struct usbg_function *f, int opts)
{
@@ -360,7 +360,7 @@ struct usbg_function_type usbg_f_type_ms = {
.get_attrs = ms_get_attrs,
.cleanup_attrs = ms_cleanup_attrs,
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
.import = ms_libconfig_import,
.export = ms_libconfig_export,
#endif
diff --git a/src/function/phonet.c b/src/function/phonet.c
index ad1ded7..17e9abb 100644
--- a/src/function/phonet.c
+++ b/src/function/phonet.c
@@ -15,7 +15,7 @@
#include "usbg/function/phonet.h"
#include <malloc.h>
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif
diff --git a/src/function/serial.c b/src/function/serial.c
index 1f02832..fa899e0 100644
--- a/src/function/serial.c
+++ b/src/function/serial.c
@@ -14,7 +14,7 @@
#include "usbg/usbg_internal.h"
#include "usbg/function/serial.h"
-#ifdef HAS_LIBCONFIG
+#ifdef HAS_GADGET_SCHEMES
#include <libconfig.h>
#endif