diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-13 22:40:05 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2016-12-13 22:45:06 +0100 |
commit | a23dee0c86fb7e35f721e3bc17096d3138015ff4 (patch) | |
tree | eccba011b2e272acd3ef488752edccfbc868599e | |
parent | d9c5a1bc4994e29144fd2a5b1fbde75b1671bfa0 (diff) | |
download | libusbg-a23dee0c86fb7e35f721e3bc17096d3138015ff4.tar.gz libusbg-a23dee0c86fb7e35f721e3bc17096d3138015ff4.tar.bz2 libusbg-a23dee0c86fb7e35f721e3bc17096d3138015ff4.zip |
libusbgx: Use suitable prefix for usbg_function_type enum
Let's use USBG_ prefix for usbg_function_type enum values
to avoid users confusion.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | examples/gadget-acm-ecm.c | 6 | ||||
-rw-r--r-- | examples/gadget-ffs.c | 4 | ||||
-rw-r--r-- | examples/gadget-midi.c | 2 | ||||
-rw-r--r-- | examples/gadget-ms.c | 2 | ||||
-rw-r--r-- | examples/show-gadgets.c | 24 | ||||
-rw-r--r-- | include/usbg/usbg.h | 26 | ||||
-rw-r--r-- | src/usbg.c | 26 | ||||
-rw-r--r-- | tests/test.c | 92 | ||||
-rw-r--r-- | tests/usbg-test.c | 50 |
9 files changed, 116 insertions, 116 deletions
diff --git a/examples/gadget-acm-ecm.c b/examples/gadget-acm-ecm.c index fe0b1ef..b73135f 100644 --- a/examples/gadget-acm-ecm.c +++ b/examples/gadget-acm-ecm.c @@ -78,7 +78,7 @@ int main(void) goto out2; } - usbg_ret = usbg_create_function(g, F_ACM, "usb0", NULL, &f_acm0); + usbg_ret = usbg_create_function(g, USBG_F_ACM, "usb0", NULL, &f_acm0); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating acm0 function\n"); fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret), @@ -86,7 +86,7 @@ int main(void) goto out2; } - usbg_ret = usbg_create_function(g, F_ACM, "usb1", NULL, &f_acm1); + usbg_ret = usbg_create_function(g, USBG_F_ACM, "usb1", NULL, &f_acm1); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating acm1 function\n"); fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret), @@ -94,7 +94,7 @@ int main(void) goto out2; } - usbg_ret = usbg_create_function(g, F_ECM, "usb0", NULL, &f_ecm); + usbg_ret = usbg_create_function(g, USBG_F_ECM, "usb0", NULL, &f_ecm); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating ecm function\n"); fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret), diff --git a/examples/gadget-ffs.c b/examples/gadget-ffs.c index b95f13b..6ba10c6 100644 --- a/examples/gadget-ffs.c +++ b/examples/gadget-ffs.c @@ -79,7 +79,7 @@ int main(void) goto out2; } - usbg_ret = usbg_create_function(g, F_FFS, "my_dev_name", NULL, &f_ffs1); + usbg_ret = usbg_create_function(g, USBG_F_FFS, "my_dev_name", NULL, &f_ffs1); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating ffs1 function\n"); fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret), @@ -87,7 +87,7 @@ int main(void) goto out2; } - usbg_ret = usbg_create_function(g, F_FFS, "my_other_dev_name", + usbg_ret = usbg_create_function(g, USBG_F_FFS, "my_other_dev_name", NULL, &f_ffs2); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating ffs2 function\n"); diff --git a/examples/gadget-midi.c b/examples/gadget-midi.c index 61556cc..2d56c0d 100644 --- a/examples/gadget-midi.c +++ b/examples/gadget-midi.c @@ -76,7 +76,7 @@ int main() { usbg_strerror(usbg_ret)); goto out2; } - usbg_ret = usbg_create_function(g, F_MIDI, "usb0", &f_attrs, &f_midi); + usbg_ret = usbg_create_function(g, USBG_F_MIDI, "usb0", &f_attrs, &f_midi); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating function\n"); fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret), diff --git a/examples/gadget-ms.c b/examples/gadget-ms.c index 017a6d1..36b0847 100644 --- a/examples/gadget-ms.c +++ b/examples/gadget-ms.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) goto out2; } - usbg_ret = usbg_create_function(g, F_MASS_STORAGE, "my_reader", + usbg_ret = usbg_create_function(g, USBG_F_MASS_STORAGE, "my_reader", &f_attrs, &f_ms); if (usbg_ret != USBG_SUCCESS) { fprintf(stderr, "Error creating mass storage function\n"); diff --git a/examples/show-gadgets.c b/examples/show-gadgets.c index 403693e..dcac7d5 100644 --- a/examples/show-gadgets.c +++ b/examples/show-gadgets.c @@ -128,18 +128,18 @@ void show_function(usbg_function *f) usbg_get_function_type_str(type), instance); switch (type) { - case F_ACM: - case F_OBEX: - case F_SERIAL: + case USBG_F_ACM: + case USBG_F_OBEX: + case USBG_F_SERIAL: fprintf(stdout, " port_num\t\t%d\n", f_attrs.serial_port_num); break; - case F_ECM: - case F_SUBSET: - case F_NCM: - case F_EEM: - case F_RNDIS: + case USBG_F_ECM: + case USBG_F_SUBSET: + case USBG_F_NCM: + case USBG_F_EEM: + case USBG_F_RNDIS: { struct usbg_f_net_attrs *f_net_attrs = &f_attrs.net; @@ -152,15 +152,15 @@ void show_function(usbg_function *f) break; } - case F_PHONET: + case USBG_F_PHONET: fprintf(stdout, " ifname\t\t%s\n", f_attrs.phonet_ifname); break; - case F_FFS: + case USBG_F_FFS: fprintf(stdout, " dev_name\t\t%s\n", f_attrs.ffs_dev_name); break; - case F_MASS_STORAGE: + case USBG_F_MASS_STORAGE: { struct usbg_f_ms_attrs *attrs = &f_attrs.ms; int i; @@ -178,7 +178,7 @@ void show_function(usbg_function *f) break; } - case F_MIDI: + case USBG_F_MIDI: { struct usbg_f_midi_attrs *attrs = &f_attrs.midi; diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 359192a..8a3578d 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -180,19 +180,19 @@ typedef struct typedef enum { USBG_FUNCTION_TYPE_MIN = 0, - F_SERIAL = USBG_FUNCTION_TYPE_MIN, - F_ACM, - F_OBEX, - F_ECM, - F_SUBSET, - F_NCM, - F_EEM, - F_RNDIS, - F_PHONET, - F_FFS, - F_MASS_STORAGE, - F_MIDI, - F_LOOPBACK, + USBG_F_SERIAL = USBG_FUNCTION_TYPE_MIN, + USBG_F_ACM, + USBG_F_OBEX, + USBG_F_ECM, + USBG_F_SUBSET, + USBG_F_NCM, + USBG_F_EEM, + USBG_F_RNDIS, + USBG_F_PHONET, + USBG_F_FFS, + USBG_F_MASS_STORAGE, + USBG_F_MIDI, + USBG_F_LOOPBACK, USBG_FUNCTION_TYPE_MAX, } usbg_function_type; @@ -56,19 +56,19 @@ extern struct usbg_function_type usbg_f_type_loopback; * @brief Types of functions supported by library */ struct usbg_function_type* function_types[] = { - [F_ACM] = &usbg_f_type_acm, - [F_SERIAL] = &usbg_f_type_serial, - [F_OBEX] = &usbg_f_type_obex, - [F_ECM] = &usbg_f_type_ecm, - [F_SUBSET] = &usbg_f_type_subset, - [F_NCM] = &usbg_f_type_ncm, - [F_EEM] = &usbg_f_type_eem, - [F_RNDIS] = &usbg_f_type_rndis, - [F_FFS] = &usbg_f_type_ffs, - [F_MIDI] = &usbg_f_type_midi, - [F_MASS_STORAGE] = &usbg_f_type_ms, - [F_PHONET] = &usbg_f_type_phonet, - [F_LOOPBACK] = &usbg_f_type_loopback, + [USBG_F_ACM] = &usbg_f_type_acm, + [USBG_F_SERIAL] = &usbg_f_type_serial, + [USBG_F_OBEX] = &usbg_f_type_obex, + [USBG_F_ECM] = &usbg_f_type_ecm, + [USBG_F_SUBSET] = &usbg_f_type_subset, + [USBG_F_NCM] = &usbg_f_type_ncm, + [USBG_F_EEM] = &usbg_f_type_eem, + [USBG_F_RNDIS] = &usbg_f_type_rndis, + [USBG_F_FFS] = &usbg_f_type_ffs, + [USBG_F_MIDI] = &usbg_f_type_midi, + [USBG_F_MASS_STORAGE] = &usbg_f_type_ms, + [USBG_F_PHONET] = &usbg_f_type_phonet, + [USBG_F_LOOPBACK] = &usbg_f_type_loopback, }; ARRAY_SIZE_SENTINEL(function_types, USBG_FUNCTION_TYPE_MAX); diff --git a/tests/test.c b/tests/test.c index a4d7fc7..865aa0a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -107,8 +107,8 @@ static char *long_udcs[] = { * @details Used to go through init when testing other things */ static struct test_function simple_funcs[] = { - FUNC_FROM_TYPE(F_ECM), - FUNC_FROM_TYPE(F_ACM), + FUNC_FROM_TYPE(USBG_F_ECM), + FUNC_FROM_TYPE(USBG_F_ACM), TEST_FUNCTION_LIST_END }; @@ -118,23 +118,23 @@ static struct test_function simple_funcs[] = { * processed correctly */ static struct test_function all_funcs[] = { - FUNC_FROM_TYPE(F_SERIAL), - FUNC_FROM_TYPE(F_ACM), - FUNC_FROM_TYPE(F_OBEX), - FUNC_FROM_TYPE(F_ECM), - FUNC_FROM_TYPE(F_SUBSET), - FUNC_FROM_TYPE(F_NCM), - FUNC_FROM_TYPE(F_EEM), - FUNC_FROM_TYPE(F_RNDIS), - FUNC_FROM_TYPE(F_PHONET), - FUNC_FROM_TYPE(F_FFS), + FUNC_FROM_TYPE(USBG_F_SERIAL), + FUNC_FROM_TYPE(USBG_F_ACM), + FUNC_FROM_TYPE(USBG_F_OBEX), + FUNC_FROM_TYPE(USBG_F_ECM), + FUNC_FROM_TYPE(USBG_F_SUBSET), + FUNC_FROM_TYPE(USBG_F_NCM), + FUNC_FROM_TYPE(USBG_F_EEM), + FUNC_FROM_TYPE(USBG_F_RNDIS), + FUNC_FROM_TYPE(USBG_F_PHONET), + FUNC_FROM_TYPE(USBG_F_FFS), TEST_FUNCTION_LIST_END }; static struct test_function same_type_funcs[] = { - FUNC_FROM_TYPE(F_SERIAL), - FUNC_FROM_TYPE(F_SERIAL), - FUNC_FROM_TYPE(F_SERIAL), + FUNC_FROM_TYPE(USBG_F_SERIAL), + FUNC_FROM_TYPE(USBG_F_SERIAL), + FUNC_FROM_TYPE(USBG_F_SERIAL), TEST_FUNCTION_LIST_END }; @@ -460,121 +460,121 @@ static void *setup_f_attrs(int f_type, void *attrs) static int setup_f_serial_attrs(void **state) { - *state = setup_f_attrs(F_SERIAL, &simple_serial_attrs); + *state = setup_f_attrs(USBG_F_SERIAL, &simple_serial_attrs); return 0; } static int setup_f_serial_writable_attrs(void **state) { - *state = setup_f_attrs(F_SERIAL, &writable_serial_attrs); + *state = setup_f_attrs(USBG_F_SERIAL, &writable_serial_attrs); return 0; } static int setup_f_acm_attrs(void **state) { - *state = setup_f_attrs(F_ACM, &simple_serial_attrs); + *state = setup_f_attrs(USBG_F_ACM, &simple_serial_attrs); return 0; } static int setup_f_acm_writable_attrs(void **state) { - *state = setup_f_attrs(F_ACM, &writable_serial_attrs); + *state = setup_f_attrs(USBG_F_ACM, &writable_serial_attrs); return 0; } static int setup_f_obex_attrs(void **state) { - *state = setup_f_attrs(F_OBEX, &simple_serial_attrs); + *state = setup_f_attrs(USBG_F_OBEX, &simple_serial_attrs); return 0; } static int setup_f_obex_writable_attrs(void **state) { - *state = setup_f_attrs(F_OBEX, &writable_serial_attrs); + *state = setup_f_attrs(USBG_F_OBEX, &writable_serial_attrs); return 0; } static int setup_f_ecm_attrs(void **state) { - *state = setup_f_attrs(F_ECM, &simple_net_attrs); + *state = setup_f_attrs(USBG_F_ECM, &simple_net_attrs); return 0; } static int setup_f_ecm_writable_attrs(void **state) { - *state = setup_f_attrs(F_ECM, &writable_net_attrs); + *state = setup_f_attrs(USBG_F_ECM, &writable_net_attrs); return 0; } static int setup_f_subset_attrs(void **state) { - *state = setup_f_attrs(F_SUBSET, &simple_net_attrs); + *state = setup_f_attrs(USBG_F_SUBSET, &simple_net_attrs); return 0; } static int setup_f_subset_writable_attrs(void **state) { - *state = setup_f_attrs(F_SUBSET, &writable_net_attrs); + *state = setup_f_attrs(USBG_F_SUBSET, &writable_net_attrs); return 0; } static int setup_f_ncm_attrs(void **state) { - *state = setup_f_attrs(F_NCM, &simple_net_attrs); + *state = setup_f_attrs(USBG_F_NCM, &simple_net_attrs); return 0; } static int setup_f_ncm_writable_attrs(void **state) { - *state = setup_f_attrs(F_NCM, &writable_net_attrs); + *state = setup_f_attrs(USBG_F_NCM, &writable_net_attrs); return 0; } static int setup_f_eem_attrs(void **state) { - *state = setup_f_attrs(F_EEM, &simple_net_attrs); + *state = setup_f_attrs(USBG_F_EEM, &simple_net_attrs); return 0; } static int setup_f_eem_writable_attrs(void **state) { - *state = setup_f_attrs(F_EEM, &writable_net_attrs); + *state = setup_f_attrs(USBG_F_EEM, &writable_net_attrs); return 0; } static int setup_f_rndis_attrs(void **state) { - *state = setup_f_attrs(F_RNDIS, &simple_net_attrs); + *state = setup_f_attrs(USBG_F_RNDIS, &simple_net_attrs); return 0; } static int setup_f_rndis_writable_attrs(void **state) { - *state = setup_f_attrs(F_RNDIS, &writable_net_attrs); + *state = setup_f_attrs(USBG_F_RNDIS, &writable_net_attrs); return 0; } static int setup_f_phonet_attrs(void **state) { - *state = setup_f_attrs(F_PHONET, &simple_phonet_attrs); + *state = setup_f_attrs(USBG_F_PHONET, &simple_phonet_attrs); return 0; } static int setup_f_phonet_writable_attrs(void **state) { - *state = setup_f_attrs(F_PHONET, &writable_phonet_attrs); + *state = setup_f_attrs(USBG_F_PHONET, &writable_phonet_attrs); return 0; } static int setup_f_ffs_attrs(void **state) { - *state = setup_f_attrs(F_FFS, &simple_ffs_attrs); + *state = setup_f_attrs(USBG_F_FFS, &simple_ffs_attrs); return 0; } static int setup_f_ffs_writable_attrs(void **state) { - *state = setup_f_attrs(F_FFS, &writable_ffs_attrs); + *state = setup_f_attrs(USBG_F_FFS, &writable_ffs_attrs); return 0; } @@ -792,7 +792,7 @@ static void test_get_function_fail(void **state) g = usbg_get_first_gadget(s); assert_non_null(g); - f = usbg_get_function(g, F_ACM, "non-existing-instance"); + f = usbg_get_function(g, USBG_F_ACM, "non-existing-instance"); assert_null(f); f = usbg_get_function(g, 9001, "0"); @@ -811,16 +811,16 @@ static void test_get_function_type_str(void **state) usbg_function_type type; const char *str; } types[] = { - {F_SERIAL, "gser"}, - {F_ACM, "acm"}, - {F_OBEX, "obex"}, - {F_ECM, "ecm"}, - {F_SUBSET, "geth"}, - {F_NCM, "ncm"}, - {F_EEM, "eem"}, - {F_RNDIS, "rndis"}, - {F_PHONET, "phonet"}, - {F_FFS, "ffs"}, + {USBG_F_SERIAL, "gser"}, + {USBG_F_ACM, "acm"}, + {USBG_F_OBEX, "obex"}, + {USBG_F_ECM, "ecm"}, + {USBG_F_SUBSET, "geth"}, + {USBG_F_NCM, "ncm"}, + {USBG_F_EEM, "eem"}, + {USBG_F_RNDIS, "rndis"}, + {USBG_F_PHONET, "phonet"}, + {USBG_F_FFS, "ffs"}, }; const char *str; diff --git a/tests/usbg-test.c b/tests/usbg-test.c index da6648b..078ed96 100644 --- a/tests/usbg-test.c +++ b/tests/usbg-test.c @@ -1064,22 +1064,22 @@ static void push_phonet_attrs(struct test_function *func, void push_function_attrs(struct test_function *func, void *function_attrs) { switch (func->type) { - case F_ACM: - case F_OBEX: - case F_SERIAL: + case USBG_F_ACM: + case USBG_F_OBEX: + case USBG_F_SERIAL: push_serial_attrs(func, function_attrs); break; - case F_ECM: - case F_SUBSET: - case F_NCM: - case F_EEM: - case F_RNDIS: + case USBG_F_ECM: + case USBG_F_SUBSET: + case USBG_F_NCM: + case USBG_F_EEM: + case USBG_F_RNDIS: push_net_attrs(func, function_attrs); break; - case F_PHONET: + case USBG_F_PHONET: push_phonet_attrs(func, function_attrs); break; - case F_FFS: + case USBG_F_FFS: // ffs does not exist in filesystem default: break; @@ -1114,11 +1114,11 @@ static void pull_function_net_attrs(struct test_function *func, void pull_function_attrs(struct test_function *func, void *attrs) { switch (func->type) { - case F_ECM: - case F_SUBSET: - case F_NCM: - case F_EEM: - case F_RNDIS: + case USBG_F_ECM: + case USBG_F_SUBSET: + case USBG_F_NCM: + case USBG_F_EEM: + case USBG_F_RNDIS: pull_function_net_attrs(func, attrs); break; default: @@ -1307,22 +1307,22 @@ void assert_function_attrs_equal(void *actual, void *expected, usbg_function_type type) { switch (type) { - case F_ACM: - case F_OBEX: - case F_SERIAL: + case USBG_F_ACM: + case USBG_F_OBEX: + case USBG_F_SERIAL: assert_f_serial_attrs_equal(actual, expected); break; - case F_ECM: - case F_SUBSET: - case F_NCM: - case F_EEM: - case F_RNDIS: + case USBG_F_ECM: + case USBG_F_SUBSET: + case USBG_F_NCM: + case USBG_F_EEM: + case USBG_F_RNDIS: assert_f_net_attrs_equal(actual, expected); break; - case F_PHONET: + case USBG_F_PHONET: assert_f_phonet_attrs_equal(actual, expected); break; - case F_FFS: + case USBG_F_FFS: assert_f_ffs_attrs_equal(actual, expected); break; default: |