diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-08-28 20:50:41 +0000 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-08-28 20:50:41 +0000 |
commit | 4474d6827c5f08bd0e9a9ba91fc8bf149df21d28 (patch) | |
tree | 4926ee8a2bd49f4c76062724f28d01a471d63b53 /firmware/usbstack | |
parent | 195ef597f5347d29a75eacad3f674bf635e791e5 (diff) | |
download | rockbox-4474d6827c5f08bd0e9a9ba91fc8bf149df21d28.tar.gz rockbox-4474d6827c5f08bd0e9a9ba91fc8bf149df21d28.zip |
binding a device driver could fail.. handle this case
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14493 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack')
-rw-r--r-- | firmware/usbstack/core/core.c | 12 | ||||
-rw-r--r-- | firmware/usbstack/device.h | 2 | ||||
-rw-r--r-- | firmware/usbstack/drivers/device/usb_serial.c | 5 | ||||
-rw-r--r-- | firmware/usbstack/drivers/device/usb_serial.h | 2 | ||||
-rw-r--r-- | firmware/usbstack/drivers/device/usb_storage.c | 5 | ||||
-rw-r--r-- | firmware/usbstack/drivers/device/usb_storage.h | 4 |
6 files changed, 19 insertions, 11 deletions
diff --git a/firmware/usbstack/core/core.c b/firmware/usbstack/core/core.c index e201b7547f..2fbec5d571 100644 --- a/firmware/usbstack/core/core.c +++ b/firmware/usbstack/core/core.c | |||
@@ -378,6 +378,8 @@ static void update_driver_names(unsigned char* result) { | |||
378 | 378 | ||
379 | static void bind_device_driver(struct usb_device_driver* driver) { | 379 | static void bind_device_driver(struct usb_device_driver* driver) { |
380 | 380 | ||
381 | int ret = 0; | ||
382 | |||
381 | /* look if there is an old driver */ | 383 | /* look if there is an old driver */ |
382 | if (usbcore.active_controller->device_driver != NULL) { | 384 | if (usbcore.active_controller->device_driver != NULL) { |
383 | usbcore.active_controller->device_driver->unbind(); | 385 | usbcore.active_controller->device_driver->unbind(); |
@@ -387,7 +389,11 @@ static void bind_device_driver(struct usb_device_driver* driver) { | |||
387 | usbcore.active_controller->device_driver = driver; | 389 | usbcore.active_controller->device_driver = driver; |
388 | 390 | ||
389 | /* init dirver */ | 391 | /* init dirver */ |
390 | driver->bind(usbcore.active_controller->controller_ops); | 392 | ret = driver->bind(usbcore.active_controller->controller_ops); |
391 | } | ||
392 | |||
393 | 393 | ||
394 | if (ret != 0) { | ||
395 | logf("binding of %s failed", driver->name); | ||
396 | usbcore.active_controller->device_driver = NULL; | ||
397 | usbcore.device_driver = NULL; | ||
398 | } | ||
399 | } | ||
diff --git a/firmware/usbstack/device.h b/firmware/usbstack/device.h index 6a7a9998ff..f1052ff9ab 100644 --- a/firmware/usbstack/device.h +++ b/firmware/usbstack/device.h | |||
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | struct usb_device_driver { | 26 | struct usb_device_driver { |
27 | const char* name; | 27 | const char* name; |
28 | void (*bind)(void* controller_ops); | 28 | int (*bind)(void* controller_ops); |
29 | void (*unbind)(void); | 29 | void (*unbind)(void); |
30 | int (*request)(struct usb_ctrlrequest* req); | 30 | int (*request)(struct usb_ctrlrequest* req); |
31 | void (*suspend)(void); | 31 | void (*suspend)(void); |
diff --git a/firmware/usbstack/drivers/device/usb_serial.c b/firmware/usbstack/drivers/device/usb_serial.c index 7299dc6765..0e6d7bf9f9 100644 --- a/firmware/usbstack/drivers/device/usb_serial.c +++ b/firmware/usbstack/drivers/device/usb_serial.c | |||
@@ -169,7 +169,7 @@ void usb_serial_driver_init(void) | |||
169 | 169 | ||
170 | /*-------------------------------------------------------------------------*/ | 170 | /*-------------------------------------------------------------------------*/ |
171 | 171 | ||
172 | void usb_serial_driver_bind(void* controler_ops) | 172 | int usb_serial_driver_bind(void* controler_ops) |
173 | { | 173 | { |
174 | logf("usb serial: bind"); | 174 | logf("usb serial: bind"); |
175 | ops = controler_ops; | 175 | ops = controler_ops; |
@@ -201,10 +201,11 @@ void usb_serial_driver_bind(void* controler_ops) | |||
201 | serial_debug_desc.bDebugInEndpoint = dev.in->ep_num; | 201 | serial_debug_desc.bDebugInEndpoint = dev.in->ep_num; |
202 | serial_debug_desc.bDebugOutEndpoint = dev.out->ep_num; | 202 | serial_debug_desc.bDebugOutEndpoint = dev.out->ep_num; |
203 | 203 | ||
204 | return; | 204 | return 0; |
205 | 205 | ||
206 | autoconf_fail: | 206 | autoconf_fail: |
207 | logf("failed to find endpoints"); | 207 | logf("failed to find endpoints"); |
208 | return -EOPNOTSUPP; | ||
208 | } | 209 | } |
209 | 210 | ||
210 | int usb_serial_driver_request(struct usb_ctrlrequest* request) | 211 | int usb_serial_driver_request(struct usb_ctrlrequest* request) |
diff --git a/firmware/usbstack/drivers/device/usb_serial.h b/firmware/usbstack/drivers/device/usb_serial.h index 657a233f05..8b9d96814e 100644 --- a/firmware/usbstack/drivers/device/usb_serial.h +++ b/firmware/usbstack/drivers/device/usb_serial.h | |||
@@ -25,7 +25,7 @@ | |||
25 | /* register serial driver in usb stack */ | 25 | /* register serial driver in usb stack */ |
26 | void usb_serial_driver_init(void); | 26 | void usb_serial_driver_init(void); |
27 | 27 | ||
28 | void usb_serial_driver_bind(void* controller_ops); | 28 | int usb_serial_driver_bind(void* controller_ops); |
29 | int usb_serial_driver_request(struct usb_ctrlrequest* req); | 29 | int usb_serial_driver_request(struct usb_ctrlrequest* req); |
30 | void usb_serial_driver_speed(enum usb_device_speed speed); | 30 | void usb_serial_driver_speed(enum usb_device_speed speed); |
31 | 31 | ||
diff --git a/firmware/usbstack/drivers/device/usb_storage.c b/firmware/usbstack/drivers/device/usb_storage.c index 3db379c1df..7d7ab8c4b8 100644 --- a/firmware/usbstack/drivers/device/usb_storage.c +++ b/firmware/usbstack/drivers/device/usb_storage.c | |||
@@ -160,7 +160,7 @@ void usb_storage_driver_init(void) | |||
160 | /*-------------------------------------------------------------------------*/ | 160 | /*-------------------------------------------------------------------------*/ |
161 | /* device driver ops */ | 161 | /* device driver ops */ |
162 | 162 | ||
163 | void usb_storage_driver_bind(void* controler_ops) | 163 | int usb_storage_driver_bind(void* controler_ops) |
164 | { | 164 | { |
165 | ops = controler_ops; | 165 | ops = controler_ops; |
166 | 166 | ||
@@ -181,10 +181,11 @@ void usb_storage_driver_bind(void* controler_ops) | |||
181 | dev.out->claimed = true; | 181 | dev.out->claimed = true; |
182 | logf("usb storage: out: %s", dev.out->name); | 182 | logf("usb storage: out: %s", dev.out->name); |
183 | 183 | ||
184 | return; | 184 | return 0; |
185 | 185 | ||
186 | autoconf_fail: | 186 | autoconf_fail: |
187 | logf("failed to find endpoints"); | 187 | logf("failed to find endpoints"); |
188 | return -EOPNOTSUPP; | ||
188 | } | 189 | } |
189 | 190 | ||
190 | int usb_storage_driver_request(struct usb_ctrlrequest* request) | 191 | int usb_storage_driver_request(struct usb_ctrlrequest* request) |
diff --git a/firmware/usbstack/drivers/device/usb_storage.h b/firmware/usbstack/drivers/device/usb_storage.h index ff4b187064..efd20fe8ee 100644 --- a/firmware/usbstack/drivers/device/usb_storage.h +++ b/firmware/usbstack/drivers/device/usb_storage.h | |||
@@ -22,10 +22,10 @@ | |||
22 | 22 | ||
23 | #include "usbstack/core.h" | 23 | #include "usbstack/core.h" |
24 | 24 | ||
25 | /* register serial driver in usb stack */ | 25 | /* register storage driver in usb stack */ |
26 | void usb_storage_driver_init(void); | 26 | void usb_storage_driver_init(void); |
27 | 27 | ||
28 | void usb_storage_driver_bind(void* controller_ops); | 28 | int usb_storage_driver_bind(void* controller_ops); |
29 | int usb_storage_driver_request(struct usb_ctrlrequest* req); | 29 | int usb_storage_driver_request(struct usb_ctrlrequest* req); |
30 | void usb_storage_driver_speed(enum usb_device_speed speed); | 30 | void usb_storage_driver_speed(enum usb_device_speed speed); |
31 | 31 | ||