Module Name:    src
Committed By:   tsutsui
Date:           Mon Sep 14 13:41:15 UTC 2009

Modified Files:
        src/sys/arch/hpcmips/vr: vrecu.c
        src/sys/dev/ic: i82365.c
        src/sys/dev/isa: i82365_isa.c i82365_isasubr.c
        src/sys/dev/pci: i82365_pci.c

Log Message:
Use device_private(), proper types or variables for device_t and softc.
(not yet split though)

No crash on gxemul emulating hpcmips mobilepro.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hpcmips/vr/vrecu.c
cvs rdiff -u -r1.109 -r1.110 src/sys/dev/ic/i82365.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/isa/i82365_isa.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/isa/i82365_isasubr.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/i82365_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hpcmips/vr/vrecu.c
diff -u src/sys/arch/hpcmips/vr/vrecu.c:1.8 src/sys/arch/hpcmips/vr/vrecu.c:1.9
--- src/sys/arch/hpcmips/vr/vrecu.c:1.8	Mon Sep 14 12:49:33 2009
+++ src/sys/arch/hpcmips/vr/vrecu.c	Mon Sep 14 13:41:15 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vrecu.c,v 1.8 2009/09/14 12:49:33 tsutsui Exp $ */
+/* $NetBSD: vrecu.c,v 1.9 2009/09/14 13:41:15 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vrecu.c,v 1.8 2009/09/14 12:49:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vrecu.c,v 1.9 2009/09/14 13:41:15 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -105,8 +105,8 @@
 static void
 pcic_vrip_attach(struct device *parent, struct device *self, void *aux)
 {
-	struct pcic_softc	*sc = (void *) self;
-	struct pcic_vrip_softc	*vsc = (void *) self;
+	struct pcic_vrip_softc	*vsc = device_private(self);
+	struct pcic_softc	*sc = &vsc->sc_pcic;
 	struct vrip_attach_args	*va = aux;
 	bus_space_handle_t	ioh;
 	bus_space_handle_t	memh;
@@ -118,9 +118,9 @@
 		vsc->sc_intrhand[i].ih_fun = NULL;
 
 	if ((sc->ih = vrip_intr_establish(va->va_vc, va->va_unit, 0,
-					  IPL_NET, pcic_vrip_intr, sc))
+					  IPL_NET, pcic_vrip_intr, vsc))
 	    == NULL) {
-		printf("%s: can't establish interrupt", sc->dev.dv_xname);
+		printf(": can't establish interrupt");
 	}
 
         /* Map i/o space. */
@@ -203,8 +203,8 @@
 
 
 	h = (struct pcic_handle *) pch;
-	sc = (struct pcic_softc *) h->ph_parent;
-	vsc = (struct pcic_vrip_softc *) h->ph_parent;
+	vsc = device_private(h->ph_parent);
+	sc = &vsc->sc_pcic;
 
 
 	ih = &vsc->sc_intrhand[irq];
@@ -239,8 +239,8 @@
 	int	r;
 
 	h = (struct pcic_handle *) pch;
-	sc = (struct pcic_softc *) h->ph_parent;
-	vsc = (struct pcic_vrip_softc *) h->ph_parent;
+	vsc = device_private(h->ph_parent);
+	sc = &vsc->sc_pcic;
 
 	if (ih != &vsc->sc_intrhand[h->ih_irq])
 		panic("pcic_vrip_chip_intr_disestablish: bad handler");
@@ -270,8 +270,8 @@
 static int
 pcic_vrip_intr(void *arg)
 {
-	struct pcic_softc	*sc = arg;
 	struct pcic_vrip_softc	*vsc = arg;
+	struct pcic_softc	*sc = &vsc->sc_pcic;
 	int			i;
 	uint16_t		r;
 

Index: src/sys/dev/ic/i82365.c
diff -u src/sys/dev/ic/i82365.c:1.109 src/sys/dev/ic/i82365.c:1.110
--- src/sys/dev/ic/i82365.c:1.109	Mon Sep 14 12:49:33 2009
+++ src/sys/dev/ic/i82365.c	Mon Sep 14 13:41:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82365.c,v 1.109 2009/09/14 12:49:33 tsutsui Exp $	*/
+/*	$NetBSD: i82365.c,v 1.110 2009/09/14 13:41:15 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2004 Charles M. Hannum.  All rights reserved.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.109 2009/09/14 12:49:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365.c,v 1.110 2009/09/14 13:41:15 tsutsui Exp $");
 
 #define	PCICDEBUG
 
@@ -230,9 +230,11 @@
 {
 	int i, reg, chip, socket;
 	struct pcic_handle *h;
+	device_t self;
 
 	DPRINTF(("pcic ident regs:"));
 
+	self = &sc->dev;
 	mutex_init(&sc->sc_pcic_lock, MUTEX_DEFAULT, IPL_NONE);
 
 	/* find and configure for the available sockets */
@@ -241,7 +243,7 @@
 		chip = i / 2;
 		socket = i % 2;
 
-		h->ph_parent = (device_t)sc;
+		h->ph_parent = self;
 		h->chip = chip;
 		h->socket = socket;
 		h->sock = chip * PCIC_CHIP_OFFSET + socket * PCIC_SOCKET_OFFSET;
@@ -315,7 +317,7 @@
 		if (h->vendor == PCIC_VENDOR_NONE)
 			continue;
 
-		aprint_normal_dev(&sc->dev, "controller %d (%s) has ",
+		aprint_normal_dev(self, "controller %d (%s) has ",
 		    chip, pcic_vendor_to_string(sc->handle[i].vendor));
 
 		if ((h->flags & PCIC_FLAG_SOCKETP) &&
@@ -347,7 +349,7 @@
 pcic_power(int why, void *arg)
 {
 	struct pcic_handle *h = (struct pcic_handle *)arg;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 	int reg;
 
 	DPRINTF(("%s: power: why %d\n", device_xname(h->ph_parent), why));
@@ -388,7 +390,7 @@
 pcic_attach_socket(struct pcic_handle *h)
 {
 	struct pcmciabus_attach_args paa;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 	int locs[PCMCIABUSCF_NLOCS];
 
 	/* initialize the rest of the handle */
@@ -439,7 +441,7 @@
 void
 pcic_attach_socket_finish(struct pcic_handle *h)
 {
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 	int reg;
 	char cs[4];
 
@@ -520,7 +522,7 @@
 	struct pcic_handle *h = arg;
 	struct pcic_event *pe;
 	int s, first = 1;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 
 	while (h->shutdown == 0) {
 		/*
@@ -797,7 +799,7 @@
 	bus_addr_t addr;
 	bus_size_t sizepg;
 	int i, mask, mhandle;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 
 	/* out of sc->memh, allocate as many pages as necessary */
 
@@ -837,7 +839,7 @@
 pcic_chip_mem_free(pcmcia_chipset_handle_t pch, struct pcmcia_mem_handle *pcmhp)
 {
 	struct pcic_handle *h = (struct pcic_handle *) pch;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 
 	sc->subregionmask |= pcmhp->mhandle;
 }
@@ -964,7 +966,7 @@
 	bus_addr_t busaddr;
 	long card_offset;
 	int i, win;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 
 	win = -1;
 	for (i = 0; i < (sizeof(mem_map_index) / sizeof(mem_map_index[0]));
@@ -1044,7 +1046,7 @@
 	bus_space_handle_t ioh;
 	bus_addr_t ioaddr;
 	int flags = 0;
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 
 	/*
 	 * Allocate some arbitrary I/O space.
@@ -1172,7 +1174,7 @@
 #ifdef PCICDEBUG
 	static const char *width_names[] = { "auto", "io8", "io16" };
 #endif
-	struct pcic_softc *sc = (struct pcic_softc *)h->ph_parent;
+	struct pcic_softc *sc = device_private(h->ph_parent);
 
 	/* XXX Sanity check offset/size. */
 

Index: src/sys/dev/isa/i82365_isa.c
diff -u src/sys/dev/isa/i82365_isa.c:1.31 src/sys/dev/isa/i82365_isa.c:1.32
--- src/sys/dev/isa/i82365_isa.c:1.31	Tue May 12 09:10:15 2009
+++ src/sys/dev/isa/i82365_isa.c	Mon Sep 14 13:41:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82365_isa.c,v 1.31 2009/05/12 09:10:15 cegger Exp $	*/
+/*	$NetBSD: i82365_isa.c,v 1.32 2009/09/14 13:41:15 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365_isa.c,v 1.31 2009/05/12 09:10:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365_isa.c,v 1.32 2009/09/14 13:41:15 tsutsui Exp $");
 
 #define	PCICISADEBUG
 
@@ -184,8 +184,8 @@
 void
 pcic_isa_attach(device_t parent, device_t self, void *aux)
 {
-	struct pcic_softc *sc = (void *) self;
-	struct pcic_isa_softc *isc = (void *) self;
+	struct pcic_isa_softc *isc = device_private(self);
+	struct pcic_softc *sc = &isc->sc_pcic;
 	struct isa_attach_args *ia = aux;
 	isa_chipset_tag_t ic = ia->ia_ic;
 	bus_space_tag_t iot = ia->ia_iot;

Index: src/sys/dev/isa/i82365_isasubr.c
diff -u src/sys/dev/isa/i82365_isasubr.c:1.43 src/sys/dev/isa/i82365_isasubr.c:1.44
--- src/sys/dev/isa/i82365_isasubr.c:1.43	Tue May 12 09:10:15 2009
+++ src/sys/dev/isa/i82365_isasubr.c	Mon Sep 14 13:41:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82365_isasubr.c,v 1.43 2009/05/12 09:10:15 cegger Exp $	*/
+/*	$NetBSD: i82365_isasubr.c,v 1.44 2009/09/14 13:41:15 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2000 Christian E. Hopps.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365_isasubr.c,v 1.43 2009/05/12 09:10:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365_isasubr.c,v 1.44 2009/09/14 13:41:15 tsutsui Exp $");
 
 #define	PCICISADEBUG
 
@@ -126,7 +126,7 @@
  * just use socket 0
  */
 
-void pcic_isa_probe_interrupts(struct pcic_softc *, struct pcic_handle *);
+void pcic_isa_probe_interrupts(struct pcic_isa_softc *, struct pcic_handle *);
 static int pcic_isa_count_intr(void *);
 
 static int
@@ -138,8 +138,8 @@
 	int cscreg;
 
 	h = arg;
-	sc = (struct pcic_softc *)h->ph_parent;
-	isc = (struct pcic_isa_softc *)h->ph_parent;
+	isc = device_private(h->ph_parent);
+	sc = &isc->sc_pcic;
 
 	cscreg = pcic_read(h, PCIC_CSC);
 	if (cscreg & PCIC_CSC_CD) {
@@ -176,9 +176,9 @@
  * for this controller
  */
 void
-pcic_isa_probe_interrupts(struct pcic_softc *sc, struct pcic_handle *h)
+pcic_isa_probe_interrupts(struct pcic_isa_softc *isc, struct pcic_handle *h)
 {
-	struct pcic_isa_softc *isc = (void *) sc;
+	struct pcic_softc *sc = &isc->sc_pcic;
 	isa_chipset_tag_t ic;
 	int i, j, mask, irq;
 	int cd, cscintr, intr, csc;
@@ -277,8 +277,8 @@
 	isa_chipset_tag_t ic;
 	int s, i, chipmask, chipuniq;
 
-	sc = (struct pcic_softc *) self;
-	isc = (struct pcic_isa_softc *) self;
+	isc = device_private(self);
+	sc = &isc->sc_pcic;
 	ic = isc->sc_ic;
 
 	/* probe each controller */
@@ -297,7 +297,7 @@
 		/* the cirrus chips lack support for the soft interrupt */
 		if (pcic_irq_probe != 0 &&
 		    h->vendor != PCIC_VENDOR_CIRRUS_PD67XX)
-			pcic_isa_probe_interrupts(sc, h);
+			pcic_isa_probe_interrupts(isc, h);
 
 		chipmask &= sc->intr_mask[h->chip];
 	}
@@ -328,17 +328,17 @@
 			if ((chipmask & (1 << sc->irq)) == 0)
 				printf("%s: warning: configured irq %d not "
 				    "detected as available\n",
-				    device_xname(&sc->dev), sc->irq);
+				    device_xname(self), sc->irq);
 		} else if (chipmask == 0 ||
 		    isa_intr_alloc(ic, chipmask, IST_EDGE, &sc->irq)) {
-			aprint_error_dev(&sc->dev, "no available irq; ");
+			aprint_error_dev(self, "no available irq; ");
 			sc->irq = ISA_UNKNOWN_IRQ;
 		} else if ((chipmask & ~(1 << sc->irq)) == 0 && chipuniq == 0) {
-			aprint_error_dev(&sc->dev, "can't share irq with cards; ");
+			aprint_error_dev(self, "can't share irq with cards; ");
 			sc->irq = ISA_UNKNOWN_IRQ;
 		}
 	} else {
-		printf("%s: ", device_xname(&sc->dev));
+		printf("%s: ", device_xname(self));
 		sc->irq = ISA_UNKNOWN_IRQ;
 	}
 
@@ -346,15 +346,15 @@
 		sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY,
 		    pcic_intr, sc);
 		if (sc->ih == NULL) {
-			aprint_error_dev(&sc->dev, "can't establish interrupt");
+			aprint_error_dev(self, "can't establish interrupt");
 			sc->irq = ISA_UNKNOWN_IRQ;
 		}
 	}
 	if (sc->irq == ISA_UNKNOWN_IRQ)
 		printf("polling for socket events\n");
 	else
-		printf("%s: using irq %d for socket events\n", device_xname(&sc->dev),
-		    sc->irq);
+		printf("%s: using irq %d for socket events\n",
+		    device_xname(self), sc->irq);
 
 	pcic_attach_sockets_finish(sc);
 
@@ -452,8 +452,8 @@
 	struct pcmcia_function *pf, int ipl, int (*fct)(void *), void *arg)
 {
 	struct pcic_handle *h = (struct pcic_handle *) pch;
-	struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
-	struct pcic_isa_softc *isc = (struct pcic_isa_softc *)(h->ph_parent);
+	struct pcic_isa_softc *isc = device_private(h->ph_parent);
+	struct pcic_softc *sc = &isc->sc_pcic;
 	isa_chipset_tag_t ic = isc->sc_ic;
 	int irq, ist;
 	void *ih;
@@ -498,7 +498,7 @@
 pcic_isa_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
 {
 	struct pcic_handle *h = (struct pcic_handle *) pch;
-	struct pcic_isa_softc *isc = (struct pcic_isa_softc *)(h->ph_parent);
+	struct pcic_isa_softc *isc = device_private(h->ph_parent);
 	isa_chipset_tag_t ic = isc->sc_ic;
 	int reg;
 

Index: src/sys/dev/pci/i82365_pci.c
diff -u src/sys/dev/pci/i82365_pci.c:1.30 src/sys/dev/pci/i82365_pci.c:1.31
--- src/sys/dev/pci/i82365_pci.c:1.30	Tue May 12 08:23:00 2009
+++ src/sys/dev/pci/i82365_pci.c	Mon Sep 14 13:41:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82365_pci.c,v 1.30 2009/05/12 08:23:00 cegger Exp $	*/
+/*	$NetBSD: i82365_pci.c,v 1.31 2009/09/14 13:41:15 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82365_pci.c,v 1.30 2009/05/12 08:23:00 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82365_pci.c,v 1.31 2009/09/14 13:41:15 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -113,7 +113,7 @@
 pcic_pci_attach(device_t parent, device_t self, void *aux)
 {
 	struct pcic_pci_softc *psc = device_private(self);
-	struct pcic_softc *sc = device_private(self);
+	struct pcic_softc *sc = &psc->sc_pcic;
 	struct pci_attach_args *pa = aux;
 	pci_chipset_tag_t pc = pa->pa_pc;
 	bus_space_tag_t memt = pa->pa_memt;
@@ -185,7 +185,7 @@
 		   PCIC_CIRRUS_EXT_CONTROL_1);
 	if ((pcic_read(&sc->handle[0], PCIC_CIRRUS_EXTENDED_DATA) &
 	    PCIC_CIRRUS_EXT_CONTROL_1_PCI_INTR_MASK)) {
-		aprint_error_dev(&sc->dev, "PCI interrupts not supported\n");
+		aprint_error_dev(self, "PCI interrupts not supported\n");
 		return;
 	}
 
@@ -196,7 +196,7 @@
 	/* Map and establish the interrupt. */
 	sc->ih = pcic_pci_machdep_pcic_intr_establish(sc, pcic_intr);
 	if (sc->ih == NULL) {
-		aprint_error_dev(&sc->dev, "couldn't map interrupt\n");
+		aprint_error_dev(self, "couldn't map interrupt\n");
 		return;
 	}
 #endif

Reply via email to