Use device_parent().

This commit is contained in:
thorpej 2006-03-25 03:44:35 +00:00
parent 6f6a761f7f
commit 5887891a8d
4 changed files with 46 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_plip.c,v 1.9 2005/12/24 23:00:49 perry Exp $ */
/* $NetBSD: if_plip.c,v 1.10 2006/03/25 03:44:35 thorpej Exp $ */
/*-
* Copyright (c) 1997 Poul-Henning Kamp
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.9 2005/12/24 23:00:49 perry Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.10 2006/03/25 03:44:35 thorpej Exp $");
/*
* Parallel port TCP/IP interfaces added. I looked at the driver from
@ -258,7 +258,7 @@ lp_detach(struct device * self, int flags)
{
int error = 0;
struct lp_softc * lp = (struct lp_softc *) self;
struct device * ppbus = self->dv_parent;
struct device * ppbus = device_parent(self);
if(lp->sc_dev_ok) {
if(!(flags & DETACH_QUIET))
@ -348,7 +348,7 @@ static int
lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
{
struct device * dev = ifp->if_softc;
struct device * ppbus = dev->dv_parent;
struct device * ppbus = device_parent(dev);
struct lp_softc * sc = (struct lp_softc *) dev;
struct ifaddr * ifa = (struct ifaddr *)data;
struct ifreq * ifr = (struct ifreq *)data;
@ -539,7 +539,7 @@ static void
lp_intr (void *arg)
{
struct device * dev = (struct device *)arg;
struct device * ppbus = dev->dv_parent;
struct device * ppbus = device_parent(dev);
struct lp_softc * sc = (struct lp_softc *)dev;
struct ifnet * ifp = &sc->sc_if;
struct mbuf *top;
@ -710,7 +710,7 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct rtentry *rt)
{
struct device * dev = ifp->if_softc;
struct device * ppbus = dev->dv_parent;
struct device * ppbus = device_parent(dev);
struct lp_softc * sc = (struct lp_softc *) dev;
ALTQ_DECL(struct altq_pktattr pktattr;)
int err;
@ -773,7 +773,7 @@ lpstart(struct ifnet * ifp)
{
struct lp_softc * lp = ifp->if_softc;
struct device * dev = ifp->if_softc;
struct device * ppbus = dev->dv_parent;
struct device * ppbus = device_parent(dev);
struct mbuf * mm;
struct mbuf * m;
u_char * cp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lpt.c,v 1.15 2005/12/25 18:43:31 rpaulo Exp $ */
/* $NetBSD: lpt.c,v 1.16 2006/03/25 03:44:35 thorpej Exp $ */
/*
* Copyright (c) 1990 William F. Jolitz, TeleMuse
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.15 2005/12/25 18:43:31 rpaulo Exp $");
__KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.16 2006/03/25 03:44:35 thorpej Exp $");
#include "opt_ppbus_lpt.h"
@ -213,9 +213,9 @@ lpt_detach(struct device * self, int flags)
/* Free memory buffers */
if(ppbdev->capabilities & PPBUS_HAS_DMA) {
ppbus_dma_free(self->dv_parent, &(lpt->sc_inbuf),
ppbus_dma_free(device_parent(self), &(lpt->sc_inbuf),
&(lpt->sc_in_baddr), BUFSIZE);
ppbus_dma_free(self->dv_parent, &(lpt->sc_outbuf),
ppbus_dma_free(device_parent(self), &(lpt->sc_outbuf),
&(lpt->sc_out_baddr), BUFSIZE);
} else {
free(lpt->sc_inbuf, M_DEVBUF);
@ -236,7 +236,7 @@ lpt_request_ppbus(struct lpt_softc * lpt, int how)
struct device * dev = (struct device *) lpt;
int error;
error = ppbus_request_bus(dev->dv_parent, dev, how, (hz));
error = ppbus_request_bus(device_parent(dev), dev, how, (hz));
if (!(error)) {
lpt->sc_state |= HAVEBUS;
}
@ -256,7 +256,7 @@ lpt_release_ppbus(struct lpt_softc * lpt, int how)
int error;
if(lpt->sc_state & HAVEBUS) {
error = ppbus_release_bus(dev->dv_parent, dev, how, (hz));
error = ppbus_release_bus(device_parent(dev), dev, how, (hz));
if(!(error))
lpt->sc_state &= ~HAVEBUS;
else
@ -426,7 +426,7 @@ lptopen(dev_t dev_id, int flags, int fmt, struct lwp *l)
lpt = (struct lpt_softc *) dev;
ppbus = dev->dv_parent;
ppbus = device_parent(dev);
ppbus_dev = &(lpt->ppbus_dev);
/* Request the ppbus */
@ -533,13 +533,13 @@ lptread(dev_t dev_id, struct uio *uio, int ioflag)
if(!(sc->sc_state & HAVEBUS)) {
LPT_DPRINTF(("%s(%s): attempt to read using device which does "
"not own the bus(%s).\n", __func__, dev->dv_xname,
dev->dv_parent->dv_xname));
device_parent(dev)->dv_xname));
return (ENODEV);
}
sc->sc_state &= ~INTERRUPTED;
while (uio->uio_resid) {
error = ppbus_read(dev->dv_parent, sc->sc_outbuf,
error = ppbus_read(device_parent(dev), sc->sc_outbuf,
min(BUFSIZE, uio->uio_resid), 0, &len);
/* If error or no more data, stop */
@ -576,7 +576,7 @@ lptwrite(dev_t dev_id, struct uio * uio, int ioflag)
if(!(sc->sc_state & HAVEBUS)) {
LPT_DPRINTF(("%s(%s): attempt to write using device which does "
"not own the bus(%s).\n", __func__, dev->dv_xname,
dev->dv_parent->dv_xname));
device_parent(dev)->dv_xname));
return EINVAL;
}
@ -591,7 +591,7 @@ lptwrite(dev_t dev_id, struct uio * uio, int ioflag)
if (error)
break;
error = ppbus_write(dev->dv_parent, sc->sc_inbuf, n, ioflag,
error = ppbus_write(device_parent(dev), sc->sc_inbuf, n, ioflag,
&cnt);
if (error) {
if (error != EWOULDBLOCK)
@ -618,13 +618,13 @@ lptioctl(dev_t dev_id, u_long cmd, caddr_t data, int flags, struct lwp *l)
if(!(sc->sc_state & HAVEBUS)) {
LPT_DPRINTF(("%s(%s): attempt to perform ioctl on device which "
"does not own the bus(%s).\n", __func__, dev->dv_xname,
dev->dv_parent->dv_xname));
device_parent(dev)->dv_xname));
return EBUSY;
}
switch (cmd) {
case LPTGMODE:
switch (ppbus_get_mode(dev->dv_parent)) {
switch (ppbus_get_mode(device_parent(dev))) {
case PPBUS_COMPATIBLE:
val = mode_standard;
break;
@ -678,7 +678,7 @@ lptioctl(dev_t dev_id, u_long cmd, caddr_t data, int flags, struct lwp *l)
}
if (!error)
error = ppbus_set_mode(dev->dv_parent, val, 0);
error = ppbus_set_mode(device_parent(dev), val, 0);
break;
@ -686,21 +686,21 @@ lptioctl(dev_t dev_id, u_long cmd, caddr_t data, int flags, struct lwp *l)
fl = 0;
/* DMA */
error = ppbus_read_ivar(dev->dv_parent, PPBUS_IVAR_DMA, &val);
error = ppbus_read_ivar(device_parent(dev), PPBUS_IVAR_DMA, &val);
if (error)
break;
if (val)
fl |= LPT_DMA;
/* IEEE mode negotiation */
error = ppbus_read_ivar(dev->dv_parent, PPBUS_IVAR_IEEE, &val);
error = ppbus_read_ivar(device_parent(dev), PPBUS_IVAR_IEEE, &val);
if (error)
break;
if (val)
fl |= LPT_IEEE;
/* interrupts */
error = ppbus_read_ivar(dev->dv_parent, PPBUS_IVAR_INTR, &val);
error = ppbus_read_ivar(device_parent(dev), PPBUS_IVAR_INTR, &val);
if (error)
break;
if (val)
@ -717,19 +717,19 @@ lptioctl(dev_t dev_id, u_long cmd, caddr_t data, int flags, struct lwp *l)
/* DMA */
val = (fl & LPT_DMA);
error = ppbus_write_ivar(dev->dv_parent, PPBUS_IVAR_DMA, &val);
error = ppbus_write_ivar(device_parent(dev), PPBUS_IVAR_DMA, &val);
if (error)
break;
/* IEEE mode negotiation */
val = (fl & LPT_IEEE);
error = ppbus_write_ivar(dev->dv_parent, PPBUS_IVAR_IEEE, &val);
error = ppbus_write_ivar(device_parent(dev), PPBUS_IVAR_IEEE, &val);
if (error)
break;
/* interrupts */
val = (fl & LPT_INTR);
error = ppbus_write_ivar(dev->dv_parent, PPBUS_IVAR_INTR, &val);
error = ppbus_write_ivar(device_parent(dev), PPBUS_IVAR_INTR, &val);
if (error)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ppbus_base.c,v 1.11 2005/12/11 12:23:28 christos Exp $ */
/* $NetBSD: ppbus_base.c,v 1.12 2006/03/25 03:44:35 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 Nicolas Souchu
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ppbus_base.c,v 1.11 2005/12/11 12:23:28 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ppbus_base.c,v 1.12 2006/03/25 03:44:35 thorpej Exp $");
#include "opt_ppbus_1284.h"
#include "opt_ppbus.h"
@ -59,7 +59,7 @@ int
ppbus_io(struct device * dev, int iop, u_char * addr, int cnt, u_char byte)
{
struct ppbus_softc * bus = (struct ppbus_softc *) dev;
return (bus->ppbus_io(dev->dv_parent, iop, addr, cnt, byte));
return (bus->ppbus_io(device_parent(dev), iop, addr, cnt, byte));
}
/* Execute microsequence */
@ -67,7 +67,7 @@ int
ppbus_exec_microseq(struct device * dev, struct ppbus_microseq ** sequence)
{
struct ppbus_softc * bus = (struct ppbus_softc *) dev;
return (bus->ppbus_exec_microseq(dev->dv_parent, sequence));
return (bus->ppbus_exec_microseq(device_parent(dev), sequence));
}
/* Read instance variables of ppbus */
@ -81,7 +81,7 @@ ppbus_read_ivar(struct device * dev, int index, unsigned int * val)
case PPBUS_IVAR_INTR:
case PPBUS_IVAR_EPP_PROTO:
case PPBUS_IVAR_DMA:
return (bus->ppbus_read_ivar(dev->dv_parent, index, val));
return (bus->ppbus_read_ivar(device_parent(dev), index, val));
case PPBUS_IVAR_IEEE:
*val = (bus->sc_use_ieee == PPBUS_ENABLE_IEEE) ? 1 : 0;
@ -104,7 +104,7 @@ ppbus_write_ivar(struct device * dev, int index, unsigned int * val)
case PPBUS_IVAR_INTR:
case PPBUS_IVAR_EPP_PROTO:
case PPBUS_IVAR_DMA:
return (bus->ppbus_write_ivar(dev->dv_parent, index, val));
return (bus->ppbus_write_ivar(device_parent(dev), index, val));
case PPBUS_IVAR_IEEE:
bus->sc_use_ieee = ((*val != 0) ? PPBUS_ENABLE_IEEE :
@ -196,8 +196,8 @@ ppbus_set_mode(struct device * dev, int mode, int options)
if(!error) {
/* Set mode and update mode of ppbus to actual mode */
error = bus->ppbus_setmode(dev->dv_parent, mode);
bus->sc_mode = bus->ppbus_getmode(dev->dv_parent);
error = bus->ppbus_setmode(device_parent(dev), mode);
bus->sc_mode = bus->ppbus_getmode(device_parent(dev));
}
/* Update host state if necessary */
@ -234,7 +234,7 @@ ppbus_write(struct device * dev, char * buf, int len, int how, size_t * cnt)
}
}
return (bus->ppbus_write(bus->sc_dev.dv_parent, buf, len, how, cnt));
return (bus->ppbus_write(device_parent(&bus->sc_dev), buf, len, how, cnt));
}
/* Read charaters from the port */
@ -251,7 +251,7 @@ ppbus_read(struct device * dev, char * buf, int len, int how, size_t * cnt)
}
}
return (bus->ppbus_read(dev->dv_parent, buf, len, how, cnt));
return (bus->ppbus_read(device_parent(dev), buf, len, how, cnt));
}
/* Reset the EPP timeout bit in the status register */
@ -261,7 +261,7 @@ ppbus_reset_epp_timeout(struct device * dev)
struct ppbus_softc * bus = (struct ppbus_softc *) dev;
if(bus->sc_capabilities & PPBUS_HAS_EPP) {
bus->ppbus_reset_epp_timeout(dev->dv_parent);
bus->ppbus_reset_epp_timeout(device_parent(dev));
return 0;
}
else {
@ -276,7 +276,7 @@ ppbus_ecp_sync(struct device * dev)
struct ppbus_softc * bus = (struct ppbus_softc *) dev;
if(bus->sc_capabilities & PPBUS_HAS_ECP) {
bus->ppbus_ecp_sync(dev->dv_parent);
bus->ppbus_ecp_sync(device_parent(dev));
return 0;
}
else {
@ -292,7 +292,7 @@ ppbus_dma_malloc(struct device * dev, caddr_t * buf, bus_addr_t * addr,
struct ppbus_softc * ppbus = (struct ppbus_softc *) dev;
if(ppbus->sc_capabilities & PPBUS_HAS_DMA)
return (ppbus->ppbus_dma_malloc(dev->dv_parent, buf, addr,
return (ppbus->ppbus_dma_malloc(device_parent(dev), buf, addr,
size));
else
return ENODEV;
@ -306,7 +306,7 @@ ppbus_dma_free(struct device * dev, caddr_t * buf, bus_addr_t * addr,
struct ppbus_softc * ppbus = (struct ppbus_softc *) dev;
if(ppbus->sc_capabilities & PPBUS_HAS_DMA) {
ppbus->ppbus_dma_free(dev->dv_parent, buf, addr, size);
ppbus->ppbus_dma_free(device_parent(dev), buf, addr, size);
return 0;
}
else {
@ -320,7 +320,7 @@ int ppbus_add_handler(struct device * dev, void (*func)(void *), void * arg)
struct ppbus_softc * bus = (struct ppbus_softc *) dev;
if(bus->sc_capabilities & PPBUS_HAS_INTR)
return bus->ppbus_add_handler(dev->dv_parent, func, arg);
return bus->ppbus_add_handler(device_parent(dev), func, arg);
else
return ENODEV;
}
@ -331,7 +331,7 @@ int ppbus_remove_handler(struct device * dev, void (*func)(void *))
struct ppbus_softc * bus = (struct ppbus_softc *) dev;
if(bus->sc_capabilities & PPBUS_HAS_INTR)
return bus->ppbus_remove_handler(dev->dv_parent, func);
return bus->ppbus_remove_handler(device_parent(dev), func);
else
return ENODEV;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ppbus_conf.c,v 1.9 2005/12/11 12:23:28 christos Exp $ */
/* $NetBSD: ppbus_conf.c,v 1.10 2006/03/25 03:44:35 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999 Nicolas Souchu
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ppbus_conf.c,v 1.9 2005/12/11 12:23:28 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ppbus_conf.c,v 1.10 2006/03/25 03:44:35 thorpej Exp $");
#include "opt_ppbus.h"
#include "opt_ppbus_1284.h"
@ -136,7 +136,7 @@ ppbus_attach(struct device *parent, struct device *self, void *aux)
LK_NOWAIT);
/* Set up bus mode and ieee state */
ppbus->sc_mode = ppbus->ppbus_getmode(self->dv_parent);
ppbus->sc_mode = ppbus->ppbus_getmode(device_parent(self));
ppbus->sc_use_ieee = 1;
ppbus->sc_1284_state = PPBUS_FORWARD_IDLE;
ppbus->sc_1284_error = PPBUS_NO_ERROR;