diff options
| author | prife <[email protected]> | 2013-01-22 16:23:33 +0800 |
|---|---|---|
| committer | prife <[email protected]> | 2013-01-22 16:23:33 +0800 |
| commit | 29d63fe2bcd04008322a0ca2259a56a6ed51ee89 (patch) | |
| tree | 4b317f0b23f17e0b676cca0ce9152615818e70a0 /components/drivers | |
| parent | 3f3b6b7deb2b87f88c2b4a1ed65bbfa25c2b3621 (diff) | |
| parent | 8bbd54ddf65fde499870ceaf4d107d6d23d90d6d (diff) | |
Merge branch 'master' into simposix
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/include/drivers/mtd_nand.h | 11 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/core/core.c | 45 |
2 files changed, 47 insertions, 9 deletions
diff --git a/components/drivers/include/drivers/mtd_nand.h b/components/drivers/include/drivers/mtd_nand.h index 45c3016e5c..fdcece3a57 100644 --- a/components/drivers/include/drivers/mtd_nand.h +++ b/components/drivers/include/drivers/mtd_nand.h @@ -25,11 +25,12 @@ struct rt_mtd_nand_driver_ops; #define RT_MTD_NAND_DEVICE(device) ((struct rt_mtd_nand_device*)(device)) -#define RT_MTD_EOK 0 -#define RT_MTD_EECC 1 -#define RT_MTD_EBUSY 2 -#define RT_MTD_EIO 3 -#define RT_MTD_ENOMEM 4 +#define RT_MTD_EOK 0 /* NO error */ +#define RT_MTD_EECC 1 /* ECC error */ +#define RT_MTD_EBUSY 2 /* hardware busy */ +#define RT_MTD_EIO 3 /* generic IO issue */ +#define RT_MTD_ENOMEM 4 /* out of memory */ +#define RT_MTD_ESRC 5 /* source issue */ struct rt_mtd_nand_device { diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c index c0f21a1cd4..9f1738ed33 100644 --- a/components/drivers/usb/usbdevice/core/core.c +++ b/components/drivers/usb/usbdevice/core/core.c @@ -124,7 +124,7 @@ static rt_err_t _get_string_descriptor(struct udevice* device, ureq_t setup) } } - if(setup->length == 0xFF) + if(setup->length > len) len = str_desc.bLength; else len = setup->length; @@ -356,6 +356,38 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup) } /** + * This function will handle standard request to + * interface that defined in class-specifics + * + * @param device the usb device object. + * @param setup the setup request. + * + * @return RT_EOK on successful. + */ +static rt_err_t _request_interface(struct udevice* device, ureq_t setup) +{ + uintf_t intf; + uclass_t cls; + rt_err_t ret; + + /* parameter check */ + RT_ASSERT(device != RT_NULL); + RT_ASSERT(setup != RT_NULL); + + RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_interface\n")); + + intf = rt_usbd_find_interface(device, setup->index & 0xFF, &cls); + if (intf != RT_NULL) + { + ret = intf->handler(device, cls, setup); + } + else + ret = -RT_ERROR; + + return ret; +} + +/** * This function will handle standard request. * * @param device the usb device object. @@ -419,9 +451,14 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup) _set_interface(device, setup); break; default: - rt_kprintf("unknown interface request\n"); - dcd_ep_stall(device->dcd, 0); - break; + if (_request_interface(device, setup) != RT_EOK) + { + rt_kprintf("unknown interface request\n"); + dcd_ep_stall(device->dcd, 0); + return - RT_ERROR; + } + else + break; } break; case USB_REQ_TYPE_ENDPOINT: |
