为什么我们需要键盘驱动程序的下半部分

时间:2014-11-08 12:08:01

标签: linux-kernel linux-device-driver

我知道下半部分主要针对需要很长时间的活动。 我已经看到了关键板驱动程序中的下半部分的引用,例如adp5588-keys.c / atkbd.c / matrix-keypad.c等。请任何人帮助我理解为什么我们需要在键盘中的下半部分,比如它的驱动器功能是捕获关键的evnts(主要是)。

来自adp5588-keys.c:

来自探索的

INIT_DELAYED_WORK(&kpad->work, adp5588_work);
来自Irq的

static irqreturn_t adp5588_irq(int irq, void *handle)
{
struct adp5588_kpad *kpad = handle;

/*
* use keventd context to read the event fifo registers
* Schedule readout at least 25ms after notification for
* REVID < 4
*/

schedule_delayed_work(&kpad->work, kpad->delay);

return IRQ_HANDLED;
}

下半部分:

static void adp5588_work(struct work_struct *work)
{
struct adp5588_kpad *kpad = container_of(work,
struct adp5588_kpad, work.work);
struct i2c_client *client = kpad->client;
int status, ev_cnt;

status = adp5588_read(client, INT_STAT);

if (status & ADP5588_OVR_FLOW_INT)  /* Unlikely and should never happen */
dev_err(&client->dev, "Event Overflow Error\n");

if (status & ADP5588_KE_INT) {
ev_cnt = adp5588_read(client, KEY_LCK_EC_STAT) & ADP5588_KEC;
if (ev_cnt) {
adp5588_report_events(kpad, ev_cnt);
input_sync(kpad->input);
}
}
adp5588_write(client, INT_STAT, status); /* Status is W1C */
}

BR, &安培;斯里达尔

0 个答案:

没有答案