15
15
#include <linux/printk.h>
16
16
#include <linux/init.h>
17
17
#include <linux/version.h>
18
+ #include <linux/workqueue.h>
18
19
19
20
#if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 10 , 0 )
20
21
#define NO_GPIO_REQUEST_ARRAY
@@ -42,16 +43,17 @@ static struct gpio buttons[] = {
42
43
{ 18 , GPIOF_IN , "LED 1 OFF BUTTON" },
43
44
};
44
45
45
- /* Tasklet containing some non-trivial amount of processing */
46
- static void bottomhalf_tasklet_fn ( unsigned long data )
46
+ /* Workqueue function containing some non-trivial amount of processing */
47
+ static void bottomhalf_work_fn ( struct work_struct * work )
47
48
{
48
- pr_info ("Bottom half tasklet starts\n" );
49
+ pr_info ("Bottom half workqueue starts\n" );
49
50
/* do something which takes a while */
50
- mdelay (500 );
51
- pr_info ("Bottom half tasklet ends\n" );
51
+ msleep (500 );
52
+
53
+ pr_info ("Bottom half workqueue ends\n" );
52
54
}
53
55
54
- static DECLARE_TASKLET_OLD ( buttontask , bottomhalf_tasklet_fn ) ;
56
+ static DECLARE_WORK ( bottomhalf_work , bottomhalf_work_fn ) ;
55
57
56
58
/* interrupt function triggered when a button is pressed */
57
59
static irqreturn_t button_isr (int irq , void * data )
@@ -63,8 +65,7 @@ static irqreturn_t button_isr(int irq, void *data)
63
65
gpio_set_value (leds [0 ].gpio , 0 );
64
66
65
67
/* Do the rest at leisure via the scheduler */
66
- tasklet_schedule (& buttontask );
67
-
68
+ schedule_work (& bottomhalf_work );
68
69
return IRQ_HANDLED ;
69
70
}
70
71
0 commit comments