freemyipod r336 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r335‎ | r336 | r337 >
Date:16:10, 19 December 2010
Author:theseven
Status:new
Tags:
Comment:
emBIOS: Some minor fixes
Modified paths:
  • /embios/trunk/usb/synopsysotg.c (modified) (history)
  • /embios/trunk/usb/usb.c (modified) (history)
  • /embios/trunk/util.h (modified) (history)

Diff [purge]

Index: embios/trunk/util.h
@@ -50,6 +50,7 @@
5151 #define BITRANGE(x, y) ((0xfffffffful >> (31 + (x) - (y))) << (x))
5252
5353 #define ERR_RC(val) (BIT(31) | (val))
 54+#define IS_ERR(val) (val & BIT(31))
5455 #define RET_ERR(val) \
5556 { \
5657 return ERR_RC(val); \
@@ -61,16 +62,17 @@
6263 }
6364 #define PASS_RC(expr, bits, val) \
6465 { \
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)); \
6769 }
6870 #define PASS_RC_MTX(expr, bits, val, mutex) \
6971 { \
70 - int rc = (expr); \
71 - if (rc & BIT(31)) \
 72+ int PASS_RC_MTX_rc = (expr); \
 73+ if (IS_ERR(PASS_RC_MTX_rc)) \
7274 { \
7375 mutex_unlock(mutex); \
74 - return ERR_RC((rc << (bits)) | (val)); \
 76+ return ERR_RC((PASS_RC_MTX_rc << (bits)) | (val)); \
7577 } \
7678 }
7779
Index: embios/trunk/usb/synopsysotg.c
@@ -132,8 +132,6 @@
133133
134134 static void usb_reset(void)
135135 {
136 - volatile int i;
137 -
138136 DCTL = 0x802; /* Soft Disconnect */
139137
140138 OPHYPWR = 0; /* PHY: Power up */
Index: embios/trunk/usb/usb.c
@@ -100,7 +100,7 @@
101101 static const char dbgconoverflowstr[] = "\n\n[overflowed]\n\n";
102102
103103 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...
105105
106106
107107 static struct usb_device_descriptor CACHEALIGN_ATTR device_descriptor =
@@ -429,10 +429,11 @@
430430 case 10: // READ CONSOLE
431431 dbgconsoleattached = true;
432432 int bytes = dbgconsendwriteidx - dbgconsendreadidx;
433 - if (bytes >= sizeof(dbgconsendbuf)) bytes -= sizeof(dbgconsendbuf);
 433+ int used = 0;
434434 if (bytes)
435435 {
436436 if (bytes < 0) bytes += sizeof(dbgconsendbuf);
 437+ used = bytes;
437438 if (bytes > dbgrecvbuf[1]) bytes = dbgrecvbuf[1];
438439 int readbytes = bytes;
439440 char* outptr = (char*)&dbgsendbuf[4];
@@ -451,7 +452,7 @@
452453 dbgsendbuf[0] = 1;
453454 dbgsendbuf[1] = bytes;
454455 dbgsendbuf[2] = sizeof(dbgconsendbuf);
455 - dbgsendbuf[3] = dbgconsendwriteidx - dbgconsendreadidx;
 456+ dbgsendbuf[3] = used - bytes;
456457 size = 16 + dbgrecvbuf[1];
457458 break;
458459 case 11: // WRITE CONSOLE
@@ -742,8 +743,8 @@
743744 int free = dbgconsole_getfree();
744745 while (!free && dbgconsoleattached)
745746 {
746 - if (wakeup_wait(&dbgconsendwakeup, 2000000) == THREAD_TIMEOUT)
747 - dbgconsoleattached = false;
 747+ dbgconsoleattached = false;
 748+ wakeup_wait(&dbgconsendwakeup, 2000000);
748749 free = dbgconsole_getfree();
749750 }
750751 if (free) return free > length ? length : free;