Module Name: src
Committed By: tsutsui
Date: Sun May 13 03:00:41 UTC 2012
Modified Files:
src/sys/arch/x68k/dev: fd.c
Log Message:
KNF and cosmetics. No binary change.
To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/arch/x68k/dev/fd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.99 src/sys/arch/x68k/dev/fd.c:1.100
--- src/sys/arch/x68k/dev/fd.c:1.99 Sun May 13 00:47:16 2012
+++ src/sys/arch/x68k/dev/fd.c Sun May 13 03:00:40 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $ */
+/* $NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_m68k_arch.h"
@@ -144,7 +144,7 @@ struct fdc_softc {
bus_dma_tag_t sc_dmat; /* intio DMA tag */
bus_dmamap_t sc_dmamap; /* DMA map */
- u_int8_t *sc_addr; /* physical address */
+ uint8_t *sc_addr; /* physical address */
struct dmac_channel_stat *sc_dmachan; /* intio DMA channel */
struct dmac_dma_xfer *sc_xfer; /* DMA transfer */
int sc_read;
@@ -153,7 +153,7 @@ struct fdc_softc {
TAILQ_HEAD(drivehead, fd_softc) sc_drives;
enum fdc_state sc_state;
int sc_errors; /* number of retries so far */
- u_char sc_status[7]; /* copy of registers */
+ uint8_t sc_status[7]; /* copy of registers */
} fdc_softc;
int fdcintr(void *);
@@ -233,8 +233,8 @@ struct fd_softc {
int sc_ops; /* I/O ops since last switch */
struct bufq_state *sc_q;/* pending I/O requests */
int sc_active; /* number of active I/O operations */
- u_char *sc_copybuf; /* for secsize >=3 */
- u_char sc_part; /* for secsize >=3 */
+ uint8_t *sc_copybuf; /* for secsize >=3 */
+ uint8_t sc_part; /* for secsize >=3 */
#define SEC_P10 0x02 /* first part */
#define SEC_P01 0x01 /* second part */
#define SEC_P11 0x03 /* both part */
@@ -275,7 +275,7 @@ void fd_motor_off(void *);
void fd_motor_on(void *);
#endif
int fdcresult(struct fdc_softc *);
-int out_fdc(bus_space_tag_t, bus_space_handle_t, u_char);
+int out_fdc(bus_space_tag_t, bus_space_handle_t, uint8_t);
void fdcstart(struct fdc_softc *);
void fdcstatus(device_t, int, const char *);
void fdctimeout(void *);
@@ -300,16 +300,16 @@ fdc_dmastart(struct fdc_softc *fdc, int
int error;
DPRINTF(("fdc_dmastart: %s, addr = %p, count = %ld\n",
- read ? "read" : "write", (void *) addr, count));
+ read ? "read" : "write", (void *)addr, count));
error = bus_dmamap_load(fdc->sc_dmat, fdc->sc_dmamap, addr, count,
- 0, BUS_DMA_NOWAIT);
+ 0, BUS_DMA_NOWAIT);
if (error) {
- panic ("fdc_dmastart: cannot load dmamap");
+ panic("fdc_dmastart: cannot load dmamap");
}
bus_dmamap_sync(fdc->sc_dmat, fdc->sc_dmamap, 0, count,
- read?BUS_DMASYNC_PREREAD:BUS_DMASYNC_PREWRITE);
+ read ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
/*
* Note 1:
@@ -324,13 +324,10 @@ fdc_dmastart(struct fdc_softc *fdc, int
* XXX: No proper API to get DMA address of FDC register for DMAC.
*/
fdc->sc_xfer = dmac_prepare_xfer(fdc->sc_dmachan, fdc->sc_dmat,
- fdc->sc_dmamap,
- (read?
- DMAC_OCR_DIR_DTM:DMAC_OCR_DIR_MTD),
- (DMAC_SCR_MAC_COUNT_UP|
- DMAC_SCR_DAC_NO_COUNT),
- (u_int8_t*) (fdc->sc_addr +
- fddata * 2 + 1));
+ fdc->sc_dmamap,
+ read ? DMAC_OCR_DIR_DTM : DMAC_OCR_DIR_MTD,
+ DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT,
+ fdc->sc_addr + fddata * 2 + 1);
fdc->sc_read = read;
dmac_start_xfer(fdc->sc_dmachan->ch_softc, fdc->sc_xfer);
@@ -353,6 +350,7 @@ fdcdmaintr(void *arg)
static int
fdcdmaerrintr(void *dummy)
{
+
DPRINTF(("fdcdmaerrintr\n"));
return 0;
@@ -380,7 +378,7 @@ fdcprobe(device_t parent, cfdata_t cf, v
return 0;
ia->ia_size = 0x2000;
- if (intio_map_allocate_region (parent, ia, INTIO_MAP_TESTONLY))
+ if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
return 0;
/* builtin device; always there */
@@ -407,7 +405,7 @@ fdprint(void *aux, const char *fdc)
{
struct fdc_attach_args *fa = aux;
- if (!fdc)
+ if (fdc == NULL)
aprint_normal(" drive %d", fa->fa_drive);
return QUIET;
}
@@ -441,18 +439,16 @@ fdcattach(device_t parent, device_t self
/* Initialize DMAC channel */
fdc->sc_dmachan = dmac_alloc_channel(parent, ia->ia_dma, "fdc",
- ia->ia_dmaintr, fdcdmaintr, fdc,
- ia->ia_dmaintr+1, fdcdmaerrintr,
- fdc);
+ ia->ia_dmaintr, fdcdmaintr, fdc,
+ ia->ia_dmaintr + 1, fdcdmaerrintr, fdc);
if (bus_dmamap_create(fdc->sc_dmat, FDC_MAXIOSIZE, 1, DMAC_MAXSEGSZ,
- 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW,
- &fdc->sc_dmamap)) {
+ 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &fdc->sc_dmamap)) {
aprint_error_dev(self, "can't set up intio DMA map\n");
return;
}
- if (intio_intr_establish(ia->ia_intr, "fdc", fdcintr, fdc))
- panic ("Could not establish interrupt (duplicated vector?).");
+ if (intio_intr_establish(ia->ia_intr, "fdc", fdcintr, fdc) != 0)
+ panic("Could not establish interrupt (duplicated vector?).");
intio_set_ivec(ia->ia_intr);
/* reset */
@@ -462,7 +458,7 @@ fdcattach(device_t parent, device_t self
fdcreset(fdc);
aprint_normal_dev(self, "uPD72065 FDC\n");
- out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
+ out_fdc(iot, ioh, NE7CMD_SPECIFY); /* specify command */
out_fdc(iot, ioh, 0xd0);
out_fdc(iot, ioh, 0x10);
@@ -477,6 +473,7 @@ fdcattach(device_t parent, device_t self
void
fdcreset(struct fdc_softc *fdc)
{
+
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdsts, NE7CMD_RESET);
}
@@ -484,8 +481,9 @@ static int
fdcpoll(struct fdc_softc *fdc)
{
int i = 25000, n;
+
while (--i > 0) {
- if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC)) {
+ if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC) != 0) {
out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
n = fdcresult(fdc);
break;
@@ -521,13 +519,13 @@ fdprobe(device_t parent, cfdata_t cf, vo
fdc_force_ready(FDCRDY);
fdcpoll(fdc);
-retry:
+ retry:
out_fdc(iot, ioh, NE7CMD_RECAL);
out_fdc(iot, ioh, drive);
i = 25000;
while (--i > 0) {
- if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC)) {
+ if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC) != 0) {
out_fdc(iot, ioh, NE7CMD_SENSEI);
n = fdcresult(fdc);
break;
@@ -554,7 +552,7 @@ retry:
/* turn off motor */
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh,
- fdctl, (type->rate << 4)| drive);
+ fdctl, (type->rate << 4) | drive);
fdc_force_ready(FDCSTBY);
if (!found) {
intio_enable_intr(SICILIAN_INTR_FDC);
@@ -586,7 +584,7 @@ fdattach(device_t parent, device_t self,
if (type)
aprint_normal(": %s, %d cyl, %d head, %d sec\n", type->name,
- type->cyls, type->heads, type->sectrac);
+ type->cyls, type->heads, type->sectrac);
else
aprint_normal(": density unknown\n");
@@ -596,7 +594,7 @@ fdattach(device_t parent, device_t self,
fd->sc_deftype = type;
fdc->sc_fd[drive] = fd;
- fd->sc_copybuf = (u_char *)malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
+ fd->sc_copybuf = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
if (fd->sc_copybuf == 0)
aprint_error("%s: WARNING!! malloc() failed.\n", __func__);
fd->sc_flags |= FD_ALIVE;
@@ -614,7 +612,7 @@ fdattach(device_t parent, device_t self,
mountroothook_establish(fd_mountroot_hook, fd->sc_dev);
rnd_attach_source(&fd->rnd_source, device_xname(fd->sc_dev),
- RND_TYPE_DISK, 0);
+ RND_TYPE_DISK, 0);
}
inline struct fd_type *
@@ -645,8 +643,8 @@ fdstrategy(struct buf *bp)
if (bp->b_blkno < 0 ||
(bp->b_bcount % FDC_BSIZE) != 0) {
DPRINTF(("fdstrategy: unit=%d, blkno=%" PRId64 ", "
- "bcount=%d\n", unit,
- bp->b_blkno, bp->b_bcount));
+ "bcount=%d\n", unit,
+ bp->b_blkno, bp->b_bcount));
bp->b_error = EINVAL;
goto done;
}
@@ -676,11 +674,11 @@ fdstrategy(struct buf *bp)
}
bp->b_rawblkno = bp->b_blkno;
- bp->b_cylinder = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE)
- / (fd->sc_type->seccyl * (1 << (fd->sc_type->secsize - 2)));
+ bp->b_cylinder = (bp->b_blkno / (FDC_BSIZE / DEV_BSIZE)) /
+ (fd->sc_type->seccyl * (1 << (fd->sc_type->secsize - 2)));
DPRINTF(("fdstrategy: %s b_blkno %" PRId64 " b_bcount %d cylin %d\n",
- bp->b_flags & B_READ ? "read" : "write",
+ bp->b_flags & B_READ ? "read" : "write",
bp->b_blkno, bp->b_bcount, bp->b_cylinder));
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
@@ -690,7 +688,9 @@ fdstrategy(struct buf *bp)
fdstart(fd);
#ifdef DIAGNOSTIC
else {
- struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev));
+ struct fdc_softc *fdc;
+
+ fdc = device_private(device_parent(fd->sc_dev));
if (fdc->sc_state == DEVIDLE) {
printf("fdstrategy: controller inactive\n");
fdcstart(fdc);
@@ -700,7 +700,7 @@ fdstrategy(struct buf *bp)
splx(s);
return;
-done:
+ done:
/* Toss transfer; we're done early. */
biodone(bp);
}
@@ -735,9 +735,9 @@ fdfinish(struct fd_softc *fd, struct buf
if (TAILQ_NEXT(fd, sc_drivechain) && ++fd->sc_ops >= 8) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
- if (bufq_peek(fd->sc_q) != NULL) {
+ if (bufq_peek(fd->sc_q) != NULL)
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
- } else
+ else
fd->sc_active = 0;
}
bp->b_resid = fd->sc_bcount;
@@ -755,14 +755,14 @@ int
fdread(dev_t dev, struct uio *uio, int flags)
{
- return (physio(fdstrategy, NULL, dev, B_READ, minphys, uio));
+ return physio(fdstrategy, NULL, dev, B_READ, minphys, uio);
}
int
fdwrite(dev_t dev, struct uio *uio, int flags)
{
- return (physio(fdstrategy, NULL, dev, B_WRITE, minphys, uio));
+ return physio(fdstrategy, NULL, dev, B_WRITE, minphys, uio);
}
void
@@ -772,11 +772,12 @@ fd_set_motor(struct fdc_softc *fdc, int
int n;
DPRINTF(("fd_set_motor:\n"));
- for (n = 0; n < 4; n++)
- if ((fd = fdc->sc_fd[n]) && (fd->sc_flags & FD_MOTOR)) {
+ for (n = 0; n < 4; n++) {
+ fd = fdc->sc_fd[n];
+ if (fd != NULL && (fd->sc_flags & FD_MOTOR) != 0)
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdctl,
- 0x80 | (fd->sc_type->rate << 4)| n);
- }
+ 0x80 | (fd->sc_type->rate << 4)| n);
+ }
}
void
@@ -790,8 +791,8 @@ fd_motor_off(void *arg)
s = splbio();
fd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
- bus_space_write_1 (fdc->sc_iot, fdc->sc_ioh, fdctl,
- (fd->sc_type->rate << 4) | fd->sc_drive);
+ bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdctl,
+ (fd->sc_type->rate << 4) | fd->sc_drive);
#if 0
fd_set_motor(fdc, 0); /* XXX */
#endif
@@ -810,8 +811,9 @@ fd_motor_on(void *arg)
s = splbio();
fd->sc_flags &= ~FD_MOTOR_WAIT;
- if ((TAILQ_FIRST(&fdc->sc_drives) == fd) && (fdc->sc_state == MOTORWAIT))
- (void) fdcintr(fdc);
+ if ((TAILQ_FIRST(&fdc->sc_drives) == fd) &&
+ (fdc->sc_state == MOTORWAIT))
+ (void)fdcintr(fdc);
splx(s);
}
#endif
@@ -821,11 +823,11 @@ fdcresult(struct fdc_softc *fdc)
{
bus_space_tag_t iot = fdc->sc_iot;
bus_space_handle_t ioh = fdc->sc_ioh;
- u_char i;
- int j = 100000,
- n = 0;
+ uint8_t i;
+ int j, n;
- for (; j; j--) {
+ n = 0;
+ for (j = 100000; j != 0; j--) {
i = bus_space_read_1(iot, ioh, fdsts) &
(NE7_DIO | NE7_RQM | NE7_CB);
@@ -837,7 +839,7 @@ fdcresult(struct fdc_softc *fdc)
return -1;
}
fdc->sc_status[n++] =
- bus_space_read_1(iot, ioh, fddata);
+ bus_space_read_1(iot, ioh, fddata);
}
delay(10);
}
@@ -846,7 +848,7 @@ fdcresult(struct fdc_softc *fdc)
}
int
-out_fdc(bus_space_tag_t iot, bus_space_handle_t ioh, u_char x)
+out_fdc(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t x)
{
int i = 100000;
@@ -884,7 +886,7 @@ fdopen(dev_t dev, int flags, int mode, s
if ((fd->sc_flags & FD_OPEN) == 0) {
/* Lock eject button */
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout,
- 0x40 | ( 1 << unit));
+ 0x40 | (1 << unit));
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0x40);
}
@@ -925,7 +927,7 @@ fdclose(dev_t dev, int flags, int mode,
if ((fd->sc_flags & FD_OPEN) == 0) {
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout,
- ( 1 << unit));
+ (1 << unit));
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0);
}
return 0;
@@ -943,7 +945,7 @@ fdcstart(struct fdc_softc *fdc)
return;
}
#endif
- (void) fdcintr(fdc);
+ (void)fdcintr(fdc);
}
@@ -985,7 +987,7 @@ fdcstatus(device_t dv, int n, const char
if (n == 0) {
out_fdc(fdc->sc_iot, fdc->sc_ioh, NE7CMD_SENSEI);
- (void) fdcresult(fdc);
+ (void)fdcresult(fdc);
n = 2;
}
@@ -1008,7 +1010,7 @@ fdctimeout(void *arg)
else
fdc->sc_state = DEVIDLE;
- (void) fdcintr(fdc);
+ (void)fdcintr(fdc);
splx(s);
}
@@ -1021,7 +1023,7 @@ fdcpseudointr(void *arg)
/* just ensure it has the right spl */
s = splbio();
- (void) fdcintr(fdc);
+ (void)fdcintr(fdc);
splx(s);
}
#endif
@@ -1037,15 +1039,16 @@ fdcintr(void *arg)
bus_space_tag_t iot = fdc->sc_iot;
bus_space_handle_t ioh = fdc->sc_ioh;
int read, head, sec, pos, i, sectrac, nblks;
- int tmp;
+ int tmp;
struct fd_type *type;
-loop:
+ loop:
fd = TAILQ_FIRST(&fdc->sc_drives);
if (fd == NULL) {
DPRINTF(("fdcintr: set DEVIDLE\n"));
if (fdc->sc_state == DEVIDLE) {
- if (intio_get_sicilian_intr() & SICILIAN_STAT_FDC) {
+ if ((intio_get_sicilian_intr() & SICILIAN_STAT_FDC)
+ != 0) {
out_fdc(iot, ioh, NE7CMD_SENSEI);
if ((tmp = fdcresult(fdc)) != 2 ||
(st0 & 0xf8) != 0x20) {
@@ -1084,10 +1087,11 @@ loop:
/* being careful about other drives. */
for (i = 0; i < 4; i++) {
struct fd_softc *ofd = fdc->sc_fd[i];
- if (ofd && ofd->sc_flags & FD_MOTOR) {
+ if (ofd != NULL &&
+ (ofd->sc_flags & FD_MOTOR) != 0) {
callout_stop(&ofd->sc_motoroff_ch);
ofd->sc_flags &=
- ~(FD_MOTOR | FD_MOTOR_WAIT);
+ ~(FD_MOTOR | FD_MOTOR_WAIT);
break;
}
}
@@ -1111,11 +1115,11 @@ loop:
if (fd->sc_cylin == bp->b_cylinder)
goto doio;
- out_fdc(iot, ioh, NE7CMD_SPECIFY);/* specify command */
- out_fdc(iot, ioh, 0xd0); /* XXX const */
+ out_fdc(iot, ioh, NE7CMD_SPECIFY); /* specify command */
+ out_fdc(iot, ioh, 0xd0); /* XXX const */
out_fdc(iot, ioh, 0x10);
- out_fdc(iot, ioh, NE7CMD_SEEK); /* seek function */
+ out_fdc(iot, ioh, NE7CMD_SEEK); /* seek function */
out_fdc(iot, ioh, fd->sc_drive); /* drive number */
out_fdc(iot, ioh, bp->b_cylinder * fd->sc_type->step);
@@ -1149,14 +1153,13 @@ loop:
} else {
fd->sc_part = SEC_P11;
nblks = (sectrac - sec) * 2;
- nblks = min(nblks, fd->sc_bcount
- / FDC_BSIZE - 1);
+ nblks = min(nblks,
+ fd->sc_bcount / FDC_BSIZE - 1);
DPRINTF(("nblks(2)"));
}
} else {
fd->sc_part = SEC_P11;
- nblks = (sectrac - sec)
- << (type->secsize - 2);
+ nblks = (sectrac - sec) << (type->secsize - 2);
nblks = min(nblks, fd->sc_bcount / FDC_BSIZE);
DPRINTF(("nblks(3)"));
}
@@ -1170,38 +1173,40 @@ loop:
fd->sc_nblks = nblks;
fd->sc_nbytes = nblks * FDC_BSIZE;
head = (fd->sc_blkno
- % (type->seccyl * (1 << (type->secsize - 2))))
- / (type->sectrac * (1 << (type->secsize - 2)));
+ % (type->seccyl * (1 << (type->secsize - 2))))
+ / (type->sectrac * (1 << (type->secsize - 2)));
#ifdef DIAGNOSTIC
- {int block;
- block = ((fd->sc_cylin * type->heads + head) * type->sectrac
- + sec) * (1 << (type->secsize - 2));
- block += (fd->sc_part == SEC_P01) ? 1 : 0;
- if (block != fd->sc_blkno) {
- printf("C H R N: %d %d %d %d\n",
- fd->sc_cylin, head, sec, type->secsize);
- printf("fdcintr: doio: block %d != blkno %" PRId64 "\n",
- block, fd->sc_blkno);
+ {
+ int block;
+ block = ((fd->sc_cylin * type->heads + head) *
+ type->sectrac + sec) * (1 << (type->secsize - 2));
+ block += (fd->sc_part == SEC_P01) ? 1 : 0;
+ if (block != fd->sc_blkno) {
+ printf("C H R N: %d %d %d %d\n",
+ fd->sc_cylin, head, sec, type->secsize);
+ printf("fdcintr: doio: block %d != blkno %"
+ PRId64 "\n",
+ block, fd->sc_blkno);
#ifdef DDB
- Debugger();
+ Debugger();
#endif
- }
+ }
}
#endif
read = bp->b_flags & B_READ;
DPRINTF(("fdcintr: %s drive %d track %d "
- "head %d sec %d nblks %d, skip %d\n",
- read ? "read" : "write", fd->sc_drive, fd->sc_cylin,
- head, sec, nblks, fd->sc_skip));
+ "head %d sec %d nblks %d, skip %d\n",
+ read ? "read" : "write", fd->sc_drive, fd->sc_cylin,
+ head, sec, nblks, fd->sc_skip));
DPRINTF(("C H R N: %d %d %d %d\n", fd->sc_cylin, head, sec,
- type->secsize));
+ type->secsize));
if (fd->sc_part != SEC_P11)
goto docopy;
fdc_dmastart(fdc, read, (char *)bp->b_data + fd->sc_skip,
- fd->sc_nbytes);
+ fd->sc_nbytes);
if (read)
out_fdc(iot, ioh, NE7CMD_READ); /* READ */
else
@@ -1227,9 +1232,10 @@ loop:
DPRINTF(("fdcintr: DOCOPY:\n"));
type = fd->sc_type;
head = (fd->sc_blkno
- % (type->seccyl * (1 << (type->secsize - 2))))
- / (type->sectrac * (1 << (type->secsize - 2)));
- pos = fd->sc_blkno % (type->sectrac * (1 << (type->secsize - 2)));
+ % (type->seccyl * (1 << (type->secsize - 2))))
+ / (type->sectrac * (1 << (type->secsize - 2)));
+ pos = fd->sc_blkno %
+ (type->sectrac * (1 << (type->secsize - 2)));
sec = pos / (1 << (type->secsize - 2));
fdc_dmastart(fdc, B_READ, fd->sc_copybuf, 1024);
out_fdc(iot, ioh, NE7CMD_READ); /* READ */
@@ -1255,21 +1261,22 @@ loop:
pos = fd->sc_blkno % (sectrac * (1 << (type->secsize - 2)));
sec = pos / (1 << (type->secsize - 2));
head = (fd->sc_blkno
- % (type->seccyl * (1 << (type->secsize - 2))))
- / (type->sectrac * (1 << (type->secsize - 2)));
+ % (type->seccyl * (1 << (type->secsize - 2))))
+ / (type->sectrac * (1 << (type->secsize - 2)));
#ifdef DIAGNOSTIC
- {int block;
- block = ((fd->sc_cylin * type->heads + head) *
- type->sectrac + sec)
- * (1 << (type->secsize - 2));
- block += (fd->sc_part == SEC_P01) ? 1 : 0;
- if (block != fd->sc_blkno) {
- printf("fdcintr: block %d != blkno %" PRId64 "\n",
- block, fd->sc_blkno);
+ {
+ int block;
+ block = ((fd->sc_cylin * type->heads + head) *
+ type->sectrac + sec) * (1 << (type->secsize - 2));
+ block += (fd->sc_part == SEC_P01) ? 1 : 0;
+ if (block != fd->sc_blkno) {
+ printf("fdcintr: block %d != blkno %" PRId64
+ "\n",
+ block, fd->sc_blkno);
#ifdef DDB
- Debugger();
+ Debugger();
#endif
- }
+ }
}
#endif
if ((read = bp->b_flags & B_READ)) {
@@ -1310,7 +1317,7 @@ loop:
case SEEKCOMPLETE:
/* Make sure seek really happened */
DPRINTF(("fdcintr: SEEKCOMPLETE: FDC status = %x\n",
- bus_space_read_1(fdc->sc_iot, fdc->sc_ioh, fdsts)));
+ bus_space_read_1(fdc->sc_iot, fdc->sc_ioh, fdsts)));
out_fdc(iot, ioh, NE7CMD_SENSEI);
tmp = fdcresult(fdc);
if ((st0 & 0xf8) == 0xc0) {
@@ -1318,8 +1325,8 @@ loop:
fdc->sc_state = DORECAL;
goto loop;
} else if (tmp != 2 ||
- (st0 & 0xf8) != 0x20 ||
- cyl != bp->b_cylinder) {
+ (st0 & 0xf8) != 0x20 ||
+ cyl != bp->b_cylinder) {
#ifdef FDDEBUG
fdcstatus(fd->sc_dev, 2, "seek failed");
#endif
@@ -1347,7 +1354,7 @@ loop:
isa_dmaabort(fdc->sc_drq);
#endif
fdcstatus(fd->sc_dev, tmp, bp->b_flags & B_READ ?
- "read failed" : "write failed");
+ "read failed" : "write failed");
printf("blkno %" PRId64 " nblks %d\n",
fd->sc_blkno, fd->sc_nblks);
fdcretry(fdc);
@@ -1370,8 +1377,8 @@ loop:
DPRINTF(("fd->sc_bcount = %d\n", fd->sc_bcount));
if (fd->sc_bcount > 0) {
bp->b_cylinder = fd->sc_blkno
- / (fd->sc_type->seccyl
- * (1 << (fd->sc_type->secsize - 2)));
+ / (fd->sc_type->seccyl
+ * (1 << (fd->sc_type->secsize - 2)));
goto doseek;
}
fdfinish(fd, bp);
@@ -1386,7 +1393,7 @@ loop:
isa_dmaabort(fdc->sc_drq);
#endif
fdcstatus(fd->sc_dev, 7, bp->b_flags & B_READ ?
- "read failed" : "write failed");
+ "read failed" : "write failed");
printf("blkno %" PRId64 " nblks %d\n",
fd->sc_blkno, fd->sc_nblks);
fdcretry(fdc);
@@ -1410,7 +1417,7 @@ loop:
/* clear the controller output buffer */
for (i = 0; i < 4; i++) {
out_fdc(iot, ioh, NE7CMD_SENSEI);
- (void) fdcresult(fdc);
+ (void)fdcresult(fdc);
}
/* fall through */
@@ -1496,7 +1503,9 @@ fdcretry(struct fdc_softc *fdc)
fdc->sc_state = SEEKCOMPLETE;
break;
- case 1: case 2: case 3:
+ case 1:
+ case 2:
+ case 3:
/* didn't work; try recalibrating */
fdc->sc_state = DORECAL;
break;
@@ -1508,7 +1517,7 @@ fdcretry(struct fdc_softc *fdc)
default:
diskerr(bp, "fd", "hard error", LOG_PRINTF,
- fd->sc_skip, (struct disklabel *)NULL);
+ fd->sc_skip, (struct disklabel *)NULL);
fdcpstatus(7, fdc);
bp->b_error = EIO;
@@ -1531,8 +1540,8 @@ fdioctl(dev_t dev, u_long cmd, void *add
case DIOCGDINFO:
DPRINTF(("DIOCGDINFO\n"));
#if 1
- *(struct disklabel *)addr = *(fd->sc_dk.dk_label);
- return(0);
+ *(struct disklabel *)addr = *fd->sc_dk.dk_label;
+ return 0;
#else
memset(&buffer, 0, sizeof(buffer));
@@ -1552,7 +1561,7 @@ fdioctl(dev_t dev, u_long cmd, void *add
((struct partinfo *)addr)->disklab = fd->sc_dk.dk_label;
((struct partinfo *)addr)->part =
&fd->sc_dk.dk_label->d_partitions[part];
- return(0);
+ return 0;
case DIOCWLABEL:
DPRINTF(("DIOCWLABEL\n"));
@@ -1567,7 +1576,7 @@ fdioctl(dev_t dev, u_long cmd, void *add
return EBADF;
error = setdisklabel(&buffer, (struct disklabel *)addr,
- 0, NULL);
+ 0, NULL);
if (error)
return error;
@@ -1590,7 +1599,7 @@ fdioctl(dev_t dev, u_long cmd, void *add
if ((fd->sc_dk.dk_openmask & ~(1 << part)) != 0 ||
fd->sc_dk.dk_bopenmask + fd->sc_dk.dk_copenmask !=
fd->sc_dk.dk_openmask) {
- return (EBUSY);
+ return EBUSY;
}
}
/* FALLTHROUGH */
@@ -1611,8 +1620,8 @@ fdioctl(dev_t dev, u_long cmd, void *add
void
fd_do_eject(struct fdc_softc *fdc, int unit)
{
- bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout,
- 0x20 | ( 1 << unit));
+
+ bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0x20 | (1 << unit));
DELAY(1); /* XXX */
bus_space_write_1(fdc->sc_iot, fdc->sc_ioh, fdout, 0x20);
}
@@ -1656,7 +1665,7 @@ fdgetdisklabel(struct fd_softc *sc, dev_
lp->d_partitions[part].p_fsize = 1024;
lp->d_partitions[part].p_frag = 8;
- return(0);
+ return 0;
}
/*