目前共有2篇帖子。 字體大小:較小 - 100% (默認)▼  內容轉換:不轉換▼
 
點擊 回復
7 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)
 

本帖信息

點擊數:7 回複數:1
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2026-6-12 14:57
 
©2010-2026 Purasbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。