diff options
author | Mike Lockwood <lockwood@android.com> | 2010-06-10 10:20:49 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-06-10 10:22:38 -0400 |
commit | e15af09876c5e0301084f46b8036aed147cf9c24 (patch) | |
tree | 50c54454cfd93745441471b9e338852e6f6fa75c /libusbhost | |
parent | 7570ab61d40190a1e9c5d4cd9dfc8220dbb18235 (diff) | |
download | system_core-e15af09876c5e0301084f46b8036aed147cf9c24.zip system_core-e15af09876c5e0301084f46b8036aed147cf9c24.tar.gz system_core-e15af09876c5e0301084f46b8036aed147cf9c24.tar.bz2 |
libusbhost: Use logcat for debugging when building device library.
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'libusbhost')
-rw-r--r-- | libusbhost/Android.mk | 2 | ||||
-rw-r--r-- | libusbhost/usbhost.c | 24 |
2 files changed, 20 insertions, 6 deletions
diff --git a/libusbhost/Android.mk b/libusbhost/Android.mk index c8c8758..97c1edc 100644 --- a/libusbhost/Android.mk +++ b/libusbhost/Android.mk @@ -38,4 +38,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := libusbhost LOCAL_SRC_FILES := usbhost.c +LOCAL_CFLAGS := -g -DUSE_LIBLOG + include $(BUILD_STATIC_LIBRARY) diff --git a/libusbhost/usbhost.c b/libusbhost/usbhost.c index a6b0867..1d83a39 100644 --- a/libusbhost/usbhost.c +++ b/libusbhost/usbhost.c @@ -14,6 +14,21 @@ * limitations under the License. */ +// #define DEBUG 1 +#if DEBUG + +#ifdef USE_LIBLOG +#define LOG_TAG "usbhost" +#include "utils/Log.h" +#define D LOGD +#else +#define D printf +#endif + +#else +#define D(...) +#endif + #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -43,11 +58,6 @@ #define USB_FS_DIR "/dev/bus/usb" #define USB_FS_ID_SCANNER "/dev/bus/usb/%d/%d" -#if 0 -#define D printf -#else -#define D(...) -#endif struct usb_host_context { usb_device_added_cb added_cb; @@ -208,7 +218,8 @@ retry: if (fd < 0) { /* if we fail, see if have read-only access */ fd = open(dev_name, O_RDONLY); - if (fd < 0 && errno == EACCES && !did_retry) { + D("usb_device_open open returned %d errno %d\n", fd, errno); + if (fd < 0 && (errno == EACCES || errno == ENOENT) && !did_retry) { /* work around race condition between inotify and permissions management */ sleep(1); did_retry = 1; @@ -221,6 +232,7 @@ retry: } length = read(fd, device->desc, sizeof(device->desc)); + D("usb_device_open read returned %d errno %d\n", fd, errno); if (length < 0) goto fail; |