Attempt to have a consistent coding convention in usb_core.c

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25617 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Amaury Pouly 2010-04-13 08:40:21 +00:00
parent 99a2299654
commit d372e3c8e6

View file

@ -137,9 +137,10 @@ static struct usb_string_descriptor __attribute__((aligned(2)))
{
84,
USB_DT_STRING,
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
'0','0','0','0','0','0','0','0','0'}
{'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0'}
};
/* Generic for all targets */
@ -267,9 +268,9 @@ static short hex[16] = {'0','1','2','3','4','5','6','7',
static void set_serial_descriptor(void)
{
#ifdef IPOD_VIDEO
uint32_t* serial = (uint32_t*)(0x20004034);
uint32_t* serial = (uint32_t*)0x20004034;
#else
uint32_t* serial = (uint32_t*)(0x20002034);
uint32_t* serial = (uint32_t*)0x20002034;
#endif
/* We need to convert from a little-endian 64-bit int
@ -352,10 +353,9 @@ void usb_core_init(void)
/* class driver init functions should be safe to call even if the driver
* won't be used. This simplifies other logic (i.e. we don't need to know
* yet which drivers will be enabled */
for(i=0;i<USB_NUM_DRIVERS;i++) {
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].init != NULL)
drivers[i].init();
}
initialized = true;
usb_state = DEFAULT;
@ -365,13 +365,12 @@ void usb_core_init(void)
void usb_core_exit(void)
{
int i;
for(i=0;i<USB_NUM_DRIVERS;i++) {
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].enabled && drivers[i].disconnect != NULL)
{
drivers[i].disconnect();
drivers[i].enabled = false;
}
}
if(initialized) {
usb_drv_exit();
@ -381,8 +380,7 @@ void usb_core_exit(void)
logf("usb_core_exit() finished");
}
void usb_core_handle_transfer_completion(
struct usb_transfer_completion_event_data* event)
void usb_core_handle_transfer_completion(struct usb_transfer_completion_event_data* event)
{
completion_handler_t handler;
int ep = event->endpoint;
@ -390,8 +388,7 @@ void usb_core_handle_transfer_completion(
switch(ep) {
case EP_CONTROL:
logf("ctrl handled %ld",current_tick);
usb_core_control_request_handler(
(struct usb_ctrlrequest*)event->data);
usb_core_control_request_handler((struct usb_ctrlrequest*)event->data);
break;
default:
handler = ep_data[ep].completion_handler[EP_DIR(event->dir)];
@ -414,12 +411,9 @@ bool usb_core_driver_enabled(int driver)
bool usb_core_any_exclusive_storage(void)
{
int i;
for(i=0;i<USB_NUM_DRIVERS;i++) {
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].enabled && drivers[i].needs_exclusive_storage)
{
return true;
}
}
return false;
}
@ -428,23 +422,20 @@ bool usb_core_any_exclusive_storage(void)
void usb_core_hotswap_event(int volume, bool inserted)
{
int i;
for(i=0;i<USB_NUM_DRIVERS;i++) {
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].enabled && drivers[i].notify_hotswap != NULL)
{
drivers[i].notify_hotswap(volume, inserted);
}
}
}
#endif
static void usb_core_set_serial_function_id(void)
{
int id = 0;
int i;
for(i=0;i<USB_NUM_DRIVERS;i++) {
int i, id = 0;
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].enabled)
id |= 1 << i;
}
usb_string_iSerial.wString[0] = hex[id];
}
@ -560,12 +551,11 @@ static void request_handler_device_get_descriptor(struct usb_ctrlrequest* req)
}
size = sizeof(struct usb_config_descriptor);
for(i=0;i<USB_NUM_DRIVERS;i++) {
if(drivers[i].enabled && drivers[i].get_config_descriptor) {
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].enabled && drivers[i].get_config_descriptor)
size += drivers[i].get_config_descriptor(
&response_data[size], max_packet_size);
}
}
config_descriptor.bNumInterfaces = usb_core_num_interfaces;
config_descriptor.wTotalLength = (uint16_t)size;
memcpy(&response_data[0], &config_descriptor,
@ -604,9 +594,8 @@ static void request_handler_device_get_descriptor(struct usb_ctrlrequest* req)
logf("data %d (%d)", size, length);
length = MIN(size, length);
if (ptr != response_data) {
if (ptr != response_data)
memcpy(response_data, ptr, length);
}
usb_drv_recv(EP_CONTROL, NULL, 0);
usb_drv_send(EP_CONTROL, response_data, length);
@ -630,14 +619,13 @@ static void request_handler_device(struct usb_ctrlrequest* req)
usb_drv_cancel_all_transfers();
if(req->wValue) {
usb_state = CONFIGURED;
for(i=0;i<USB_NUM_DRIVERS;i++) {
for(i = 0; i < USB_NUM_DRIVERS; i++)
if(drivers[i].enabled && drivers[i].init_connection)
drivers[i].init_connection();
}
}
else {
else
usb_state = ADDRESS;
}
usb_drv_send(EP_CONTROL, NULL, 0);
break;
}
@ -742,25 +730,24 @@ static void request_handler_endpoint_standard(struct usb_ctrlrequest* req)
{
switch (req->bRequest) {
case USB_REQ_CLEAR_FEATURE:
if (req->wValue==USB_ENDPOINT_HALT) {
if(req->wValue == USB_ENDPOINT_HALT)
usb_drv_stall(EP_NUM(req->wIndex), false, EP_DIR(req->wIndex));
}
usb_drv_send(EP_CONTROL, NULL, 0);
break;
case USB_REQ_SET_FEATURE:
if (req->wValue==USB_ENDPOINT_HALT) {
if(req->wValue == USB_ENDPOINT_HALT)
usb_drv_stall(EP_NUM(req->wIndex), true, EP_DIR(req->wIndex));
}
usb_drv_send(EP_CONTROL, NULL, 0);
break;
case USB_REQ_GET_STATUS:
response_data[0] = 0;
response_data[1] = 0;
logf("usb_core: GET_STATUS");
if(req->wIndex>0) {
response_data[0]=usb_drv_stalled(EP_NUM(req->wIndex),
EP_DIR(req->wIndex));
}
if(req->wIndex > 0)
response_data[0] = usb_drv_stalled(EP_NUM(req->wIndex), EP_DIR(req->wIndex));
usb_drv_recv(EP_CONTROL, NULL, 0);
usb_drv_send(EP_CONTROL, response_data, 2);
break;