use device_lookup_private to get softc
This commit is contained in:
parent
1c5d6ce502
commit
3bde75a1bc
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lpt_mvme.c,v 1.13 2008/04/28 20:23:54 martin Exp $ */
|
||||
/* $NetBSD: lpt_mvme.c,v 1.14 2008/06/12 22:45:46 cegger Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -84,7 +84,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lpt_mvme.c,v 1.13 2008/04/28 20:23:54 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lpt_mvme.c,v 1.14 2008/06/12 22:45:46 cegger Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -148,24 +148,16 @@ lpt_attach_subr(sc)
|
|||
* Reset the printer, then wait until it's selected and not busy.
|
||||
*/
|
||||
int
|
||||
lptopen(dev, flag, mode, l)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
int mode;
|
||||
struct lwp *l;
|
||||
lptopen(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
{
|
||||
int unit;
|
||||
u_char flags;
|
||||
struct lpt_softc *sc;
|
||||
int error;
|
||||
int spin;
|
||||
|
||||
unit = LPTUNIT(dev);
|
||||
flags = LPTFLAGS(dev);
|
||||
|
||||
if (unit >= lpt_cd.cd_ndevs)
|
||||
return (ENXIO);
|
||||
sc = device_private(lpt_cd.cd_devs[unit]);
|
||||
sc = device_lookup_private(&lpt_cd, LPTUNIT(dev));
|
||||
if (!sc)
|
||||
return (ENXIO);
|
||||
|
||||
|
@ -240,17 +232,11 @@ lpt_wakeup(arg)
|
|||
* Close the device, and free the local line buffer.
|
||||
*/
|
||||
int
|
||||
lptclose(dev, flag, mode, l)
|
||||
dev_t dev;
|
||||
int flag;
|
||||
int mode;
|
||||
struct lwp *l;
|
||||
lptclose(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
{
|
||||
struct lpt_softc *sc;
|
||||
int unit;
|
||||
|
||||
unit = LPTUNIT(dev);
|
||||
sc = device_private(lpt_cd.cd_devs[unit]);
|
||||
sc = device_lookup_private(&lpt_cd, LPTUNIT(dev));
|
||||
|
||||
if (sc->sc_count)
|
||||
(void) pushbytes(sc);
|
||||
|
@ -326,16 +312,13 @@ pushbytes(sc)
|
|||
* chars moved to the output queue.
|
||||
*/
|
||||
int
|
||||
lptwrite(dev, uio, flags)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flags;
|
||||
lptwrite(dev_t dev, struct uio *uio, int flags)
|
||||
{
|
||||
struct lpt_softc *sc;
|
||||
size_t n;
|
||||
int error;
|
||||
|
||||
sc = device_private(lpt_cd.cd_devs[LPTUNIT(dev)]);
|
||||
sc = device_lookup_private(&lpt_cd, LPTUNIT(dev));
|
||||
error = 0;
|
||||
|
||||
while ((n = min(LPT_BSIZE, uio->uio_resid)) != 0) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_devar.h,v 1.49 2008/05/22 01:27:32 dyoung Exp $ */
|
||||
/* $NetBSD: if_devar.h,v 1.50 2008/06/12 22:44:47 cegger Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
|
||||
|
@ -974,7 +974,7 @@ NETISR_SET(NETISR_DE, tulip_softintr);
|
|||
#define ifnet_ret_t void
|
||||
typedef u_long ioctl_cmd_t;
|
||||
extern struct cfdriver de_cd;
|
||||
#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) de_cd.cd_devs[unit])
|
||||
#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *)device_lookup_private(&de_cd,unit))
|
||||
#define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
|
||||
#define tulip_unit tulip_dev.dv_unit
|
||||
#define tulip_xname tulip_if.if_xname
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_fpa.c,v 1.49 2008/04/10 19:13:36 cegger Exp $ */
|
||||
/* $NetBSD: if_fpa.c,v 1.50 2008/06/12 22:44:47 cegger Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_fpa.c,v 1.49 2008/04/10 19:13:36 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_fpa.c,v 1.50 2008/06/12 22:44:47 cegger Exp $");
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include "opt_inet.h"
|
||||
|
@ -125,11 +125,11 @@ static void pdq_pci_shutdown(int howto, void *sc);
|
|||
|
||||
#elif defined(__bsdi__)
|
||||
extern struct cfdriver fpacd;
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpacd.cd_devs[unit])
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)device_lookup_private(&fpa_cd, unit))
|
||||
|
||||
#elif defined(__NetBSD__)
|
||||
extern struct cfdriver fpa_cd;
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpa_cd.cd_devs[unit])
|
||||
#define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)device_lookup_private(&fpa_cd, unit))
|
||||
#define pdq_pci_ifwatchdog NULL
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_lmc.c,v 1.41 2008/04/10 19:13:37 cegger Exp $ */
|
||||
/* $NetBSD: if_lmc.c,v 1.42 2008/06/12 22:44:47 cegger Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002-2006 David Boggs. <boggs@boggs.palo-alto.ca.us>
|
||||
|
@ -142,7 +142,7 @@
|
|||
|
||||
#if defined(__NetBSD__)
|
||||
# include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.41 2008/04/10 19:13:37 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.42 2008/06/12 22:44:47 cegger Exp $");
|
||||
# include <sys/param.h> /* OS version */
|
||||
/* -DLKM is passed on the compiler command line */
|
||||
# include "opt_inet.h" /* INET6, INET */
|
||||
|
@ -7420,10 +7420,10 @@ int if_lmc_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
|
|||
{ /* for each pci bus... */
|
||||
int devnum, maxdevs;
|
||||
struct pci_attach_args pa;
|
||||
struct device *parent = pci_cd.cd_devs[i];
|
||||
device_t parent = device_lookup(&pci_cd, i);
|
||||
/* This is ugly: only way to get pci_chipset_tag. */
|
||||
struct pci_sc { struct device dev; pci_chipset_tag_t pc; };
|
||||
struct pci_sc *pci_sc = pci_cd.cd_devs[i];
|
||||
struct pci_sc *pci_sc = device_lookup_private(&pci_cd, i);
|
||||
|
||||
if (parent == NULL) continue; /* no pci bus */
|
||||
pa.pa_pc = pci_sc->pc;
|
||||
|
@ -7459,7 +7459,7 @@ int if_lmc_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
|
|||
{
|
||||
for (i=lmc_cd.cd_ndevs-1; i>=0; i--)
|
||||
{
|
||||
struct device *dev = lmc_cd.cd_devs[i];
|
||||
device_t dev = device_lookup(&lmc_cd, i);
|
||||
if (dev == NULL) continue;
|
||||
if ((error = config_detach(dev, 0)))
|
||||
printf("%s: config_detach(): error %d\n",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* $NetBSD: if_lmc.h,v 1.11 2008/04/10 19:13:37 cegger Exp $
|
||||
* $NetBSD: if_lmc.h,v 1.12 2008/06/12 22:44:47 cegger Exp $
|
||||
*
|
||||
* Copyright (c) 2002-2006 David Boggs. (boggs@boggs.palo-alto.ca.us)
|
||||
* All rights reserved.
|
||||
|
@ -1012,7 +1012,7 @@ static __inline int test_and_set(volatile int *ptr, int val)
|
|||
# if _BSDI_VERSION <= 199910
|
||||
extern struct cfdriver lmccd;
|
||||
# undef IFP2SC
|
||||
# define UNIT2SC(unit) ((softc_t *)lmccd.cd_devs[unit])
|
||||
# define UNIT2SC(unit) ((softc_t *)device_lookup_private(&lmccd, unit))
|
||||
# define IFP2SC(ifp) (UNIT2SC((ifp)->if_unit))
|
||||
# endif
|
||||
#endif /* __bsdi__ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: machfb.c,v 1.52 2008/04/10 19:13:37 cegger Exp $ */
|
||||
/* $NetBSD: machfb.c,v 1.53 2008/06/12 22:44:47 cegger Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Bang Jun-Young
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0,
|
||||
"$NetBSD: machfb.c,v 1.52 2008/04/10 19:13:37 cegger Exp $");
|
||||
"$NetBSD: machfb.c,v 1.53 2008/06/12 22:44:47 cegger Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1806,23 +1806,22 @@ int
|
|||
machfb_fbopen(dev_t dev, int flags, int mode, struct lwp *l)
|
||||
{
|
||||
struct mach64_softc *sc;
|
||||
int unit = minor(dev);
|
||||
|
||||
sc = machfb_cd.cd_devs[unit];
|
||||
sc = device_lookup_private(&machfb_cd, minor(dev));
|
||||
if (sc == NULL)
|
||||
return ENXIO;
|
||||
sc->sc_locked = 1;
|
||||
|
||||
#ifdef DEBUG_MACHFB
|
||||
printf("machfb_fbopen(%d)\n", unit);
|
||||
printf("machfb_fbopen(%d)\n", minor(dev));
|
||||
#endif
|
||||
if (unit > machfb_cd.cd_ndevs || machfb_cd.cd_devs[unit] == NULL)
|
||||
return ENXIO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
machfb_fbclose(dev_t dev, int flags, int mode, struct lwp *l)
|
||||
{
|
||||
struct mach64_softc *sc = machfb_cd.cd_devs[minor(dev)];
|
||||
struct mach64_softc *sc = device_lookup_private(&machfb_cd, minor(dev));
|
||||
|
||||
#ifdef DEBUG_MACHFB
|
||||
printf("machfb_fbclose()\n");
|
||||
|
@ -1836,7 +1835,7 @@ machfb_fbclose(dev_t dev, int flags, int mode, struct lwp *l)
|
|||
int
|
||||
machfb_fbioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
|
||||
{
|
||||
struct mach64_softc *sc = machfb_cd.cd_devs[minor(dev)];
|
||||
struct mach64_softc *sc = device_lookup_private(&machfb_cd, minor(dev));
|
||||
|
||||
#ifdef DEBUG_MACHFB
|
||||
printf("machfb_fbioctl(%d, %lx)\n", minor(dev), cmd);
|
||||
|
@ -1936,7 +1935,7 @@ machfb_fbioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
|
|||
paddr_t
|
||||
machfb_fbmmap(dev_t dev, off_t off, int prot)
|
||||
{
|
||||
struct mach64_softc *sc = machfb_cd.cd_devs[minor(dev)];
|
||||
struct mach64_softc *sc = device_lookup_private(&machfb_cd, minor(dev));
|
||||
|
||||
if (sc != NULL)
|
||||
return mach64_mmap(&sc->vd, NULL, off, prot);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pci.c,v 1.117 2008/05/05 20:14:30 dyoung Exp $ */
|
||||
/* $NetBSD: pci.c,v 1.118 2008/06/12 22:44:47 cegger Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997, 1998
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.117 2008/05/05 20:14:30 dyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.118 2008/06/12 22:44:47 cegger Exp $");
|
||||
|
||||
#include "opt_pci.h"
|
||||
|
||||
|
@ -463,7 +463,7 @@ pci_find_device(struct pci_attach_args *pa,
|
|||
};
|
||||
|
||||
for (i = 0; i < pci_cd.cd_ndevs; i++) {
|
||||
pcidev = pci_cd.cd_devs[i];
|
||||
pcidev = device_lookup(&pci_cd, i);
|
||||
if (pcidev != NULL &&
|
||||
pci_enumerate_bus(device_private(pcidev), wildcard,
|
||||
match, pa) != 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sec.c,v 1.10 2008/04/05 20:08:52 cegger Exp $ */
|
||||
/* $NetBSD: sec.c,v 1.11 2008/06/12 22:46:10 cegger Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001, 2006 Ben Harris
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sec.c,v 1.10 2008/04/05 20:08:52 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sec.c,v 1.11 2008/06/12 22:46:10 cegger Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
|
@ -521,9 +521,12 @@ extern struct cfdriver sec_cd;
|
|||
void sec_dumpall(void)
|
||||
{
|
||||
int i;
|
||||
struct sec_softc *sc;
|
||||
|
||||
for (i = 0; i < sec_cd.cd_ndevs; ++i)
|
||||
if (sec_cd.cd_devs[i])
|
||||
sec_dumpdma(sec_cd.cd_devs[i]);
|
||||
for (i = 0; i < sec_cd.cd_ndevs; ++i) {
|
||||
sc = device_lookup_private(&sec_cd, i);
|
||||
if (sc != NULL)
|
||||
sec_dumpdma(sc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue