MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mv_gpio_setup_intrhandler

Function mv_gpio_setup_intrhandler

freebsd/arm/mv/gpio.c:408–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408int
409mv_gpio_setup_intrhandler(device_t dev, const char *name, driver_filter_t *filt,
410 void (*hand)(void *), void *arg, int pin, int flags, void **cookiep)
411{
412 struct intr_event *event;
413 int error;
414 struct mv_gpio_pindev *s;
415 struct mv_gpio_softc *sc;
416 sc = (struct mv_gpio_softc *)device_get_softc(dev);
417 s = malloc(sizeof(struct mv_gpio_pindev), M_DEVBUF, M_NOWAIT | M_ZERO);
418
419 if (pin < 0 || pin >= sc->pin_num)
420 return (ENXIO);
421 event = sc->gpio_events[pin];
422 if (event == NULL) {
423 MV_GPIO_LOCK();
424 if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_DEBOUNCE) {
425 error = mv_gpio_debounce_init(dev, pin);
426 if (error != 0) {
427 MV_GPIO_UNLOCK();
428 return (error);
429 }
430 } else if (sc->gpio_setup[pin].gp_flags & MV_GPIO_IN_IRQ_DOUBLE_EDGE)
431 mv_gpio_double_edge_init(dev, pin);
432 MV_GPIO_UNLOCK();
433 error = intr_event_create(&event, (void *)s, 0, pin,
434 (void (*)(void *))mv_gpio_intr_mask,
435 (void (*)(void *))mv_gpio_intr_unmask,
436 (void (*)(void *))mv_gpio_int_ack,
437 NULL,
438 "gpio%d:", pin);
439 if (error != 0)
440 return (error);
441 sc->gpio_events[pin] = event;
442 }
443
444 intr_event_add_handler(event, name, filt, hand, arg,
445 intr_priority(flags), flags, cookiep);
446 return (0);
447}
448
449static void
450mv_gpio_intr_mask(struct mv_gpio_pindev *s)

Callers

nothing calls this directly

Calls 7

device_get_softcFunction · 0.85
mallocFunction · 0.85
mv_gpio_debounce_initFunction · 0.85
mv_gpio_double_edge_initFunction · 0.85
intr_event_createFunction · 0.85
intr_event_add_handlerFunction · 0.85
intr_priorityFunction · 0.85

Tested by

no test coverage detected