spidev.c中spidev_probe函数没有被调用

cskyrain 2010-07-05 02:30:33
/* The main reason to have this class is to make mdev/udev create the
* /dev/spidevB.C character device nodes exposing our userspace API.
* It also simplifies memory management.
*/

static struct class spidev_class = {
.name = "spidev",
.owner = THIS_MODULE,
};

/*-------------------------------------------------------------------------*/

static int spidev_probe(struct spi_device *spi)
{
struct spidev_data *spidev;
int status;
unsigned long minor;

/* Allocate driver data */
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
printk("in the spidev_probe\n");
if (!spidev)
return -ENOMEM;

/* Initialize the driver data */
spidev->spi = spi;
mutex_init(&spidev->buf_lock);

INIT_LIST_HEAD(&spidev->device_entry);

/* If we can allocate a minor number, hook up this device.
* Reusing minors is fine so long as udev or mdev is working.
*/
mutex_lock(&device_list_lock);
minor = find_first_zero_bit(minors, N_SPI_MINORS);
if (minor < N_SPI_MINORS) {
spidev->dev.parent = &spi->dev;
spidev->dev.class = &spidev_class;
spidev->dev.devt = MKDEV(SPIDEV_MAJOR, minor);
snprintf(spidev->dev.bus_id, sizeof spidev->dev.bus_id,
"spidev%d.%d",
spi->master->bus_num, spi->chip_select);
status = device_register(&spidev->dev);
} else {
dev_dbg(&spi->dev, "no minor number available!\n");
status = -ENODEV;
}
if (status == 0) {
set_bit(minor, minors);
dev_set_drvdata(&spi->dev, spidev);
list_add(&spidev->device_entry, &device_list);
}
mutex_unlock(&device_list_lock);

if (status != 0)
kfree(spidev);

return status;
}


把相关的config都配置了,但是编译后的内核启动后并没有调用spidev_probe探测函数。这个probe是如何才会被调用的。
...全文
962 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
crazy_srong 2010-07-17
  • 打赏
  • 举报
回复
设备初始化地方加入,在你的源码目录/arch/arm/mach-****/board-mach****.c具体参照触摸屏写入 ,完成设备注册 就能用了
mercyzx 2010-07-16
  • 打赏
  • 举报
回复
首先 驱动名和设备名在driver_register中匹配了就会被调用啊
iguest 2010-07-14
  • 打赏
  • 举报
回复
调用了没?
weib_2007 2010-07-13
  • 打赏
  • 举报
回复
同问。
zznda4 2010-07-13
  • 打赏
  • 举报
回复
这个问题是,你在初始化那个位置的名字没有和spidev.c spi_driver这个结构的name赋值的时候,两个名字不一样导致,一定要使初始化spi地方的name和spidev.c的name一样才可以,要不probe是不会执行的
karlzheng 2010-07-06
  • 打赏
  • 举报
回复
要在平台设备初始化那里加载

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧