sys/netgraph7/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c
static int
ubtbcmfw_open(struct cdev *dev, int flag, int mode, struct thread *p)
{
	ubtbcmfw_softc_p	sc = NULL;
	int			error = 0;

	/* checks for sc != NULL */
	sc = devclass_get_softc(ubtbcmfw_devclass, UBTBCMFW_UNIT(dev));
	if (sc == NULL)
		return (ENXIO);
	if (sc->sc_dying)
		return (ENXIO);

	switch (UBTBCMFW_ENDPOINT(dev)) {
	case USB_CONTROL_ENDPOINT:
		if (!(sc->sc_flags & UBTBCMFW_CTRL_DEV))
			sc->sc_flags |= UBTBCMFW_CTRL_DEV;
		else
			error = EBUSY;
		break;

	case UBTBCMFW_INTR_IN:
		if (!(sc->sc_flags & UBTBCMFW_INTR_IN_DEV)) {
			if (sc->sc_intr_in_pipe != NULL)
				sc->sc_flags |= UBTBCMFW_INTR_IN_DEV;
			else
				error = ENXIO;
		} else
			error = EBUSY;
		break;

	case UBTBCMFW_BULK_OUT:
		if (!(sc->sc_flags & UBTBCMFW_BULK_OUT_DEV)) {
			if (sc->sc_bulk_out_pipe != NULL)
				sc->sc_flags |= UBTBCMFW_BULK_OUT_DEV;
			else
				error = ENXIO;
		} else
			error = EBUSY;
		break;

	default:
		error = ENXIO;
		break;
	}

	return (error);
}
/*
 * Open endpoint device
 * XXX FIXME softc locking
 */
Open endpoint device
XXX FIXME softc locking
Open endpoint device XXX FIXME softc locking
static int
ubtbcmfw_open(struct cdev *dev, int flag, int mode, struct thread *p)
{
	ubtbcmfw_softc_p	sc = NULL;
	int			error = 0;
	sc = devclass_get_softc(ubtbcmfw_devclass, UBTBCMFW_UNIT(dev));
	if (sc == NULL)
		return (ENXIO);
	if (sc->sc_dying)
		return (ENXIO);
	switch (UBTBCMFW_ENDPOINT(dev)) {
	case USB_CONTROL_ENDPOINT:
		if (!(sc->sc_flags & UBTBCMFW_CTRL_DEV))
			sc->sc_flags |= UBTBCMFW_CTRL_DEV;
		else
			error = EBUSY;
		break;
	case UBTBCMFW_INTR_IN:
		if (!(sc->sc_flags & UBTBCMFW_INTR_IN_DEV)) {
			if (sc->sc_intr_in_pipe != NULL)
				sc->sc_flags |= UBTBCMFW_INTR_IN_DEV;
			else
				error = ENXIO;
		} else
			error = EBUSY;
		break;
	case UBTBCMFW_BULK_OUT:
		if (!(sc->sc_flags & UBTBCMFW_BULK_OUT_DEV)) {
			if (sc->sc_bulk_out_pipe != NULL)
				sc->sc_flags |= UBTBCMFW_BULK_OUT_DEV;
			else
				error = ENXIO;
		} else
			error = EBUSY;
		break;
	default:
		error = ENXIO;
		break;
	}
	return (error);
}
static int ubtbcmfw_open ( struct cdev * dev , int flag , int mode , struct thread * p ) { ubtbcmfw_softc_p sc = NULL ; int error = 0 ; sc = devclass_get_softc ( ubtbcmfw_devclass , UBTBCMFW_UNIT ( dev ) ) ; if ( sc == NULL ) return ( ENXIO ) ; if ( sc -> sc_dying ) return ( ENXIO ) ; switch ( UBTBCMFW_ENDPOINT ( dev ) ) { case USB_CONTROL_ENDPOINT : if ( ! ( sc -> sc_flags & UBTBCMFW_CTRL_DEV ) ) sc -> sc_flags |= UBTBCMFW_CTRL_DEV ; else error = EBUSY ; break ; case UBTBCMFW_INTR_IN : if ( ! ( sc -> sc_flags & UBTBCMFW_INTR_IN_DEV ) ) { if ( sc -> sc_intr_in_pipe != NULL ) sc -> sc_flags |= UBTBCMFW_INTR_IN_DEV ; else error = ENXIO ; } else error = EBUSY ; break ; case UBTBCMFW_BULK_OUT : if ( ! ( sc -> sc_flags & UBTBCMFW_BULK_OUT_DEV ) ) { if ( sc -> sc_bulk_out_pipe != NULL ) sc -> sc_flags |= UBTBCMFW_BULK_OUT_DEV ; else error = ENXIO ; } else error = EBUSY ; break ; default : error = ENXIO ; break ; } return ( error ) ; }
Open endpoint device
 XXX FIXME softc locking
Open endpoint device XXX FIXME softc locking
/* checks for sc != NULL */