参考韦东山老师的GPIO教程,编写一个虚拟的GPIO Controller时,安装LED驱动在获取gpio引脚时出现问题了,请问该怎么解决?
报错信息:
设备树信息如下:
虚拟gpio controller驱动代码的probe如下:
static int virtual_gpio_probe(struct platform_device *pdev)
{
int ret;
unsigned int val;
printk("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__);
/* 1. 分配gpio_chip */
g_virt_gpio = devm_kzalloc(&pdev->dev, sizeof(*g_virt_gpio), GFP_KERNEL);
/* 2. 设置gpio_chip */
/* 2.1 设置函数 */
g_virt_gpio->label = pdev->name;
g_virt_gpio->direction_output = virt_gpio_direction_output;
g_virt_gpio->direction_input = virt_gpio_direction_input;
g_virt_gpio->get = virt_gpio_get_value;
g_virt_gpio->set = virt_gpio_set_value;
g_virt_gpio->owner = THIS_MODULE;
/* 2.2 设置base、ngpio值 */
g_virt_gpio->base = -1;
ret = of_property_read_u32(pdev->dev.of_node, "ngpios", &val);
g_virt_gpio->ngpio = val;
/* 3. 注册gpio_chip */
ret = devm_gpiochip_add_data(&pdev->dev, g_virt_gpio, NULL);
if (ret) {
printk("devm_gpiochip_add_data fail!\n");
}
return 0;
}
myled、gpio_virt节点也是在的: