How is it possible to build a loadable module from spi-altera.c ...?
How is it possible to build a loadable module from _spi-altera.c_ when it has no code for creating _udev_ files (i.e., _/dev/spidevXX_); it has no:
static int __init spidev_init(void)
{
int status;
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);
/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers.
*/
BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);
if (status < 0)
return status;
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);
spidev_class = class_create(THIS_MODULE, "spidev");
if (IS_ERR(spidev_class)) {
unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
return PTR_ERR(spidev_class);
}
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);
status = spi_register_driver(&spidev_spi_driver);
if (status < 0) {
class_destroy(spidev_class);
unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
}
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__); return status;
}module_init(spidev_init);
The _printk_'s are of course mine.
---John
My problem is I have an 1553 chip (an avionic data bus) connected to the HPS master (an ARM processor) via an FPGA (soft) SPI controller. This is where the spi-altera.c comes in. It provides the driver/interface to the soft SPI controller on the Arria 10 SoC.
I need an interface now to communicate between the SPI slave (the 1553 chip) and the SPI master (the Arria 10 HPS/ARM).
When I load _spi-altera.ko_ I get the _udev_ files (_/dev/spidevXX_) but not when I load _spidev.ko._ Why? _spi-altera.c _doesn't have an _init_ routine and consequently no call to _register_chrdev_(..) but _spidev.c_ does. What's the relationship between _spi-altera_ and _spidev_? What's the purpose of _spi.c_?
Quoted 55 lines · jchludzinski
How is it possible to build a loadable module from _spi-altera.c_ when it has no code for creating _udev_ files (i.e., _/dev/spidevXX_); it has no:
static int
__initspidev_init(void)
{
int status;
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);/* Claim our 256 reserved device numbers. Then register a class
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers.
*/BUILD_BUG_ON(N_SPI_MINORS > 256);
status =register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);if (status < 0)
return status;
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);
spidev_class=class_create(THIS_MODULE, "spidev"); if (IS_ERR(spidev_class)) {unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
returnPTR_ERR(spidev_class);
}
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);status =
spi_register_driver(&spidev_spi_driver);
if (status < 0) {class_destroy(spidev_class);
unregister_chrdev(SPIDEV_MAJOR,
spidev_spi_driver.driver.name);
}
printk(KERN_ALERT "DEBUG: Passed %s %d \n", __FUNCTION__, __LINE__);return status;
}module_init(spidev_init);The _printk_'s are of course mine.
---John