summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/usbstack/core/config.c9
-rw-r--r--firmware/usbstack/core/core.c31
-rw-r--r--firmware/usbstack/core/epsetup.c6
-rw-r--r--firmware/usbstack/drivers/device/usb_serial.c21
-rw-r--r--firmware/usbstack/drivers/device/usb_storage.c27
5 files changed, 60 insertions, 34 deletions
diff --git a/firmware/usbstack/core/config.c b/firmware/usbstack/core/config.c
index c49d54702c..1a9b12508e 100644
--- a/firmware/usbstack/core/config.c
+++ b/firmware/usbstack/core/config.c
@@ -23,7 +23,8 @@
#include <string.h>
#include "usbstack/core.h"
-static int usb_descriptor_fillbuf(void* buf, unsigned buflen, struct usb_descriptor_header** src)
+static int usb_descriptor_fillbuf(void* buf, unsigned buflen,
+ struct usb_descriptor_header** src)
{
uint8_t* dest = buf;
@@ -45,7 +46,8 @@ static int usb_descriptor_fillbuf(void* buf, unsigned buflen, struct usb_descrip
return dest - (uint8_t *)buf;
}
-int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf, unsigned length, struct usb_descriptor_header** desc)
+int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf,
+ unsigned length, struct usb_descriptor_header** desc)
{
struct usb_config_descriptor* cp = buf;
int len;
@@ -58,7 +60,8 @@ int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf,
*cp = *config;
/* then interface/endpoint/class/vendor/... */
- len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (uint8_t*)buf, length - USB_DT_CONFIG_SIZE, desc);
+ len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (uint8_t*)buf,
+ length - USB_DT_CONFIG_SIZE, desc);
if (len < 0) {
return len;
diff --git a/firmware/usbstack/core/core.c b/firmware/usbstack/core/core.c
index 2fbec5d571..0d2cfc67b9 100644
--- a/firmware/usbstack/core/core.c
+++ b/firmware/usbstack/core/core.c
@@ -99,7 +99,8 @@ void usb_stack_start(void)
* and if it has a device driver bind to it */
logf("check for auto bind");
if (usbcore.active_controller->type == DEVICE) {
- if (usbcore.active_controller->device_driver == NULL && usbcore.device_driver != NULL) {
+ if (usbcore.active_controller->device_driver == NULL &&
+ usbcore.device_driver != NULL) {
/* bind driver */
logf("binding...");
bind_device_driver(usbcore.device_driver);
@@ -130,7 +131,8 @@ void usb_stack_stop(void)
void usb_stack_irq(void)
{
/* simply notify usb controller */
- if (usbcore.active_controller != NULL && usbcore.active_controller->irq != NULL) {
+ if (usbcore.active_controller != NULL &&
+ usbcore.active_controller->irq != NULL) {
usbcore.active_controller->irq();
}
}
@@ -190,7 +192,8 @@ int usb_controller_register(struct usb_controller* ctrl)
* @param ctrl pointer to controller to unregister.
* @return 0 on success else a defined error code.
*/
-int usb_controller_unregister(struct usb_controller* ctrl) {
+int usb_controller_unregister(struct usb_controller* ctrl)
+{
if (ctrl == NULL) {
return EINVAL;
@@ -226,7 +229,8 @@ void usb_controller_select(int type)
struct usb_controller* new = NULL;
/* check if a controller of the wanted type is already loaded */
- if (usbcore.active_controller != NULL && (int)usbcore.active_controller->type == type) {
+ if (usbcore.active_controller != NULL &&
+ (int)usbcore.active_controller->type == type) {
logf("controller already set");
return;
}
@@ -263,7 +267,8 @@ void usb_controller_select(int type)
usbcore.active_controller->init();
}
-int usb_stack_get_mode(void) {
+int usb_stack_get_mode(void)
+{
return usbcore.mode;
}
@@ -296,8 +301,8 @@ int usb_device_driver_register(struct usb_device_driver* driver)
return 0;
}
-int usb_device_driver_bind(const char* name) {
-
+int usb_device_driver_bind(const char* name)
+{
int i;
struct usb_device_driver *tmp = NULL;
struct usb_device_driver *driver = NULL;
@@ -340,8 +345,8 @@ int usb_device_driver_bind(const char* name) {
return 0;
}
-void usb_device_driver_unbind(void) {
-
+void usb_device_driver_unbind(void)
+{
logf("usb_device_driver_unbind");
if (usbcore.active_controller->device_driver != NULL) {
usbcore.active_controller->device_driver->unbind();
@@ -351,8 +356,8 @@ void usb_device_driver_unbind(void) {
usbcore.device_driver = NULL;
}
-static void update_driver_names(unsigned char* result) {
-
+static void update_driver_names(unsigned char* result)
+{
int i;
int pos = 0;
unsigned char terminator = ',';
@@ -376,8 +381,8 @@ static void update_driver_names(unsigned char* result) {
}
}
-static void bind_device_driver(struct usb_device_driver* driver) {
-
+static void bind_device_driver(struct usb_device_driver* driver)
+{
int ret = 0;
/* look if there is an old driver */
diff --git a/firmware/usbstack/core/epsetup.c b/firmware/usbstack/core/epsetup.c
index 969678e18f..ef98935fe3 100644
--- a/firmware/usbstack/core/epsetup.c
+++ b/firmware/usbstack/core/epsetup.c
@@ -151,13 +151,15 @@ static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc)
switch (type) {
case USB_ENDPOINT_XFER_INT:
/* INT: limit 64 bytes full speed, 1024 high speed */
- if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 64)) {
+ if ((usbcore.active_controller->speed != USB_SPEED_HIGH) &&
+ (max > 64)) {
return 0;
}
/* FALLTHROUGH */
case USB_ENDPOINT_XFER_ISOC:
- if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 1023)) {
+ if ((usbcore.active_controller->speed != USB_SPEED_HIGH) &&
+ (max > 1023)) {
return 0;
}
break;
diff --git a/firmware/usbstack/drivers/device/usb_serial.c b/firmware/usbstack/drivers/device/usb_serial.c
index 0c66cf68fe..c8850042cd 100644
--- a/firmware/usbstack/drivers/device/usb_serial.c
+++ b/firmware/usbstack/drivers/device/usb_serial.c
@@ -209,7 +209,8 @@ int usb_serial_driver_bind(void* controler_ops)
serial_debug_desc.bDebugInEndpoint = dev.in->ep_num;
serial_debug_desc.bDebugOutEndpoint = dev.out->ep_num;
- /* update hs descriptors as we asume that endpoints are the same for fs and hs */
+ /* update hs descriptors as we asume that endpoints
+ are the same for fs and hs */
serial_hs_in_desc.bEndpointAddress = serial_fs_in_desc.bEndpointAddress;
serial_hs_out_desc.bEndpointAddress = serial_fs_out_desc.bEndpointAddress;
@@ -242,13 +243,15 @@ int usb_serial_driver_request(struct usb_ctrlrequest* request)
switch (request->wValue >> 8) {
case USB_DT_DEVICE:
logf("usb serial: sending device desc");
- ret = MIN(sizeof(struct usb_device_descriptor), request->wLength);
+ ret = MIN(sizeof(struct usb_device_descriptor),
+ request->wLength);
res.buf = &serial_device_desc;
break;
case USB_DT_DEVICE_QUALIFIER:
logf("usb serial: sending qualifier dec");
- ret = MIN(sizeof(struct usb_qualifier_descriptor), request->wLength);
+ ret = MIN(sizeof(struct usb_qualifier_descriptor),
+ request->wLength);
res.buf = &serial_qualifier_desc;
break;
@@ -256,7 +259,8 @@ int usb_serial_driver_request(struct usb_ctrlrequest* request)
case USB_DT_CONFIG:
logf("usb serial: sending config desc");
- ret = config_buf(buf, request->wValue >> 8, request->wValue & 0xff);
+ ret = config_buf(buf, request->wValue >> 8,
+ request->wValue & 0xff);
if (ret >= 0) {
logf("%d, vs %d", request->wLength, ret);
ret = MIN(request->wLength, (uint16_t)ret);
@@ -266,13 +270,15 @@ int usb_serial_driver_request(struct usb_ctrlrequest* request)
case USB_DT_DEBUG:
logf("usb serial: sending debug desc");
- ret = MIN(sizeof(struct usb_debug_descriptor), request->wLength);
+ ret = MIN(sizeof(struct usb_debug_descriptor),
+ request->wLength);
res.buf = &serial_debug_desc;
break;
case USB_DT_STRING:
logf("usb serial: sending string desc");
- ret = usb_stack_get_string(strings, request->wValue & 0xff, buf);
+ ret = usb_stack_get_string(strings, request->wValue & 0xff,
+ buf);
ret = MIN(ret, request->wLength);
res.buf = buf;
break;
@@ -324,7 +330,8 @@ static int config_buf(uint8_t *buf, uint8_t type, unsigned index)
/* TODO check index*/
(void)index;
- len = usb_stack_configdesc(&serial_bulk_config_desc, buf, BUFFER_SIZE, dev.descriptors);
+ len = usb_stack_configdesc(&serial_bulk_config_desc, buf, BUFFER_SIZE,
+ dev.descriptors);
if (len < 0) {
return len;
}
diff --git a/firmware/usbstack/drivers/device/usb_storage.c b/firmware/usbstack/drivers/device/usb_storage.c
index 45fd5c14b7..8fc9df672f 100644
--- a/firmware/usbstack/drivers/device/usb_storage.c
+++ b/firmware/usbstack/drivers/device/usb_storage.c
@@ -207,9 +207,12 @@ int usb_storage_driver_bind(void* controler_ops)
/* update device decsriptor */
storage_device_desc.bMaxPacketSize0 = ops->ep0->maxpacket;
- /* update hs descriptors as we asume that endpoints are the same for fs and hs */
- storage_hs_bulk_in_desc.bEndpointAddress = storage_fs_bulk_in_desc.bEndpointAddress;
- storage_hs_bulk_out_desc.bEndpointAddress = storage_fs_bulk_out_desc.bEndpointAddress;
+ /* update hs descriptors as we asume that endpoints
+ are the same for fs and hs */
+ storage_hs_bulk_in_desc.bEndpointAddress =
+ storage_fs_bulk_in_desc.bEndpointAddress;
+ storage_hs_bulk_out_desc.bEndpointAddress =
+ storage_fs_bulk_out_desc.bEndpointAddress;
return 0;
@@ -218,7 +221,8 @@ autoconf_fail:
return -EOPNOTSUPP;
}
-void usb_storage_driver_unbind(void) {
+void usb_storage_driver_unbind(void)
+{
/* disable endpoints... */
}
@@ -240,13 +244,15 @@ int usb_storage_driver_request(struct usb_ctrlrequest* request)
switch (request->wValue >> 8) {
case USB_DT_DEVICE:
logf("usb storage: sending device desc");
- ret = MIN(sizeof(struct usb_device_descriptor), request->wLength);
+ ret = MIN(sizeof(struct usb_device_descriptor),
+ request->wLength);
res.buf = &storage_device_desc;
break;
case USB_DT_DEVICE_QUALIFIER:
logf("usb storage: sending qualifier dec");
- ret = MIN(sizeof(struct usb_qualifier_descriptor), request->wLength);
+ ret = MIN(sizeof(struct usb_qualifier_descriptor),
+ request->wLength);
res.buf = &storage_qualifier_desc;
break;
@@ -254,7 +260,8 @@ int usb_storage_driver_request(struct usb_ctrlrequest* request)
case USB_DT_CONFIG:
logf("usb storage: sending config desc");
- ret = config_buf(buf, request->wValue >> 8, request->wValue & 0xff);
+ ret = config_buf(buf, request->wValue >> 8,
+ request->wValue & 0xff);
if (ret >= 0) {
logf("%d, vs %d", request->wLength, ret);
ret = MIN(request->wLength, (uint16_t)ret);
@@ -264,7 +271,8 @@ int usb_storage_driver_request(struct usb_ctrlrequest* request)
case USB_DT_STRING:
logf("usb storage: sending string desc");
- ret = usb_stack_get_string(strings, request->wValue & 0xff, buf);
+ ret = usb_stack_get_string(strings, request->wValue & 0xff,
+ buf);
ret = MIN(ret, request->wLength);
res.buf = buf;
break;
@@ -336,7 +344,8 @@ static int config_buf(uint8_t *buf, uint8_t type, unsigned index)
(void)index;
- len = usb_stack_configdesc(&storage_config_desc, buf, BUFFER_SIZE, dev.descriptors);
+ len = usb_stack_configdesc(&storage_config_desc, buf, BUFFER_SIZE,
+ dev.descriptors);
logf("result %d", len);
if (len < 0) {
return len;