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

cskyrain cskyrain 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
/* 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是如何才会被调用的。
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
cskyrain
Linux_Kernel 4,469 成员 17,458 内容