summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-02-22 09:32:57 +0000
committerphk <phk@FreeBSD.org>2003-02-22 09:32:57 +0000
commitb2526cd2251743e790317b57ac7d03cb832dfb8b (patch)
treeb6a41b5cd2d996282774d6ec1c08a1b0cb7e3a16
parentbefb0ff113682be7457ade6d3300be70bc2516f4 (diff)
downloadFreeBSD-src-b2526cd2251743e790317b57ac7d03cb832dfb8b.zip
FreeBSD-src-b2526cd2251743e790317b57ac7d03cb832dfb8b.tar.gz
NO_GEOM cleanup:
Move to "struct disk *" centric use of disk_* API. Remove NOOP ioctl, spl*() and some debug printfs.
-rw-r--r--sys/contrib/dev/fla/fla.c84
1 files changed, 16 insertions, 68 deletions
diff --git a/sys/contrib/dev/fla/fla.c b/sys/contrib/dev/fla/fla.c
index dda7f5b..62949b5 100644
--- a/sys/contrib/dev/fla/fla.c
+++ b/sys/contrib/dev/fla/fla.c
@@ -11,6 +11,7 @@
*/
#include <sys/param.h>
+#include <sys/stdint.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
#include <sys/kernel.h>
@@ -35,33 +36,6 @@
static MALLOC_DEFINE(M_FLA, "fla driver", "fla driver storage");
-static int fla_debug = 0;
-SYSCTL_INT(_debug, OID_AUTO, fladebug, CTLFLAG_RW, &fla_debug, 0, "");
-
-#define CDEV_MAJOR 102
-
-static d_strategy_t flastrategy;
-static d_open_t flaopen;
-static d_close_t flaclose;
-static d_ioctl_t flaioctl;
-
-static struct cdevsw fla_cdevsw = {
- /* open */ flaopen,
- /* close */ flaclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ flaioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ flastrategy,
- /* name */ "fla",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
-};
-static struct cdevsw fladisk_cdevsw;
-
void *
doc2k_malloc(int bytes)
{
@@ -112,17 +86,13 @@ static struct fla_s {
} softc[8];
static int
-flaopen(dev_t dev, int flag, int fmt, struct thread *td)
+flaopen(struct disk *dp)
{
struct fla_s *sc;
int error;
u_int spu, ncyl, nt, ns;
- if (fla_debug)
- printf("flaopen(%s %x %x %p)\n",
- devtoname(dev), flag, fmt, td);
-
- sc = dev->si_drv1;
+ sc = dp->d_drv1;
error = doc2k_open(sc->unit);
@@ -141,16 +111,12 @@ flaopen(dev_t dev, int flag, int fmt, struct thread *td)
}
static int
-flaclose(dev_t dev, int flags, int fmt, struct thread *td)
+flaclose(struct disk *dp)
{
int error;
struct fla_s *sc;
- if (fla_debug)
- printf("flaclose(%s %x %x %p)\n",
- devtoname(dev), flags, fmt, td);
-
- sc = dev->si_drv1;
+ sc = dp->d_drv1;
error = doc2k_close(sc->unit);
if (error) {
@@ -160,39 +126,19 @@ flaclose(dev_t dev, int flags, int fmt, struct thread *td)
return (0);
}
-static int
-flaioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
-{
-
- if (fla_debug)
- printf("flaioctl(%s %lx %p %x %p)\n",
- devtoname(dev), cmd, addr, flags, td);
-
- return (ENOIOCTL);
-}
-
static void
flastrategy(struct bio *bp)
{
int unit, error;
- int s;
struct fla_s *sc;
enum doc2k_work what;
- if (fla_debug > 1)
- printf("flastrategy(%p) %s %x, %lld, %ld, %p)\n",
- bp, devtoname(bp->bio_dev), bp->bio_flags,
- (long long)bp->bio_blkno,
- bp->bio_bcount / DEV_BSIZE, bp->bio_data);
-
- sc = bp->bio_dev->si_drv1;
+ sc = bp->bio_disk->d_drv1;
- s = splbio();
bioqdisksort(&sc->bio_queue, bp);
if (sc->busy) {
- splx(s);
return;
}
@@ -202,7 +148,6 @@ flastrategy(struct bio *bp)
bp = bioq_first(&sc->bio_queue);
if (bp)
bioq_remove(&sc->bio_queue, bp);
- splx(s);
if (!bp)
break;
@@ -224,10 +169,10 @@ flastrategy(struct bio *bp)
ENTER();
- if (fla_debug > 1 || error) {
- printf("fla%d: %d = rwe(%p, %d, %d, %lld, %ld, %p)\n",
+ if (error) {
+ printf("fla%d: %d = rwe(%p, %d, %d, %jd, %ld, %p)\n",
unit, error, bp, unit, what,
- (long long)bp->bio_pblkno,
+ (intmax_t)bp->bio_pblkno,
bp->bio_bcount / DEV_BSIZE, bp->bio_data);
}
if (error) {
@@ -238,7 +183,6 @@ flastrategy(struct bio *bp)
}
biofinish(bp, &sc->stats, 0);
- s = splbio();
}
sc->busy = 0;
return;
@@ -320,10 +264,14 @@ flaattach (device_t dev)
DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER,
DEVSTAT_PRIORITY_DISK);
- sc->disk.d_flags |= DISKFLAG_CANDELETE;
- sc->dev = disk_create(unit, &sc->disk, 0, &fla_cdevsw, &fladisk_cdevsw);
- sc->dev->si_drv1 = sc;
+ sc->disk.d_open = flaopen;
+ sc->disk.d_close = flaclose;
+ sc->disk.d_strategy = flastrategy;
+ sc->disk.d_drv1 = sc;
+ sc->disk.d_name = "fla";
+ sc->disk.d_maxsize = MAXPHYS;
sc->unit = unit;
+ disk_create(unit, &sc->disk, DISKFLAG_CANDELETE, NULL, NULL);
return (0);
}
OpenPOWER on IntegriCloud