在我的代码中disable_irq似乎无法真正禁用irq,我有以下代码
rc = devm_request_threaded_irq(&client->dev, irq, NULL,
name_for_ask_question_irq_handler,
IRQF_ONESHOT | IRQF_TRIGGER_FALLING, client->name, data);
if (rc < 0) {
dev_err(&client->dev, "request irq failed \n");
return rc;
}
/* IRQ handler threadeded, this can (and will) sleep */
static irqreturn_t name_for_ask_question_irq_handler(int irq, void *dev)
{
struct touch_point_data *pdata = dev;
dev_err(&pdata->client->dev, "%s:%d irq handler \n", __func__, __LINE__);
return IRQ_HANDLED;
}
static ssize_t wakeup_i2c_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
struct touch_point_data *pdata = dev_get_drvdata(dev);
if (buf[0] == '1') {
disable_irq(pdata->client->irq);
gpiod_direction_output(pdata->gpiod_irq, 0);
udelay(100);
gpiod_direction_output(pdata->gpiod_irq, 1);
udelay(100);
gpiod_direction_output(pdata->gpiod_irq, 0);
udelay(100);
gpiod_direction_output(pdata->gpiod_irq, 1);
udelay(100);
gpiod_direction_input(pdata->gpiod_irq);
dev_err(&pdata->client->dev, "%s:%d disable irq \n", __func__, __LINE__);
} else if (buf[0] == '2') {
enable_irq(pdata->client->irq);
dev_err(&pdata->client->dev, "%s:%d enable irq \n", __func__, __LINE__);
}
return size;
}
and then i get following result:
我很困惑,为什么disable_irq不能真正掩盖中断,看来这种功能只会延迟IRQ,并且在enable_irq之后仍会调用irq_handler。 有谁知道发生了什么事?
答案 0 :(得分:0)
延迟中断的处理直到重新启用才是“屏蔽”中断的含义。这正是disable_irq()
/ enable_irq()
的工作方式。
如果您想忽略某些中断,只需将该逻辑放在中断处理程序中即可。