summaryrefslogtreecommitdiffstats
path: root/sys/dev/ppbus/if_plip.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-10-21 18:30:10 +0000
committerjhb <jhb@FreeBSD.org>2008-10-21 18:30:10 +0000
commit03f7a1b892756cd78ff85f138ffdb94cd4216670 (patch)
tree7de1b18022c6338570a93ecf78a487c8a9820918 /sys/dev/ppbus/if_plip.c
parentddfa987b872f81817a11a48d9b97c719ef1e48d3 (diff)
downloadFreeBSD-src-03f7a1b892756cd78ff85f138ffdb94cd4216670.zip
FreeBSD-src-03f7a1b892756cd78ff85f138ffdb94cd4216670.tar.gz
Several cleanups to remove the need for explicit unit numbers and a few
other fixes: - Add pointers back to device_t objects in softc structures instead of storing the unit and using devclass_get_device(). - Add 'lpbb', 'pcf', 'pps', and 'vpo' child devices to every 'ppbus' device instead of just the first one. - Store softc pointers in si_drv1 of character devices instead of pulling the unit number from the minor number and using devclass_get_softc() and devclass_get_device(). - Store the LP_BYPASS flag in si_drv2 instead of encoding it in the minor number. - Destroy character devices for lpt(4) when detaching the device. - Use bus_print_child_footer() instead of duplicating it in ppbus_print_child() and fix ppbus_print_child()'s return value. - Remove unused AVM ivar from ppbus. - Don't store the 'mode' ivar in the ppbus ivars since we always fetch it from the parent anyway. - Try to detach all the child devices before deleting them in ppbus_detach(). - Use pause() instead of a tsleep() on a dummy address when polling the ppbus. - Use if_printf() and device_printf() instead of explicit names with unit numbers. Silence on: current@
Diffstat (limited to 'sys/dev/ppbus/if_plip.c')
-rw-r--r--sys/dev/ppbus/if_plip.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c
index 291c2db..fd17ed9 100644
--- a/sys/dev/ppbus/if_plip.c
+++ b/sys/dev/ppbus/if_plip.c
@@ -147,6 +147,7 @@ static int volatile lptflag = 0;
struct lp_data {
struct ifnet *sc_ifp;
+ device_t sc_dev;
u_char *sc_ifbuf;
int sc_iferrs;
@@ -173,8 +174,6 @@ static void lp_intr(void *);
#define DEVTOSOFTC(dev) \
((struct lp_data *)device_get_softc(dev))
-#define UNITODEVICE(unit) \
- (devclass_get_device(lp_devclass, (unit)))
static devclass_t lp_devclass;
@@ -206,6 +205,8 @@ lp_attach (device_t dev)
struct ifnet *ifp;
int rid = 0;
+ lp->sc_dev = dev;
+
/*
* Reserve the interrupt resource. If we don't have one, the
* attach fails.
@@ -284,9 +285,9 @@ lpinittables (void)
static int
lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
{
- device_t dev = UNITODEVICE(ifp->if_dunit);
+ struct lp_data *sc = ifp->if_softc;
+ device_t dev = sc->sc_dev;
device_t ppbus = device_get_parent(dev);
- struct lp_data *sc = DEVTOSOFTC(dev);
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
u_char *ptr;
@@ -560,7 +561,7 @@ lp_intr (void *arg)
* so stop wasting our time
*/
if (sc->sc_iferrs > LPMAXERRS) {
- printf("lp%d: Too many errors, Going off-line.\n", device_get_unit(dev));
+ if_printf(sc->sc_ifp, "Too many errors, Going off-line.\n");
ppb_wctr(ppbus, 0x00);
sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
sc->sc_iferrs=0;
@@ -589,7 +590,8 @@ static int
lpoutput (struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt)
{
- device_t dev = UNITODEVICE(ifp->if_dunit);
+ struct lp_data *sc = ifp->if_softc;
+ device_t dev = sc->sc_dev;
device_t ppbus = device_get_parent(dev);
int s, err;
struct mbuf *mm;
OpenPOWER on IntegriCloud