NONE sounds bad, use OK instead

This commit is contained in:
NIIBE Yutaka
2016-06-10 08:25:00 +09:00
parent 74c7b5bcb3
commit a6541cbcc6
6 changed files with 42 additions and 30 deletions

View File

@@ -1,3 +1,12 @@
2016-06-10 NIIBE Yutaka <gniibe@fsij.org>
* usb_lld.h (USB_EVENT_OK): Rename.
* mcu/usb-stm32f103.c: Update.
* mcu/usb-mkl27z.c: Likewise.
* example-cdc/usb-cdc.c: Follow the change of API.
* example-fs-bb48/usb-cdc.c: Likewise.
2016-06-09 NIIBE Yutaka <gniibe@fsij.org>
* mcu/usb-stm32f103.c (usb_lld_ctrl_recv): Rename.

View File

@@ -739,7 +739,7 @@ tty_main (void *arg)
/* The addres is assigned to the device. We don't
* need to do anything for this actually, but in this
* application, we maintain the USB status of the
* device. Usually, just "continue" as EVENT_NONE is
* device. Usually, just "continue" as EVENT_OK is
* OK.
*/
chopstx_mutex_lock (&tty0.mtx);
@@ -791,7 +791,7 @@ tty_main (void *arg)
usb_ctrl_write_finish (&dev);
continue;
case USB_EVENT_NONE:
case USB_EVENT_OK:
case USB_EVENT_DEVICE_SUSPEND:
default:
continue;

View File

@@ -722,24 +722,24 @@ tty_main (void *arg)
usb_device_reset (&dev);
continue;
case USB_EVENT_GET_DESCRIPTOR:
if (usb_get_descriptor (&dev) < 0)
usb_lld_ctrl_error (&dev);
continue;
case USB_EVENT_DEVICE_ADDRESSED:
/* The addres is assigned to the device. We don't
* need to do anything for this actually, but in this
* application, we maintain the USB status of the
* device. Usually, just "continue" as EVENT_NONE is
* device. Usually, just "continue" as EVENT_OK is
* OK.
*/
case USB_EVENT_DEVICE_ADDRESSED:
chopstx_mutex_lock (&tty0.mtx);
tty0.device_state = ADDRESSED;
chopstx_cond_signal (&tty0.cnd);
chopstx_mutex_unlock (&tty0.mtx);
continue;
case USB_EVENT_GET_DESCRIPTOR:
if (usb_get_descriptor (&dev) < 0)
usb_lld_ctrl_error (&dev);
continue;
case USB_EVENT_SET_CONFIGURATION:
if (usb_set_configuration (&dev) < 0)
usb_lld_ctrl_error (&dev);
@@ -750,17 +750,12 @@ tty_main (void *arg)
usb_lld_ctrl_error (&dev);
continue;
/* Non standard device request. */
case USB_EVENT_CTRL_REQUEST:
/* Device specific device request. */
if (usb_setup (&dev) < 0)
usb_lld_ctrl_error (&dev);
continue;
/* Control WRITE transfer finished. */
case USB_EVENT_CTRL_WRITE_FINISH:
usb_ctrl_write_finish (&dev);
continue;
case USB_EVENT_GET_STATUS_INTERFACE:
if (usb_get_status_interface (&dev) < 0)
usb_lld_ctrl_error (&dev);
@@ -771,11 +766,19 @@ tty_main (void *arg)
usb_lld_ctrl_error (&dev);
continue;
case USB_EVENT_NONE:
case USB_EVENT_SET_FEATURE_DEVICE:
case USB_EVENT_SET_FEATURE_ENDPOINT:
case USB_EVENT_CLEAR_FEATURE_DEVICE:
case USB_EVENT_CLEAR_FEATURE_ENDPOINT:
usb_lld_ctrl_ack (&dev);
continue;
case USB_EVENT_CTRL_WRITE_FINISH:
/* Control WRITE transfer finished. */
usb_ctrl_write_finish (&dev);
continue;
case USB_EVENT_OK:
case USB_EVENT_DEVICE_SUSPEND:
default:
continue;

View File

@@ -332,7 +332,7 @@ usb_lld_ctrl_ack (struct usb_dev *dev)
/* Zero length packet for ACK. */
dev->state = WAIT_STATUS_IN;
kl27z_prepare_ep0_in (&dev->dev_req, 0, DATA1);
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
@@ -392,7 +392,7 @@ usb_lld_event_handler (struct usb_dev *dev)
USB_CTRL1->ISTAT = USB_IS_STALL;
}
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
@@ -736,7 +736,7 @@ handle_setup0 (struct usb_dev *dev)
if ((r = (*handler) (dev)) < 0)
{
usb_lld_ctrl_error (dev);
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
else
return r;
@@ -829,7 +829,7 @@ handle_transaction (struct usb_dev *dev, uint8_t stat)
{
handle_out0 (dev, stat);
USB_CTRL1->ISTAT = USB_IS_TOKDNE;
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
}
else
@@ -963,7 +963,7 @@ usb_lld_ctrl_recv (struct usb_dev *dev, void *p, size_t len)
kl27z_prepare_ep0_out (p, len, DATA1);
dev->state = OUT_DATA;
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
/*
@@ -1006,7 +1006,7 @@ usb_lld_ctrl_send (struct usb_dev *dev, const void *buf, size_t buflen)
data_p->len -= len;
data_p->addr += len;
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
void

View File

@@ -359,7 +359,7 @@ usb_lld_ctrl_ack (struct usb_dev *dev)
dev->state = WAIT_STATUS_IN;
st103_set_tx_count (ENDP0, 0);
st103_ep_set_rxtx_status (ENDP0, EP_RX_NAK, EP_TX_VALID);
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
void usb_lld_init (struct usb_dev *dev, uint8_t feature)
@@ -416,7 +416,7 @@ usb_lld_event_handler (struct usb_dev *dev)
return usb_handle_transfer (dev, istr_value);
}
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
static void handle_datastage_out (struct usb_dev *dev)
@@ -797,7 +797,7 @@ static int handle_setup0 (struct usb_dev *dev)
if ((r = (*handler) (dev)) < 0)
{
usb_lld_ctrl_error (dev);
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
else
return r;
@@ -885,7 +885,7 @@ usb_handle_transfer (struct usb_dev *dev, uint16_t istr_value)
else
{
handle_out0 (dev);
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
}
}
@@ -908,7 +908,7 @@ usb_handle_transfer (struct usb_dev *dev, uint16_t istr_value)
}
}
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
void usb_lld_reset (struct usb_dev *dev, uint8_t feature)
@@ -1016,7 +1016,7 @@ int usb_lld_ctrl_recv (struct usb_dev *dev, void *p, size_t len)
struct ctrl_data *data_p = &dev->ctrl_data;
data_p->addr = p;
data_p->len = len;
return USB_EVENT_NONE;
return USB_EVENT_OK;
}
void usb_lld_to_pmabuf (const void *src, uint16_t addr, size_t n)
@@ -1136,5 +1136,5 @@ usb_lld_ctrl_send (struct usb_dev *dev, const void *buf, size_t buflen)
st103_set_tx_count (ENDP0, len);
st103_ep_set_rxtx_status (ENDP0, EP_RX_NAK, EP_TX_VALID);
return USB_EVENT_NONE;
return USB_EVENT_OK;
}

View File

@@ -60,7 +60,7 @@ struct usb_dev {
};
enum {
USB_EVENT_NONE=0, /* Processed in lower layer. */
USB_EVENT_OK=0, /* Processed in lower layer. */
/* Device reset and suspend. */
USB_EVENT_DEVICE_RESET,
USB_EVENT_DEVICE_SUSPEND,