static int gpioc_attach(device_t 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); 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); } return (0); }
static void pty_clone(void *arg, struct ucred *cr, char *name, int namelen, struct cdev **dev) { struct make_dev_args mda; int error; /* Cloning is already satisfied. */ if (*dev != NULL) return; /* Only catch /dev/ptyXX. */ if (namelen != 5 || bcmp(name, "pty", 3) != 0) return; /* Only catch /dev/pty[l-sL-S]X. */ if (!(name[3] >= 'l' && name[3] <= 's') && !(name[3] >= 'L' && name[3] <= 'S')) return; /* Only catch /dev/pty[l-sL-S][0-9a-v]. */ if (!(name[4] >= '0' && name[4] <= '9') && !(name[4] >= 'a' && name[4] <= 'v')) return; /* Create the controller device node. */ make_dev_args_init(&mda); mda.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_REF; mda.mda_devsw = &ptydev_cdevsw; mda.mda_uid = UID_ROOT; mda.mda_gid = GID_WHEEL; mda.mda_mode = 0666; error = make_dev_s(&mda, dev, "%s", name); if (error != 0) *dev = NULL; }
static int pwmc_attach(device_t dev) { struct pwmc_softc *sc; struct make_dev_args args; sc = device_get_softc(dev); sc->dev = dev; sc->pdev = device_get_parent(dev); snprintf(sc->name, sizeof(sc->name), "pwmc%d", device_get_unit(dev)); make_dev_args_init(&args); args.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; args.mda_devsw = &pwm_cdevsw; args.mda_uid = UID_ROOT; args.mda_gid = GID_OPERATOR; args.mda_mode = 0600; args.mda_si_drv1 = sc; if (make_dev_s(&args, &sc->pwm_dev, "%s", sc->name) != 0) { device_printf(dev, "Failed to make PWM device\n"); return (ENXIO); } return (0); }