int mcd_getresult(struct mcd_softc *sc, struct mcd_result *res) { int i, x; if (sc->debug) printf("%s: mcd_getresult: %d", device_xname(sc->sc_dev), res->length); if ((x = mcd_getreply(sc)) < 0) { if (sc->debug) printf(" timeout\n"); else if (!sc->probe) printf("%s: timeout in getresult\n", device_xname(sc->sc_dev)); return EIO; } if (sc->debug) printf(" %02x", (u_int)x); sc->status = x; mcd_setflags(sc); if ((sc->status & MCD_ST_CMDCHECK) != 0) return EINVAL; for (i = 0; i < res->length; i++) { if ((x = mcd_getreply(sc)) < 0) { if (sc->debug) printf(" timeout\n"); else printf("%s: timeout in getresult\n", device_xname(sc->sc_dev)); return EIO; } if (sc->debug) printf(" %02x", (u_int)x); res->data.raw.data[i] = x; } if (sc->debug) printf(" succeeded\n"); #ifdef MCDDEBUG delay(10); while ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, MCD_XFER) & MCD_XF_STATUSUNAVAIL) == 0) { x = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MCD_STATUS); printf("%s: got extra byte %02x during getstatus\n", device_xname(sc->sc_dev), (u_int)x); delay(10); } #endif return 0; }
static int mcd_get(struct mcd_softc *sc, char *buf, int nmax) { int i,k; for (i=0; i<nmax; i++) { /* wait for data */ if ((k = mcd_getreply(sc, DELAY_GETREPLY)) < 0) { device_printf(sc->dev, "timeout mcd_get\n"); return (-1); } buf[i] = k; } return (i); }
static int mcd_getstat(struct mcd_softc *sc, int sflg) { int i; /* get the status */ if (sflg) MCD_WRITE(sc, MCD_REG_COMMAND, MCD_CMDGETSTAT); i = mcd_getreply(sc, DELAY_GETREPLY); if (i<0 || (i & MCD_ST_CMDCHECK)) { sc->data.curr_mode = MCD_MD_UNKNOWN; return (-1); } sc->data.status = i; if (mcd_setflags(sc) < 0) return (-2); return (sc->data.status); }