diff --git a/index.html b/index.html index 9efb3f2..455f978 100644 --- a/index.html +++ b/index.html @@ -5527,74 +5527,76 @@ halves, but using threads. 79 80    pr_info("Successfully requested BUTTON1 IRQ # %d\n", button_irqs[0]); 81 -82    ret = request_threaded_irq( -83        button_irqs[0], button_top_half, button_bottom_half, -84        IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "gpiomod#button1", &buttons[0]); -85 -86    if (ret) { -87        pr_err("Unable to request IRQ: %d\n", ret); -88        goto fail2; -89    } -90 -91    ret = gpio_to_irq(buttons[1].gpio); -92 -93    if (ret < 0) { -94        pr_err("Unable to request IRQ: %d\n", ret); -95        goto fail2; -96    } -97 -98    button_irqs[1] = ret; -99 -100    pr_info("Successfully requested BUTTON2 IRQ # %d\n", button_irqs[1]); -101 -102    ret = request_threaded_irq( -103        button_irqs[1], button_top_half, button_bottom_half, -104        IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "gpiomod#button2", &buttons[1]); -105 -106    if (ret) { -107        pr_err("Unable to request IRQ: %d\n", ret); -108        goto fail3; -109    } -110 -111    return 0; +82    ret = request_threaded_irq(button_irqs[0], button_top_half, +83                               button_bottom_half, +84                               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, +85                               "gpiomod#button1", &buttons[0]); +86 +87    if (ret) { +88        pr_err("Unable to request IRQ: %d\n", ret); +89        goto fail2; +90    } +91 +92    ret = gpio_to_irq(buttons[1].gpio); +93 +94    if (ret < 0) { +95        pr_err("Unable to request IRQ: %d\n", ret); +96        goto fail2; +97    } +98 +99    button_irqs[1] = ret; +100 +101    pr_info("Successfully requested BUTTON2 IRQ # %d\n", button_irqs[1]); +102 +103    ret = request_threaded_irq(button_irqs[1], button_top_half, +104                               button_bottom_half, +105                               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, +106                               "gpiomod#button2", &buttons[1]); +107 +108    if (ret) { +109        pr_err("Unable to request IRQ: %d\n", ret); +110        goto fail3; +111    } 112 -113/* cleanup what has been setup so far */ -114fail3: -115    free_irq(button_irqs[0], NULL); -116 -117fail2: -118    gpio_free_array(buttons, ARRAY_SIZE(leds)); -119 -120fail1: -121    gpio_free_array(leds, ARRAY_SIZE(leds)); -122 -123    return ret; -124} -125 -126static void __exit bottomhalf_exit(void) -127{ -128    int i; -129 -130    pr_info("%s\n", __func__); +113    return 0; +114 +115/* cleanup what has been setup so far */ +116fail3: +117    free_irq(button_irqs[0], NULL); +118 +119fail2: +120    gpio_free_array(buttons, ARRAY_SIZE(leds)); +121 +122fail1: +123    gpio_free_array(leds, ARRAY_SIZE(leds)); +124 +125    return ret; +126} +127 +128static void __exit bottomhalf_exit(void) +129{ +130    int i; 131 -132    /* free irqs */ -133    free_irq(button_irqs[0], NULL); -134    free_irq(button_irqs[1], NULL); -135 -136    /* turn all LEDs off */ -137    for (i = 0; i < ARRAY_SIZE(leds); i++) -138        gpio_set_value(leds[i].gpio, 0); -139 -140    /* unregister */ -141    gpio_free_array(leds, ARRAY_SIZE(leds)); -142    gpio_free_array(buttons, ARRAY_SIZE(buttons)); -143} -144 -145module_init(bottomhalf_init); -146module_exit(bottomhalf_exit); -147 -148MODULE_LICENSE("GPL"); -149MODULE_DESCRIPTION("Interrupt with top and bottom half"); +132    pr_info("%s\n", __func__); +133 +134    /* free irqs */ +135    free_irq(button_irqs[0], NULL); +136    free_irq(button_irqs[1], NULL); +137 +138    /* turn all LEDs off */ +139    for (i = 0; i < ARRAY_SIZE(leds); i++) +140        gpio_set_value(leds[i].gpio, 0); +141 +142    /* unregister */ +143    gpio_free_array(leds, ARRAY_SIZE(leds)); +144    gpio_free_array(buttons, ARRAY_SIZE(buttons)); +145} +146 +147module_init(bottomhalf_init); +148module_exit(bottomhalf_exit); +149 +150MODULE_LICENSE("GPL"); +151MODULE_DESCRIPTION("Interrupt with top and bottom half");

A threaded IRQ is registered using request_threaded_irq() . This function only takes one additional parameter than the request_irq() diff --git a/lkmpg-for-ht.html b/lkmpg-for-ht.html index 9efb3f2..455f978 100644 --- a/lkmpg-for-ht.html +++ b/lkmpg-for-ht.html @@ -5527,74 +5527,76 @@ halves, but using threads. 79 80    pr_info("Successfully requested BUTTON1 IRQ # %d\n", button_irqs[0]); 81 -82    ret = request_threaded_irq( -83        button_irqs[0], button_top_half, button_bottom_half, -84        IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "gpiomod#button1", &buttons[0]); -85 -86    if (ret) { -87        pr_err("Unable to request IRQ: %d\n", ret); -88        goto fail2; -89    } -90 -91    ret = gpio_to_irq(buttons[1].gpio); -92 -93    if (ret < 0) { -94        pr_err("Unable to request IRQ: %d\n", ret); -95        goto fail2; -96    } -97 -98    button_irqs[1] = ret; -99 -100    pr_info("Successfully requested BUTTON2 IRQ # %d\n", button_irqs[1]); -101 -102    ret = request_threaded_irq( -103        button_irqs[1], button_top_half, button_bottom_half, -104        IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "gpiomod#button2", &buttons[1]); -105 -106    if (ret) { -107        pr_err("Unable to request IRQ: %d\n", ret); -108        goto fail3; -109    } -110 -111    return 0; +82    ret = request_threaded_irq(button_irqs[0], button_top_half, +83                               button_bottom_half, +84                               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, +85                               "gpiomod#button1", &buttons[0]); +86 +87    if (ret) { +88        pr_err("Unable to request IRQ: %d\n", ret); +89        goto fail2; +90    } +91 +92    ret = gpio_to_irq(buttons[1].gpio); +93 +94    if (ret < 0) { +95        pr_err("Unable to request IRQ: %d\n", ret); +96        goto fail2; +97    } +98 +99    button_irqs[1] = ret; +100 +101    pr_info("Successfully requested BUTTON2 IRQ # %d\n", button_irqs[1]); +102 +103    ret = request_threaded_irq(button_irqs[1], button_top_half, +104                               button_bottom_half, +105                               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, +106                               "gpiomod#button2", &buttons[1]); +107 +108    if (ret) { +109        pr_err("Unable to request IRQ: %d\n", ret); +110        goto fail3; +111    } 112 -113/* cleanup what has been setup so far */ -114fail3: -115    free_irq(button_irqs[0], NULL); -116 -117fail2: -118    gpio_free_array(buttons, ARRAY_SIZE(leds)); -119 -120fail1: -121    gpio_free_array(leds, ARRAY_SIZE(leds)); -122 -123    return ret; -124} -125 -126static void __exit bottomhalf_exit(void) -127{ -128    int i; -129 -130    pr_info("%s\n", __func__); +113    return 0; +114 +115/* cleanup what has been setup so far */ +116fail3: +117    free_irq(button_irqs[0], NULL); +118 +119fail2: +120    gpio_free_array(buttons, ARRAY_SIZE(leds)); +121 +122fail1: +123    gpio_free_array(leds, ARRAY_SIZE(leds)); +124 +125    return ret; +126} +127 +128static void __exit bottomhalf_exit(void) +129{ +130    int i; 131 -132    /* free irqs */ -133    free_irq(button_irqs[0], NULL); -134    free_irq(button_irqs[1], NULL); -135 -136    /* turn all LEDs off */ -137    for (i = 0; i < ARRAY_SIZE(leds); i++) -138        gpio_set_value(leds[i].gpio, 0); -139 -140    /* unregister */ -141    gpio_free_array(leds, ARRAY_SIZE(leds)); -142    gpio_free_array(buttons, ARRAY_SIZE(buttons)); -143} -144 -145module_init(bottomhalf_init); -146module_exit(bottomhalf_exit); -147 -148MODULE_LICENSE("GPL"); -149MODULE_DESCRIPTION("Interrupt with top and bottom half"); +132    pr_info("%s\n", __func__); +133 +134    /* free irqs */ +135    free_irq(button_irqs[0], NULL); +136    free_irq(button_irqs[1], NULL); +137 +138    /* turn all LEDs off */ +139    for (i = 0; i < ARRAY_SIZE(leds); i++) +140        gpio_set_value(leds[i].gpio, 0); +141 +142    /* unregister */ +143    gpio_free_array(leds, ARRAY_SIZE(leds)); +144    gpio_free_array(buttons, ARRAY_SIZE(buttons)); +145} +146 +147module_init(bottomhalf_init); +148module_exit(bottomhalf_exit); +149 +150MODULE_LICENSE("GPL"); +151MODULE_DESCRIPTION("Interrupt with top and bottom half");

A threaded IRQ is registered using request_threaded_irq() . This function only takes one additional parameter than the request_irq()