Deleted Added
full compact
54c54
< __FBSDID("$FreeBSD: head/sys/dev/fdc/fdc.c 175230 2008-01-11 16:50:52Z kib $");
---
> __FBSDID("$FreeBSD: head/sys/dev/fdc/fdc.c 184976 2008-11-15 01:43:34Z jkim $");
99a100,101
> #define FD_NO_CHLINE 0x10 /* drive does not support changeline
> * aka. unit attention */
265a268
> static int fd_probe_disk(struct fd_data *, int *);
771,773c774,778
< mtx_lock(&fdc->fdc_mtx);
< fd->flags |= FD_EMPTY;
< mtx_unlock(&fdc->fdc_mtx);
---
> if (fdc->flags & FDC_NEEDS_RESET) {
> mtx_lock(&fdc->fdc_mtx);
> fd->flags |= FD_EMPTY;
> mtx_unlock(&fdc->fdc_mtx);
> }
839,840c844,847
<
< if (!(fdin_rd(fdc) & FDI_DCHG) && !(fd->flags & FD_EMPTY))
---
> if ((!(device_get_flags(fd->dev) & FD_NO_CHLINE) &&
> !(fdin_rd(fdc) & FDI_DCHG) &&
> !(fd->flags & FD_EMPTY)) ||
> fd_probe_disk(fd, &need_recal) == 0)
842,897c849
<
< /*
< * Try to find out if we have a disk in the drive
< *
< * First recal, then seek to cyl#1, this clears the
< * old condition on the disk change line so we can
< * examine it for current status
< */
< if (debugflags & 0x40)
< printf("New disk in probe\n");
< mtx_lock(&fdc->fdc_mtx);
< fd->flags |= FD_NEWDISK;
< mtx_unlock(&fdc->fdc_mtx);
< retry_line = __LINE__;
< if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0))
< return (1);
< tsleep(fdc, PRIBIO, "fdrecal", hz);
< retry_line = __LINE__;
< if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
< return (1); /* XXX */
< retry_line = __LINE__;
< if ((st0 & 0xc0) || cyl != 0)
< return (1);
<
< /* Seek to track 1 */
< retry_line = __LINE__;
< if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, 1, 0))
< return (1);
< tsleep(fdc, PRIBIO, "fdseek", hz);
< retry_line = __LINE__;
< if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
< return (1); /* XXX */
< need_recal |= (1 << fd->fdsu);
< if (fdin_rd(fdc) & FDI_DCHG) {
< if (debugflags & 0x40)
< printf("Empty in probe\n");
< mtx_lock(&fdc->fdc_mtx);
< fd->flags |= FD_EMPTY;
< mtx_unlock(&fdc->fdc_mtx);
< } else {
< if (debugflags & 0x40)
< printf("Got disk in probe\n");
< mtx_lock(&fdc->fdc_mtx);
< fd->flags &= ~FD_EMPTY;
< mtx_unlock(&fdc->fdc_mtx);
< retry_line = __LINE__;
< if(fdc_sense_drive(fdc, &st3) != 0)
< return (1);
< mtx_lock(&fdc->fdc_mtx);
< if(st3 & NE7_ST3_WP)
< fd->flags |= FD_WP;
< else
< fd->flags &= ~FD_WP;
< mtx_unlock(&fdc->fdc_mtx);
< }
< return (fdc_biodone(fdc, 0));
---
> return (1);
1240a1193,1195
> /*
> * Try to find out if we have a disk in the drive.
> */
1241a1197,1258
> fd_probe_disk(struct fd_data *fd, int *recal)
> {
> struct fdc_data *fdc;
> int st0, st3, cyl;
> int oopts, ret;
>
> fdc = fd->fdc;
> oopts = fd->options;
> fd->options |= FDOPT_NOERRLOG | FDOPT_NORETRY;
> ret = 1;
>
> /*
> * First recal, then seek to cyl#1, this clears the old condition on
> * the disk change line so we can examine it for current status.
> */
> if (debugflags & 0x40)
> printf("New disk in probe\n");
> mtx_lock(&fdc->fdc_mtx);
> fd->flags |= FD_NEWDISK;
> mtx_unlock(&fdc->fdc_mtx);
> if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0))
> goto done;
> tsleep(fdc, PRIBIO, "fdrecal", hz);
> if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
> goto done; /* XXX */
> if ((st0 & 0xc0) || cyl != 0)
> goto done;
>
> /* Seek to track 1 */
> if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, 1, 0))
> goto done;
> tsleep(fdc, PRIBIO, "fdseek", hz);
> if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
> goto done; /* XXX */
> *recal |= (1 << fd->fdsu);
> if (fdin_rd(fdc) & FDI_DCHG) {
> if (debugflags & 0x40)
> printf("Empty in probe\n");
> mtx_lock(&fdc->fdc_mtx);
> fd->flags |= FD_EMPTY;
> mtx_unlock(&fdc->fdc_mtx);
> } else {
> if (fdc_sense_drive(fdc, &st3) != 0)
> goto done;
> if (debugflags & 0x40)
> printf("Got disk in probe\n");
> mtx_lock(&fdc->fdc_mtx);
> fd->flags &= ~FD_EMPTY;
> if (st3 & NE7_ST3_WP)
> fd->flags |= FD_WP;
> else
> fd->flags &= ~FD_WP;
> mtx_unlock(&fdc->fdc_mtx);
> }
> ret = 0;
>
> done:
> fd->options = oopts;
> return (ret);
> }
>
> static int
1353c1370
< return (0);
---
> return (-1);
1414c1431,1437
< fdautoselect(fd);
---
> if (fdautoselect(fd) != 0 &&
> (device_get_flags(fd->dev) & FD_NO_CHLINE)) {
> mtx_lock(&fdc->fdc_mtx);
> fd->flags |= FD_EMPTY;
> mtx_unlock(&fdc->fdc_mtx);
> return (ENXIO);
> }