Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The led_close function is defined in led_cdevsw as the d_close operation. Here is its function definition (again):
static int
led_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
{
int led = dev2unit(dev) & 0xff;
struct led_softc *sc = dev->si_drv1;
if (led >= LED_NUM)
return (ENXIO);
mtx_lock(&sc->sc_mutex);
sc->sc_open_mask &= ˜(1 << led);
mtx_unlock(&sc->sc_mutex);
return (0);
}
As you can see, this function simply clears
sc_open_mask’s led bit (which allows another process to open this device).