diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-16 12:58:41 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2017-03-03 14:02:27 +0100 |
commit | 71f93716df8e3e93b5cdc307938a913e1a3058a5 (patch) | |
tree | ec9fabbfe8210b7a248fc97d0b5e3c5d03b049c8 | |
parent | 7b0ef8b934ac7f122a07491f1352608681c37d41 (diff) | |
download | libusbg-71f93716df8e3e93b5cdc307938a913e1a3058a5.tar.gz libusbg-71f93716df8e3e93b5cdc307938a913e1a3058a5.tar.bz2 libusbg-71f93716df8e3e93b5cdc307938a913e1a3058a5.zip |
libsubgx: common: Allow to export dev_t attribute using libconfig
Add a helper to export dev_t attributes to gadget schemes using
libconfig syntax.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | include/usbg/usbg_internal.h | 4 | ||||
-rw-r--r-- | src/usbg_common.c | 23 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/usbg/usbg_internal.h b/include/usbg/usbg_internal.h index 5eb20b6..2f59865 100644 --- a/include/usbg/usbg_internal.h +++ b/include/usbg/usbg_internal.h @@ -406,6 +406,10 @@ int usbg_set_config_node_string(config_setting_t *root, int usbg_set_config_node_ether_addr(config_setting_t *root, const char *node_name, void *val); +int usbg_set_config_node_dev(config_setting_t *root, + const char *node_name, void *val); + + #ifdef __cplusplus } #endif diff --git a/src/usbg_common.c b/src/usbg_common.c index 99bc99b..948cce8 100644 --- a/src/usbg_common.c +++ b/src/usbg_common.c @@ -491,6 +491,29 @@ int usbg_set_config_node_ether_addr(config_setting_t *root, return usbg_set_config_node_string(root, node_name, &ptr); } +int usbg_set_config_node_dev(config_setting_t *root, + const char *node_name, void *val) +{ + dev_t *dev = (dev_t *)val; + config_setting_t *node; + int tmp; + int ret = 0; + + node = config_setting_add(root, node_name, CONFIG_TYPE_GROUP); + if (!node) + return USBG_ERROR_NO_MEM; + + tmp = major(*dev); + ret = usbg_set_config_node_int(node, "major", &tmp); + if (ret) + return ret; + + tmp = minor(*dev); + ret = usbg_set_config_node_int(node, "minor", &tmp); + + return ret; +} + void usbg_cleanup_function(struct usbg_function *f) { free(f->path); |