October 2017
Intermediate to advanced
586 pages
14h 8m
English
The following simple excerpt is a demonstration of how you can implement the threaded bottom half mechanism:
static irqreturn_t pcf8574_kp_irq_handler(int irq, void *dev_id) { struct custom_data *lp = dev_id; unsigned char nextstate = read_state(lp); if (lp->laststate != nextstate) { int key_down = nextstate < ARRAY_SIZE(lp->btncode); unsigned short keycode = key_down ? p->btncode[nextstate] : lp->btncode[lp->laststate]; input_report_key(lp->idev, keycode, key_down); input_sync(lp->idev); lp->laststate = nextstate; } return IRQ_HANDLED; } static int pcf8574_kp_probe(struct i2c_client *client, \ const struct i2c_device_id *id) { struct custom_data *lp = init_custom_data(); [...] /* * @handler is NULL and @thread_fn != ...