Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/atari/dev Misc KNF.
details: https://anonhg.NetBSD.org/src/rev/00a72a6ad0d5
branches: trunk
changeset: 753705:00a72a6ad0d5
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Wed Apr 07 13:53:05 2010 +0000
description:
Misc KNF.
diffstat:
sys/arch/atari/dev/fd.c | 676 ++++++++++++++++++++++++-----------------------
1 files changed, 345 insertions(+), 331 deletions(-)
diffs (truncated from 1193 to 300 lines):
diff -r ac6b24ab3e03 -r 00a72a6ad0d5 sys/arch/atari/dev/fd.c
--- a/sys/arch/atari/dev/fd.c Wed Apr 07 13:14:23 2010 +0000
+++ b/sys/arch/atari/dev/fd.c Wed Apr 07 13:53:05 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fd.c,v 1.74 2010/04/07 13:14:23 tsutsui Exp $ */
+/* $NetBSD: fd.c,v 1.75 2010/04/07 13:53:05 tsutsui Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman.
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.74 2010/04/07 13:14:23 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.75 2010/04/07 13:53:05 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,6 +72,8 @@
#include <atari/dev/ym2149reg.h>
#include <atari/dev/fdreg.h>
+#include "ioconf.h"
+
/*
* Be verbose for debugging
*/
@@ -121,9 +123,9 @@
static short nopens = 0; /* Number of opens executed */
static short fd_state = FLP_IDLE; /* Current driver state */
-static int lock_stat= 0; /* DMA locking status */
+static int lock_stat = 0; /* DMA locking status */
static short fd_cmd = 0; /* command being executed */
-static const char *fd_error= NULL; /* error from fd_xfer_ok() */
+static const char *fd_error = NULL; /* error from fd_xfer_ok() */
/*
* Private per device data
@@ -142,11 +144,11 @@
short flags; /* misc flags */
short part; /* Current open partition */
int sector; /* logical sector for I/O */
- char *io_data; /* KVA for data transfer */
+ uint8_t *io_data; /* KVA for data transfer */
int io_bytes; /* bytes left for I/O */
int io_dir; /* B_READ/B_WRITE */
int errcnt; /* current error count */
- u_char *bounceb; /* Bounce buffer */
+ uint8_t *bounceb; /* Bounce buffer */
};
@@ -217,26 +219,34 @@
static void fddeselect(void);
static void fdmoff(struct fd_softc *);
-static inline u_char read_fdreg(u_short);
+static u_short rd_cfg_switch(void);
+
+static inline uint8_t read_fdreg(u_short);
static inline void write_fdreg(u_short, u_short);
-static inline u_char read_dmastat(void);
+static inline uint8_t read_dmastat(void);
-static inline u_char read_fdreg(u_short regno)
+static inline
+uint8_t read_fdreg(u_short regno)
{
+
DMA->dma_mode = regno;
- return(DMA->dma_data);
+ return DMA->dma_data;
}
-static inline void write_fdreg(u_short regno, u_short val)
+static inline
+void write_fdreg(u_short regno, u_short val)
{
+
DMA->dma_mode = regno;
DMA->dma_data = val;
}
-static inline u_char read_dmastat(void)
+static inline
+uint8_t read_dmastat(void)
{
+
DMA->dma_mode = FDC_CS | DMA_SCREG;
- return(DMA->dma_stat);
+ return DMA->dma_stat;
}
/*
@@ -246,10 +256,11 @@
* Note: This location _must_ be read as an u_short. Failure to do so
* will return garbage!
*/
-static u_short rd_cfg_switch(void);
-static u_short rd_cfg_switch(void)
+static u_short
+rd_cfg_switch(void)
{
- return(*((volatile u_short *)AD_CFG_SWITCH));
+
+ return *(volatile u_short *)AD_CFG_SWITCH;
}
/*
@@ -261,8 +272,6 @@
/*
* Autoconfig stuff....
*/
-extern struct cfdriver fd_cd;
-
static int fdcmatch(device_t, cfdata_t, void *);
static int fdcprint(void *, const char *);
static void fdcattach(device_t, device_t, void *);
@@ -282,25 +291,25 @@
static int
fdcmatch(device_t parent, cfdata_t match, void *aux)
{
- static int fdc_matched = 0;
+ static int fdc_matched = 0;
/* Match only once */
- if(strcmp("fdc", aux) || fdc_matched)
- return(0);
+ if (strcmp("fdc", aux) || fdc_matched)
+ return 0;
fdc_matched = 1;
- return(1);
+ return 1;
}
static void
fdcattach(device_t parent, device_t self, void *aux)
{
struct fd_softc fdsoftc;
- int i, nfound, first_found;
+ int i, nfound, first_found;
nfound = first_found = 0;
printf("\n");
fddeselect();
- for(i = 0; i < NR_DRIVES; i++) {
+ for (i = 0; i < NR_DRIVES; i++) {
/*
* Test if unit is present
@@ -308,18 +317,18 @@
fdsoftc.unit = i;
fdsoftc.flags = 0;
st_dmagrab((dma_farg)fdcint, (dma_farg)fdtestdrv, &fdsoftc,
- &lock_stat, 0);
+ &lock_stat, 0);
st_dmafree(&fdsoftc, &lock_stat);
- if(!(fdsoftc.flags & FLPF_NOTRESP)) {
- if(!nfound)
+ if ((fdsoftc.flags & FLPF_NOTRESP) == 0) {
+ if (nfound == 0)
first_found = i;
nfound++;
- config_found(self, (void*)i, fdcprint);
+ config_found(self, (void *)i, fdcprint);
}
}
- if(nfound) {
+ if (nfound != 0) {
struct fd_softc *fdsc =
device_lookup_private(&fd_cd, first_found);
@@ -335,7 +344,7 @@
* enable disk related interrupts
*/
MFP->mf_ierb |= IB_DINT;
- MFP->mf_iprb = (u_int8_t)~IB_DINT;
+ MFP->mf_iprb = (uint8_t)~IB_DINT;
MFP->mf_imrb |= IB_DINT;
}
}
@@ -343,10 +352,11 @@
static int
fdcprint(void *aux, const char *pnp)
{
+
if (pnp != NULL)
aprint_normal("fd%d at %s:", (int)aux, pnp);
- return(UNCONF);
+ return UNCONF;
}
static int fdmatch(device_t, cfdata_t, void *);
@@ -357,12 +367,11 @@
CFATTACH_DECL_NEW(fd, sizeof(struct fd_softc),
fdmatch, fdattach, NULL, NULL);
-extern struct cfdriver fd_cd;
-
static int
fdmatch(device_t parent, cfdata_t match, void *aux)
{
- return(1);
+
+ return 1;
}
static void
@@ -386,8 +395,8 @@
type = &fdtypes[def_type];
aprint_normal(": %s %d cyl, %d head, %d sec\n", type->descr,
- type->nblocks / (type->nsectors * type->nheads), type->nheads,
- type->nsectors);
+ type->nblocks / (type->nsectors * type->nheads), type->nheads,
+ type->nsectors);
/*
* Initialize and attach the disk structure.
@@ -403,35 +412,33 @@
sc = device_lookup_private(&fd_cd, DISKUNIT(dev));
- if((sc->flags & FLPF_HAVELAB) == 0)
- return(EBADF);
+ if ((sc->flags & FLPF_HAVELAB) == 0)
+ return EBADF;
- switch(cmd) {
- case DIOCSBAD:
- return(EINVAL);
- case DIOCGDINFO:
- *(struct disklabel *)addr = *(sc->dkdev.dk_label);
- return(0);
- case DIOCGPART:
- ((struct partinfo *)addr)->disklab =
- sc->dkdev.dk_label;
- ((struct partinfo *)addr)->part =
- &sc->dkdev.dk_label->d_partitions[RAW_PART];
- return(0);
+ switch (cmd) {
+ case DIOCSBAD:
+ return EINVAL;
+ case DIOCGDINFO:
+ *(struct disklabel *)addr = *(sc->dkdev.dk_label);
+ return 0;
+ case DIOCGPART:
+ ((struct partinfo *)addr)->disklab = sc->dkdev.dk_label;
+ ((struct partinfo *)addr)->part =
+ &sc->dkdev.dk_label->d_partitions[RAW_PART];
+ return 0;
#ifdef notyet /* XXX LWP */
- case DIOCSRETRIES:
- case DIOCSSTEP:
- case DIOCSDINFO:
- case DIOCWDINFO:
- case DIOCWLABEL:
- break;
+ case DIOCSRETRIES:
+ case DIOCSSTEP:
+ case DIOCSDINFO:
+ case DIOCWDINFO:
+ case DIOCWLABEL:
+ break;
#endif /* notyet */
- case DIOCGDEFLABEL:
- fdgetdefaultlabel(sc, (struct disklabel *)addr,
- RAW_PART);
- return(0);
+ case DIOCGDEFLABEL:
+ fdgetdefaultlabel(sc, (struct disklabel *)addr, RAW_PART);
+ return 0;
}
- return(ENOTTY);
+ return ENOTTY;
}
/*
@@ -446,23 +453,23 @@
fdopen(dev_t dev, int flags, int devtype, struct lwp *l)
{
struct fd_softc *sc;
- int sps;
+ int s;
#ifdef FLP_DEBUG
printf("fdopen dev=0x%x\n", dev);
#endif
- if(FLP_TYPE(dev) >= NR_TYPES)
- return(ENXIO);
+ if (FLP_TYPE(dev) >= NR_TYPES)
+ return ENXIO;
- if((sc = device_lookup_private(&fd_cd, DISKUNIT(dev))) == NULL)
- return(ENXIO);
Home |
Main Index |
Thread Index |
Old Index