summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2015-05-19 16:15:36 +0200
committerKrzysztof Opasiak <k.opasiak@samsung.com>2015-12-22 21:45:36 +0100
commit2f09cdc9b6315a9bc1884ecc1c4760f3c4485411 (patch)
treef238ac3f67455110837f1e51a7716a5744ab258e /examples
parent782cd0a928e2c898d5fc0b086967a6bfb1f2789b (diff)
downloadlibusbg-2f09cdc9b6315a9bc1884ecc1c4760f3c4485411.tar.gz
libusbg-2f09cdc9b6315a9bc1884ecc1c4760f3c4485411.tar.bz2
libusbg-2f09cdc9b6315a9bc1884ecc1c4760f3c4485411.zip
libusbgx: examples: Make examples easier to read
Use the same order of structure initialization in all examples. Initialize gadget attributes and strings using: .member = val, syntax to make examples easier to read. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/gadget-acm-ecm.c25
-rw-r--r--examples/gadget-ffs.c36
-rw-r--r--examples/gadget-midi.c25
-rw-r--r--examples/gadget-ms.c36
4 files changed, 64 insertions, 58 deletions
diff --git a/examples/gadget-acm-ecm.c b/examples/gadget-acm-ecm.c
index 4e8010f..14b8a7d 100644
--- a/examples/gadget-acm-ecm.c
+++ b/examples/gadget-acm-ecm.c
@@ -16,6 +16,7 @@
#include <errno.h>
#include <stdio.h>
+#include <linux/usb/ch9.h>
#include <usbg/usbg.h>
/**
@@ -37,24 +38,24 @@ int main(void)
int usbg_ret;
usbg_gadget_attrs g_attrs = {
- 0x0200, /* bcdUSB */
- 0x00, /* Defined at interface level */
- 0x00, /* subclass */
- 0x00, /* device protocol */
- 0x0040, /* Max allowed packet size */
- VENDOR,
- PRODUCT,
- 0x0001, /* Verson of device */
+ .bcdUSB = 0x0200,
+ .bDeviceClass = USB_CLASS_PER_INTERFACE,
+ .bDeviceSubClass = 0x00,
+ .bDeviceProtocol = 0x00,
+ .bMaxPacketSize0 = 0x0040, /* Max allowed ep0 packet size */
+ .idVendor = VENDOR,
+ .idProduct = PRODUCT,
+ .bcdDevice = 0x0001, /* Verson of device */
};
usbg_gadget_strs g_strs = {
- "0123456789", /* Serial number */
- "Foo Inc.", /* Manufacturer */
- "Bar Gadget" /* Product string */
+ .str_ser = "0123456789", /* Serial number */
+ .str_mnf = "Foo Inc.", /* Manufacturer */
+ .str_prd = "Bar Gadget" /* Product string */
};
usbg_config_strs c_strs = {
- "CDC 2xACM+ECM"
+ .configuration = "CDC 2xACM+ECM"
};
usbg_ret = usbg_init("/sys/kernel/config", &s);
diff --git a/examples/gadget-ffs.c b/examples/gadget-ffs.c
index 2e29366..1365844 100644
--- a/examples/gadget-ffs.c
+++ b/examples/gadget-ffs.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include <stdio.h>
+#include <linux/usb/ch9.h>
#include <usbg/usbg.h>
#define VENDOR 0x1d6b
@@ -40,31 +41,32 @@ int main(void)
usbg_function *f_ffs1, *f_ffs2;
int ret = -EINVAL;
int usbg_ret;
- usbg_function_attrs f_attrs = {
- .attrs.ffs = {
- .dev_name = "my_awesome_dev_name",
- },
- };
usbg_gadget_attrs g_attrs = {
- 0x0200, /* bcdUSB */
- 0x00, /* Defined at interface level */
- 0x00, /* subclass */
- 0x00, /* device protocol */
- 0x0040, /* Max allowed packet size */
- VENDOR,
- PRODUCT,
- 0x0001, /* Verson of device */
+ .bcdUSB = 0x0200,
+ .bDeviceClass = USB_CLASS_PER_INTERFACE,
+ .bDeviceSubClass = 0x00,
+ .bDeviceProtocol = 0x00,
+ .bMaxPacketSize0 = 0x0040, /* Max allowed ep0 packet size */
+ .idVendor = VENDOR,
+ .idProduct = PRODUCT,
+ .bcdDevice = 0x0001, /* Verson of device */
};
usbg_gadget_strs g_strs = {
- "0123456789", /* Serial number */
- "Foo Inc.", /* Manufacturer */
- "Bar Gadget" /* Product string */
+ .str_ser = "0123456789", /* Serial number */
+ .str_mnf = "Foo Inc.", /* Manufacturer */
+ .str_prd = "Bar Gadget" /* Product string */
};
usbg_config_strs c_strs = {
- "2xFFS"
+ .configuration = "2xFFS"
+ };
+
+ usbg_function_attrs f_attrs = {
+ .attrs.ffs = {
+ .dev_name = "my_awesome_dev_name",
+ },
};
usbg_ret = usbg_init("/sys/kernel/config", &s);
diff --git a/examples/gadget-midi.c b/examples/gadget-midi.c
index 44699f3..1004063 100644
--- a/examples/gadget-midi.c
+++ b/examples/gadget-midi.c
@@ -16,6 +16,7 @@
#include <errno.h>
#include <stdio.h>
+#include <linux/usb/ch9.h>
#include <usbg/usbg.h>
#define VENDOR 0x1d6b
@@ -30,24 +31,24 @@ int main() {
int usbg_ret;
usbg_gadget_attrs g_attrs = {
- 0x0200, /* bcdUSB */
- 0x00, /* Defined at interface level */
- 0x00, /* subclass */
- 0x00, /* device protocol */
- 0x0040, /* Max allowed packet size */
- VENDOR,
- PRODUCT,
- 0x0001, /* Verson of device */
+ .bcdUSB = 0x0200,
+ .bDeviceClass = USB_CLASS_PER_INTERFACE,
+ .bDeviceSubClass = 0x00,
+ .bDeviceProtocol = 0x00,
+ .bMaxPacketSize0 = 0x0040, /* Max allowed ep0 packet size */
+ .idVendor = VENDOR,
+ .idProduct = PRODUCT,
+ .bcdDevice = 0x0001, /* Verson of device */
};
usbg_gadget_strs g_strs = {
- "0123456789", /* Serial number */
- "Foo Inc.", /* Manufacturer */
- "Bar Gadget" /* Product string */
+ .str_ser = "0123456789", /* Serial number */
+ .str_mnf = "Foo Inc.", /* Manufacturer */
+ .str_prd = "Bar Gadget" /* Product string */
};
usbg_config_strs c_strs = {
- "1xMIDI"
+ .configuration = "1xMIDI"
};
usbg_function_attrs f_attrs = {
diff --git a/examples/gadget-ms.c b/examples/gadget-ms.c
index a37b163..69c3406 100644
--- a/examples/gadget-ms.c
+++ b/examples/gadget-ms.c
@@ -23,6 +23,7 @@
#include <errno.h>
#include <stdio.h>
+#include <linux/usb/ch9.h>
#include <usbg/usbg.h>
#define VENDOR 0x1d6b
@@ -36,6 +37,24 @@ int main(int argc, char **argv)
usbg_function *f_ms;
int ret = -EINVAL;
int usbg_ret;
+
+ usbg_gadget_attrs g_attrs = {
+ .bcdUSB = 0x0200,
+ .bDeviceClass = USB_CLASS_PER_INTERFACE,
+ .bDeviceSubClass = 0x00,
+ .bDeviceProtocol = 0x00,
+ .bMaxPacketSize0 = 0x0040, /* Max allowed ep0 packet size */
+ .idVendor = VENDOR,
+ .idProduct = PRODUCT,
+ .bcdDevice = 0x0001, /* Verson of device */
+ };
+
+ usbg_gadget_strs g_strs = {
+ .str_ser = "0123456789", /* Serial number */
+ .str_mnf = "Foo Inc.", /* Manufacturer */
+ .str_prd = "Bar Gadget" /* Product string */
+ };
+
usbg_f_ms_lun_attrs f_ms_luns_array[] = {
{
.id = -1, /* allows to place in any position */
@@ -73,23 +92,6 @@ int main(int argc, char **argv)
},
};
- usbg_gadget_attrs g_attrs = {
- 0x0200, /* bcdUSB */
- 0x00, /* Defined at interface level */
- 0x00, /* subclass */
- 0x00, /* device protocol */
- 0x0040, /* Max allowed packet size */
- VENDOR,
- PRODUCT,
- 0x0001, /* Verson of device */
- };
-
- usbg_gadget_strs g_strs = {
- "0123456789", /* Serial number */
- "Foo Inc.", /* Manufacturer */
- "Bar Gadget" /* Product string */
- };
-
usbg_config_strs c_strs = {
"1xMass Storage"
};