Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: device_lookup_private() puzzle



On Tue, Feb 22, 2011 at 04:32:19PM +0000, Patrick Welche wrote:
> Trying out an old udsbr(4) on i386, I was surprised to get an error running
> radioctl -a, ENXIO on open of /dev/radio.
> 
> In /sys/dev/radio.c, printing sc in radioattach and in radioopen show that
> sc has a different value in each. Am I right in thinking that that is
> wrong?

Looks like a sloppy device_t/softc split.  Try this patch.

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 344-0444 x24
Index: sys/dev/radio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/radio.c,v
retrieving revision 1.24
diff -u -p -r1.24 radio.c
--- sys/dev/radio.c     21 Jan 2010 02:19:55 -0000      1.24
+++ sys/dev/radio.c     22 Feb 2011 17:03:13 -0000
@@ -78,7 +78,7 @@ radioprobe(device_t parent, cfdata_t mat
 static void
 radioattach(device_t parent, device_t self, void *aux)
 {
-       struct radio_softc *sc = (void *)self;
+       struct radio_softc *sc = device_private(self);
        struct radio_attach_args *sa = aux;
        const struct radio_hw_if *hwp = sa->hwif;
        void  *hdlp = sa->hdl;
@@ -87,7 +87,7 @@ radioattach(device_t parent, device_t se
        aprint_normal("\n");
        sc->hw_if = hwp;
        sc->hw_hdl = hdlp;
-       sc->sc_dev = parent;
+       sc->sc_dev = self;
 }
 
 static int
@@ -181,7 +181,6 @@ radioprint(void *aux, const char *pnp)
 static int
 radiodetach(device_t self, int flags)
 {
-       /*struct radio_softc *sc = (struct radio_softc *)self;*/
        int maj, mn;
 
        /* locate the major number */


Home | Main Index | Thread Index | Old Index