| 406 | } |
| 407 | |
| 408 | int |
| 409 | mv_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 | |
| 449 | static void |
| 450 | mv_gpio_intr_mask(struct mv_gpio_pindev *s) |
nothing calls this directly
no test coverage detected