目前共有2篇帖子。 字体大小:较小 - 100% (默认)▼  内容转换:不转换▼
 
点击 回复
11 1
gpiod_is_active_low - test whether a GPIO is active-low or not
武林盟主 二十一级
1楼 发表于:2026-6-12 14:54
/**
 * gpiod_is_active_low - test whether a GPIO is active-low or not
 * @desc: the gpio descriptor to test
 *
 * Returns 1 if the GPIO is active-low, 0 otherwise.
 */
int gpiod_is_active_low(const struct gpio_desc *desc)
{
        VALIDATE_DESC(desc);
        return test_bit(FLAG_ACTIVE_LOW, &desc->flags);
}
EXPORT_SYMBOL_GPL(gpiod_is_active_low);
武林盟主 二十一级
2楼 发表于:2026-6-12 14:57

int irq, ret;

unsigned long irqflags;


// 配置中断

drvdata->gpio = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN);

if (IS_ERR(drvdata->gpio)) {

    dev_err(&pdev->dev, "failed to request GPIO\n");

    return PTR_ERR(drvdata->gpio);

}

irq = gpiod_to_irq(drvdata->gpio);

irqflags = gpiod_is_active_low(drvdata->gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;

ret = devm_request_irq(&pdev->dev, irq, system_power_irq_handler, irqflags, "system_power", drvdata);

if (ret != 0) {

    dev_err(&pdev->dev, "failed to request irq\n");

    return ret;

}

 

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:11 回复数:1
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2026-6-12 14:57
 
©2010-2026 Purasbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。