diff options
-rw-r--r-- | include/usbg/usbg.h | 6 | ||||
-rw-r--r-- | src/usbg.c | 15 | ||||
-rw-r--r-- | tests/test.c | 16 | ||||
-rw-r--r-- | tests/usbg-test.c | 4 | ||||
-rw-r--r-- | tests/usbg-test.h | 4 |
5 files changed, 22 insertions, 23 deletions
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index d2bffba..41a6454 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -136,8 +136,8 @@ struct usbg_gadget_attrs typedef enum { USBG_GADGET_STR_MIN = 0, - USBG_STR_PRODUCT = USBG_GADGET_STR_MIN, - USBG_STR_MANUFACTURER, + USBG_STR_MANUFACTURER = USBG_GADGET_STR_MIN, + USBG_STR_PRODUCT, USBG_STR_SERIAL_NUMBER, USBG_GADGET_STR_MAX, } usbg_gadget_str; @@ -147,9 +147,9 @@ typedef enum { */ struct usbg_gadget_strs { - char serial[USBG_MAX_STR_LENGTH]; char manufacturer[USBG_MAX_STR_LENGTH]; char product[USBG_MAX_STR_LENGTH]; + char serial[USBG_MAX_STR_LENGTH]; }; /** @@ -89,8 +89,8 @@ ARRAY_SIZE_SENTINEL(gadget_attr_names, USBG_GADGET_ATTR_MAX); const char *gadget_str_names[] = { - "product", "manufacturer", + "product", "serialnumber", }; @@ -773,15 +773,15 @@ static int usbg_parse_gadget_strs(const char *path, const char *name, int lang, } closedir(dir); - ret = usbg_read_string(spath, "", "serialnumber", g_strs->serial); + ret = usbg_read_string(spath, "", "manufacturer", g_strs->manufacturer); if (ret != USBG_SUCCESS) goto out; - ret = usbg_read_string(spath, "", "manufacturer", g_strs->manufacturer); + ret = usbg_read_string(spath, "", "product", g_strs->product); if (ret != USBG_SUCCESS) goto out; - ret = usbg_read_string(spath, "", "product", g_strs->product); + ret = usbg_read_string(spath, "", "serialnumber", g_strs->serial); if (ret != USBG_SUCCESS) goto out; @@ -1691,16 +1691,15 @@ int usbg_set_gadget_strs(usbg_gadget *g, int lang, if (ret != USBG_SUCCESS) goto out; - ret = usbg_write_string(path, "", "serialnumber", g_strs->serial); - if (ret != USBG_SUCCESS) - goto out; - ret = usbg_write_string(path, "", "manufacturer", g_strs->manufacturer); if (ret != USBG_SUCCESS) goto out; ret = usbg_write_string(path, "", "product", g_strs->product); + if (ret != USBG_SUCCESS) + goto out; + ret = usbg_write_string(path, "", "serialnumber", g_strs->serial); out: return ret; } diff --git a/tests/test.c b/tests/test.c index 80b6fec..a830544 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1439,10 +1439,6 @@ static void test_set_gadget_strs(void **data) pull_gadget_string(tg, LANG_US_ENG, i, get_gadget_str(ts->strs, i)); - ret = usbg_set_gadget_serial_number(g, LANG_US_ENG, - ts->strs->serial); - assert_int_equal(ret, 0); - ret = usbg_set_gadget_manufacturer(g, LANG_US_ENG, ts->strs->manufacturer); assert_int_equal(ret, 0); @@ -1451,15 +1447,15 @@ static void test_set_gadget_strs(void **data) ts->strs->product); assert_int_equal(ret, 0); + ret = usbg_set_gadget_serial_number(g, LANG_US_ENG, + ts->strs->serial); + assert_int_equal(ret, 0); + for (i = 0; i < GADGET_STR_MAX; i++) pull_gadget_string(tg, LANG_US_ENG, i, get_gadget_str(ts->strs, i)); - ret = usbg_set_gadget_str(g, USBG_STR_SERIAL_NUMBER, - LANG_US_ENG, ts->strs->serial); - assert_int_equal(ret, 0); - ret = usbg_set_gadget_str(g, USBG_STR_MANUFACTURER, LANG_US_ENG, ts->strs->manufacturer); assert_int_equal(ret, 0); @@ -1467,6 +1463,10 @@ static void test_set_gadget_strs(void **data) ret = usbg_set_gadget_str(g, USBG_STR_PRODUCT, LANG_US_ENG, ts->strs->product); assert_int_equal(ret, 0); + + ret = usbg_set_gadget_str(g, USBG_STR_SERIAL_NUMBER, + LANG_US_ENG, ts->strs->serial); + assert_int_equal(ret, 0); } } diff --git a/tests/usbg-test.c b/tests/usbg-test.c index 09703cc..ad76481 100644 --- a/tests/usbg-test.c +++ b/tests/usbg-test.c @@ -18,9 +18,9 @@ static struct simple_stack{ } *cleanup_top = NULL; static const char *gadget_str_names[] = { - "serialnumber", "manufacturer", - "product" + "product", + "serialnumber", }; static const char *config_attr_names[] = { diff --git a/tests/usbg-test.h b/tests/usbg-test.h index d0cc9b7..e2b35aa 100644 --- a/tests/usbg-test.h +++ b/tests/usbg-test.h @@ -71,9 +71,9 @@ struct test_state }; typedef enum { - STR_SER = 0, - STR_MNF, + STR_MNF = 0, STR_PRD, + STR_SER, GADGET_STR_MAX } gadget_str; |