Advertisement
rayddteam

Untitled

Dec 5th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- a/head/sys/dev/flash/mx25l.c Wed Dec 05 12:37:28 2012 +0200
  2. +++ b/head/sys/dev/flash/mx25l.c Wed Dec 05 14:10:50 2012 +0200
  3. @@ -231,9 +231,10 @@
  4. uint8_t txBuf[4];//, rxBuf[4];
  5. uint8_t status;
  6. struct spi_command cmd;
  7. - int err;
  8. + int err, timeout;
  9.  
  10. sc = device_get_softc(dev);
  11. + mx25l_wait_for_device_ready(dev);
  12.  
  13. MX25LDEBUG(sc, MX25L_DBG_WRITE, "%s(dev, writable=%d)\n", __func__,
  14. writable);
  15. @@ -246,9 +247,17 @@
  16. cmd.tx_cmd_sz = 1;
  17. err = SPIBUS_TRANSFER(device_get_parent(dev), dev, &cmd);
  18.  
  19. - status = mx25l_get_status(dev);
  20. + mx25l_wait_for_device_ready(dev);
  21.  
  22. - if (writable && !(status & STATUS_WEL))
  23. + timeout = 1000;
  24. + while (timeout--) {
  25. + status = mx25l_get_status(dev);
  26. + if (writable && (status & STATUS_WEL))
  27. + break;
  28. + if (!writable && !(status & STATUS_WEL))
  29. + break;
  30. + }
  31. + if (timeout == 0)
  32. device_printf(dev, "%s - fail\n", __func__);
  33. }
  34.  
  35. @@ -531,6 +540,7 @@
  36. mx25l_attach_sysctl(dev);
  37. #endif
  38.  
  39. + device_printf(sc->sc_dev, "status is 0x%02x\n", mx25l_get_status(dev));
  40. return (0);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement