use device_lookup_private to get softc
This commit is contained in:
parent
c3b5ec7f50
commit
1d9f25d95a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: asc.c,v 1.51 2007/10/17 19:55:16 garbled Exp $ */
|
||||
/* $NetBSD: asc.c,v 1.52 2008/06/13 11:36:11 cegger Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Scott Reynolds
|
||||
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: asc.c,v 1.51 2007/10/17 19:55:16 garbled Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: asc.c,v 1.52 2008/06/13 11:36:11 cegger Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
|
@ -212,11 +212,9 @@ int
|
|||
ascopen(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
{
|
||||
struct asc_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = ASCUNIT(dev);
|
||||
sc = asc_cd.cd_devs[unit];
|
||||
if (unit >= asc_cd.cd_ndevs)
|
||||
sc = device_lookup_private(&asc_cd, ASCUNIT(dev));
|
||||
if (sc == NULL)
|
||||
return (ENXIO);
|
||||
if (sc->sc_open)
|
||||
return (EBUSY);
|
||||
|
@ -230,7 +228,7 @@ ascclose(dev_t dev, int flag, int mode, struct lwp *l)
|
|||
{
|
||||
struct asc_softc *sc;
|
||||
|
||||
sc = asc_cd.cd_devs[ASCUNIT(dev)];
|
||||
sc = device_lookup_private(&asc_cd, ASCUNIT(dev));
|
||||
sc->sc_open = 0;
|
||||
|
||||
return (0);
|
||||
|
@ -255,7 +253,7 @@ ascioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
|
|||
int error;
|
||||
int unit = ASCUNIT(dev);
|
||||
|
||||
sc = asc_cd.cd_devs[unit];
|
||||
sc = device_lookup_private(&asc_cd, ASCUNIT(dev));
|
||||
error = 0;
|
||||
|
||||
switch (cmd) {
|
||||
|
@ -269,11 +267,10 @@ ascioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
|
|||
paddr_t
|
||||
ascmmap(dev_t dev, off_t off, int prot)
|
||||
{
|
||||
int unit = ASCUNIT(dev);
|
||||
struct asc_softc *sc;
|
||||
paddr_t pa;
|
||||
|
||||
sc = asc_cd.cd_devs[unit];
|
||||
sc = device_lookup_private(&asc_cd, ASCUNIT(dev));
|
||||
if ((u_int)off < MAC68K_ASC_LEN) {
|
||||
(void) pmap_extract(pmap_kernel(), (vaddr_t)sc->sc_handle.base,
|
||||
&pa);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iwm_fd.c,v 1.41 2008/05/26 17:58:37 hauke Exp $ */
|
||||
/* $NetBSD: iwm_fd.c,v 1.42 2008/06/13 11:36:11 cegger Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998 Hauke Fath. All rights reserved.
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.41 2008/05/26 17:58:37 hauke Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: iwm_fd.c,v 1.42 2008/06/13 11:36:11 cegger Exp $");
|
||||
|
||||
#ifdef _LKM
|
||||
#define IWMCF_DRIVE 0
|
||||
|
@ -641,7 +641,7 @@ fdopen(dev_t dev, int flags, int devType, struct lwp *l)
|
|||
int fdType, fdUnit;
|
||||
int ierr, err;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm;
|
||||
#endif
|
||||
info = NULL; /* XXX shut up egcs */
|
||||
fd = NULL; /* XXX shut up gcc3 */
|
||||
|
@ -652,6 +652,10 @@ fdopen(dev_t dev, int flags, int devType, struct lwp *l)
|
|||
*/
|
||||
fdType = minor(dev) % MAXPARTITIONS;
|
||||
fdUnit = minor(dev) / MAXPARTITIONS;
|
||||
|
||||
#ifndef _LKM
|
||||
iwm = device_lookup_private(&iwm_cd, fdUnit);
|
||||
#endif
|
||||
if (TRACE_OPEN)
|
||||
printf("iwm: Open drive %d", fdUnit);
|
||||
|
||||
|
@ -775,13 +779,17 @@ fdclose(dev_t dev, int flags, int devType, struct lwp *l)
|
|||
fd_softc_t *fd;
|
||||
int partitionMask, fdUnit, fdType;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm;
|
||||
#endif
|
||||
|
||||
if (TRACE_CLOSE)
|
||||
printf("iwm: Closing driver.");
|
||||
fdUnit = minor(dev) / MAXPARTITIONS;
|
||||
fdType = minor(dev) % MAXPARTITIONS;
|
||||
|
||||
#ifndef _LKM
|
||||
iwm = device_lookup_private(&iwm_cd, fdUnit);
|
||||
#endif
|
||||
fd = iwm->fd[fdUnit];
|
||||
/* release cylinder cache memory */
|
||||
if (fd->cbuf != NULL)
|
||||
|
@ -819,7 +827,7 @@ fdioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
|
|||
int result, fdUnit, fdType;
|
||||
fd_softc_t *fd;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm;
|
||||
#endif
|
||||
|
||||
if (TRACE_IOCTL)
|
||||
|
@ -835,6 +843,11 @@ fdioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
|
|||
}
|
||||
return ENXIO;
|
||||
}
|
||||
#ifndef _LKM
|
||||
iwm = device_lookup_private(&iwm_cd, fdUnit);
|
||||
if (iwm == NULL)
|
||||
return ENXIO;
|
||||
#endif
|
||||
fd = iwm->fd[fdUnit];
|
||||
result = 0;
|
||||
|
||||
|
@ -982,7 +995,7 @@ fdstrategy(struct buf *bp)
|
|||
diskPosition_t physDiskLoc;
|
||||
fd_softc_t *fd;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm;
|
||||
#endif
|
||||
|
||||
err = 0;
|
||||
|
@ -991,6 +1004,9 @@ fdstrategy(struct buf *bp)
|
|||
fd = NULL; /* XXX shut up gcc3 */
|
||||
|
||||
fdUnit = minor(bp->b_dev) / MAXPARTITIONS;
|
||||
#ifndef _LKM
|
||||
iwm = device_lookup_private(&iwm_cd, fdUnit);
|
||||
#endif
|
||||
if (TRACE_STRAT) {
|
||||
printf("iwm: fdstrategy()...\n");
|
||||
printf(" struct buf is at %p\n", bp);
|
||||
|
@ -1275,7 +1291,7 @@ fdstart_Read(fd_softc_t *fd)
|
|||
diskPosition_t *pos;
|
||||
sectorHdr_t *shdr;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm = device_lookup_private(&iwm_cd, 0); /* XXX */
|
||||
#endif
|
||||
|
||||
/* Initialize retry counters */
|
||||
|
@ -1391,7 +1407,7 @@ fdstart_Flush(fd_softc_t *fd)
|
|||
diskPosition_t *pos;
|
||||
sectorHdr_t *shdr;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm = device_lookup_private(&iwm_cd, 0); /* XXX */
|
||||
#endif
|
||||
dcnt = 0;
|
||||
pos = &fd->pos;
|
||||
|
@ -1521,7 +1537,7 @@ fdstart_IOErr(fd_softc_t *fd)
|
|||
{
|
||||
int state;
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm = device_lookup_private(&iwm_cd, 0); /* XXX */
|
||||
#endif
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
|
@ -1887,7 +1903,7 @@ seek(fd_softc_t *fd, int style)
|
|||
sectorHdr_t hdr;
|
||||
char action[32];
|
||||
#ifndef _LKM
|
||||
iwm_softc_t *iwm = iwm_cd.cd_devs[0];
|
||||
iwm_softc_t *iwm = device_lookup_private(&iwm_cd, 0); /* XXX */
|
||||
#endif
|
||||
|
||||
const char *stateDesc[] = {
|
||||
|
|
Loading…
Reference in New Issue