mirror of
https://github.com/linux-usb-gadgets/libusbgx.git
synced 2025-07-22 02:25:05 +03:00
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>
This commit is contained in:
parent
651177558b
commit
5d0962ed41
10 changed files with 32 additions and 24 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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, \
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "usbg/function/ffs.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#ifdef HAS_LIBCONFIG
|
||||
#ifdef HAS_GADGET_SCHEMES
|
||||
#include <libconfig.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "usbg/function/phonet.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#ifdef HAS_LIBCONFIG
|
||||
#ifdef HAS_GADGET_SCHEMES
|
||||
#include <libconfig.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue