Index: embios/trunk/util.h |
— | — | @@ -50,6 +50,7 @@ |
51 | 51 | #define BITRANGE(x, y) ((0xfffffffful >> (31 + (x) - (y))) << (x))
|
52 | 52 |
|
53 | 53 | #define ERR_RC(val) (BIT(31) | (val))
|
| 54 | +#define IS_ERR(val) (val & BIT(31))
|
54 | 55 | #define RET_ERR(val) \
|
55 | 56 | { \
|
56 | 57 | return ERR_RC(val); \
|
— | — | @@ -61,16 +62,17 @@ |
62 | 63 | }
|
63 | 64 | #define PASS_RC(expr, bits, val) \
|
64 | 65 | { \
|
65 | | - int rc = (expr); \
|
66 | | - if (rc & BIT(31)) return ERR_RC((rc << (bits)) | (val)); \
|
| 66 | + int PASS_RC_rc = (expr); \
|
| 67 | + if (IS_ERR(PASS_RC_rc)) \
|
| 68 | + return ERR_RC((PASS_RC_rc << (bits)) | (val)); \
|
67 | 69 | }
|
68 | 70 | #define PASS_RC_MTX(expr, bits, val, mutex) \
|
69 | 71 | { \
|
70 | | - int rc = (expr); \
|
71 | | - if (rc & BIT(31)) \
|
| 72 | + int PASS_RC_MTX_rc = (expr); \
|
| 73 | + if (IS_ERR(PASS_RC_MTX_rc)) \
|
72 | 74 | { \
|
73 | 75 | mutex_unlock(mutex); \
|
74 | | - return ERR_RC((rc << (bits)) | (val)); \
|
| 76 | + return ERR_RC((PASS_RC_MTX_rc << (bits)) | (val)); \
|
75 | 77 | } \
|
76 | 78 | }
|
77 | 79 |
|
Index: embios/trunk/usb/synopsysotg.c |
— | — | @@ -132,8 +132,6 @@ |
133 | 133 |
|
134 | 134 | static void usb_reset(void)
|
135 | 135 | {
|
136 | | - volatile int i;
|
137 | | -
|
138 | 136 | DCTL = 0x802; /* Soft Disconnect */
|
139 | 137 |
|
140 | 138 | OPHYPWR = 0; /* PHY: Power up */
|
Index: embios/trunk/usb/usb.c |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
|
102 | 102 |
|
103 | 103 | extern int _initstart; // These aren't ints at all, but gcc complains about void types being
|
104 | | -extern int _sdramstart; // used here, and we only need the address, so forget about it...
|
| 104 | +extern int _sdramstart; // used here, and we only need the address, so just make it happy...
|
105 | 105 |
|
106 | 106 |
|
107 | 107 | static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
|
— | — | @@ -429,10 +429,11 @@ |
430 | 430 | case 10: // READ CONSOLE
|
431 | 431 | dbgconsoleattached = true;
|
432 | 432 | int bytes = dbgconsendwriteidx - dbgconsendreadidx;
|
433 | | - if (bytes >= sizeof(dbgconsendbuf)) bytes -= sizeof(dbgconsendbuf);
|
| 433 | + int used = 0;
|
434 | 434 | if (bytes)
|
435 | 435 | {
|
436 | 436 | if (bytes < 0) bytes += sizeof(dbgconsendbuf);
|
| 437 | + used = bytes;
|
437 | 438 | if (bytes > dbgrecvbuf[1]) bytes = dbgrecvbuf[1];
|
438 | 439 | int readbytes = bytes;
|
439 | 440 | char* outptr = (char*)&dbgsendbuf[4];
|
— | — | @@ -451,7 +452,7 @@ |
452 | 453 | dbgsendbuf[0] = 1;
|
453 | 454 | dbgsendbuf[1] = bytes;
|
454 | 455 | dbgsendbuf[2] = sizeof(dbgconsendbuf);
|
455 | | - dbgsendbuf[3] = dbgconsendwriteidx - dbgconsendreadidx;
|
| 456 | + dbgsendbuf[3] = used - bytes;
|
456 | 457 | size = 16 + dbgrecvbuf[1];
|
457 | 458 | break;
|
458 | 459 | case 11: // WRITE CONSOLE
|
— | — | @@ -742,8 +743,8 @@ |
743 | 744 | int free = dbgconsole_getfree();
|
744 | 745 | while (!free && dbgconsoleattached)
|
745 | 746 | {
|
746 | | - if (wakeup_wait(&dbgconsendwakeup, 2000000) == THREAD_TIMEOUT)
|
747 | | - dbgconsoleattached = false;
|
| 747 | + dbgconsoleattached = false;
|
| 748 | + wakeup_wait(&dbgconsendwakeup, 2000000);
|
748 | 749 | free = dbgconsole_getfree();
|
749 | 750 | }
|
750 | 751 | if (free) return free > length ? length : free;
|