因IIO框架下IMU驱动在定时器中断内调用报错,于是想通过使用struct spidev_data试一试,
static ssize_t
spidev_sync_front(struct spidev_data *spidev, struct spi_message *message)
{
int status;
struct spi_device *spi;
spin_lock_irq(&spidev->spi_lock);
spi = spidev->spi;
spin_unlock_irq(&spidev->spi_lock);
if (spi == NULL)
status = -ESHUTDOWN;
else
status = spi_sync(spi, message);
if (status == 0)
status = message->actual_length;
return status;
}
编译时出现了:
icm42686.c:111:23: error: dereferencing pointer to incomplete type ‘struct spidev_data’
spin_lock_irq(&spidev->spi_lock);
在驱动里实现了SPI读写,用到了这个结构体。查找原因,是因为这个结构体放在了spidev.c里,并没有放在头文件中。驱动在编译时找不到这个结构体定义,就报了这个错误。
解决方法:
1.把 struct spidev_data 结构体在使用的驱动代码重新定义,能解决问题,但不好。为了测试,就直接重新定义了一遍,试过就删除了。
2.把 struct spidev_data 结构体移到头文件中。