mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
binding a device driver could fail.. handle this case
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14493 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
195ef597f5
commit
4474d6827c
6 changed files with 19 additions and 11 deletions
|
@ -378,6 +378,8 @@ static void update_driver_names(unsigned char* result) {
|
|||
|
||||
static void bind_device_driver(struct usb_device_driver* driver) {
|
||||
|
||||
int ret = 0;
|
||||
|
||||
/* look if there is an old driver */
|
||||
if (usbcore.active_controller->device_driver != NULL) {
|
||||
usbcore.active_controller->device_driver->unbind();
|
||||
|
@ -387,7 +389,11 @@ static void bind_device_driver(struct usb_device_driver* driver) {
|
|||
usbcore.active_controller->device_driver = driver;
|
||||
|
||||
/* init dirver */
|
||||
driver->bind(usbcore.active_controller->controller_ops);
|
||||
ret = driver->bind(usbcore.active_controller->controller_ops);
|
||||
|
||||
if (ret != 0) {
|
||||
logf("binding of %s failed", driver->name);
|
||||
usbcore.active_controller->device_driver = NULL;
|
||||
usbcore.device_driver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
struct usb_device_driver {
|
||||
const char* name;
|
||||
void (*bind)(void* controller_ops);
|
||||
int (*bind)(void* controller_ops);
|
||||
void (*unbind)(void);
|
||||
int (*request)(struct usb_ctrlrequest* req);
|
||||
void (*suspend)(void);
|
||||
|
|
|
@ -169,7 +169,7 @@ void usb_serial_driver_init(void)
|
|||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
void usb_serial_driver_bind(void* controler_ops)
|
||||
int usb_serial_driver_bind(void* controler_ops)
|
||||
{
|
||||
logf("usb serial: bind");
|
||||
ops = controler_ops;
|
||||
|
@ -201,10 +201,11 @@ void usb_serial_driver_bind(void* controler_ops)
|
|||
serial_debug_desc.bDebugInEndpoint = dev.in->ep_num;
|
||||
serial_debug_desc.bDebugOutEndpoint = dev.out->ep_num;
|
||||
|
||||
return;
|
||||
return 0;
|
||||
|
||||
autoconf_fail:
|
||||
logf("failed to find endpoints");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int usb_serial_driver_request(struct usb_ctrlrequest* request)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
/* register serial driver in usb stack */
|
||||
void usb_serial_driver_init(void);
|
||||
|
||||
void usb_serial_driver_bind(void* controller_ops);
|
||||
int usb_serial_driver_bind(void* controller_ops);
|
||||
int usb_serial_driver_request(struct usb_ctrlrequest* req);
|
||||
void usb_serial_driver_speed(enum usb_device_speed speed);
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ void usb_storage_driver_init(void)
|
|||
/*-------------------------------------------------------------------------*/
|
||||
/* device driver ops */
|
||||
|
||||
void usb_storage_driver_bind(void* controler_ops)
|
||||
int usb_storage_driver_bind(void* controler_ops)
|
||||
{
|
||||
ops = controler_ops;
|
||||
|
||||
|
@ -181,10 +181,11 @@ void usb_storage_driver_bind(void* controler_ops)
|
|||
dev.out->claimed = true;
|
||||
logf("usb storage: out: %s", dev.out->name);
|
||||
|
||||
return;
|
||||
return 0;
|
||||
|
||||
autoconf_fail:
|
||||
logf("failed to find endpoints");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int usb_storage_driver_request(struct usb_ctrlrequest* request)
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
#include "usbstack/core.h"
|
||||
|
||||
/* register serial driver in usb stack */
|
||||
/* register storage driver in usb stack */
|
||||
void usb_storage_driver_init(void);
|
||||
|
||||
void usb_storage_driver_bind(void* controller_ops);
|
||||
int usb_storage_driver_bind(void* controller_ops);
|
||||
int usb_storage_driver_request(struct usb_ctrlrequest* req);
|
||||
void usb_storage_driver_speed(enum usb_device_speed speed);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue