Author: loos Date: Sun Jan 8 20:41:32 2017 New Revision: 311701 URL: https://svnweb.freebsd.org/changeset/base/311701
Log: Convert gpioc to use the make_dev_s(9) KPI. This fix a possible race where si_drv1 can be accessed before it gets set. This is inspired on r311700. MFC after: 3 days Modified: head/sys/dev/gpio/gpioc.c Modified: head/sys/dev/gpio/gpioc.c ============================================================================== --- head/sys/dev/gpio/gpioc.c Sun Jan 8 20:37:41 2017 (r311700) +++ head/sys/dev/gpio/gpioc.c Sun Jan 8 20:41:32 2017 (r311701) @@ -78,18 +78,25 @@ gpioc_probe(device_t dev) static int gpioc_attach(device_t dev) { - struct gpioc_softc *sc = device_get_softc(dev); + int err; + struct gpioc_softc *sc; + struct make_dev_args devargs; + sc = device_get_softc(dev); sc->sc_dev = dev; sc->sc_pdev = device_get_parent(dev); sc->sc_unit = device_get_unit(dev); - sc->sc_ctl_dev = make_dev(&gpioc_cdevsw, sc->sc_unit, - UID_ROOT, GID_WHEEL, 0600, "gpioc%d", sc->sc_unit); - if (!sc->sc_ctl_dev) { + make_dev_args_init(&devargs); + devargs.mda_devsw = &gpioc_cdevsw; + devargs.mda_uid = UID_ROOT; + devargs.mda_gid = GID_WHEEL; + devargs.mda_mode = 0600; + devargs.mda_si_drv1 = sc; + err = make_dev_s(&devargs, &sc->sc_ctl_dev, "gpioc%d", sc->sc_unit); + if (err != 0) { printf("Failed to create gpioc%d", sc->sc_unit); return (ENXIO); } - sc->sc_ctl_dev->si_drv1 = sc; return (0); } _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"