Re: spidev.c ?


jchludzinski
 

root@arria10:~# find /sys/ -name 'spi*'
/sys/kernel/debug/clk/spi_m_clk /sys/kernel/debug/tracing/events/spi /sys/kernel/debug/tracing/events/spi/spi_controller_idle /sys/kernel/debug/tracing/events/spi/spi_controller_busy /sys/kernel/debug/tracing/events/spi/spi_message_submit /sys/kernel/debug/tracing/events/spi/spi_message_start /sys/kernel/debug/tracing/events/spi/spi_message_done /sys/kernel/debug/tracing/events/spi/spi_transfer_start /sys/kernel/debug/tracing/events/spi/spi_transfer_stop /sys/kernel/debug/regmap/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0 /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/spi0.0/statistics/spi_sync_immediate /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_async /sys/devices/platform/soc/ffda5000.spi/spi_master/spi0/statistics/spi_sync_immediate /sys/class/spidev /sys/class/spi_master /sys/class/spi_master/spi0 /sys/firmware/devicetree/base/__symbols__/spi2 /sys/firmware/devicetree/base/__symbols__/spi0 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_1 /sys/firmware/devicetree/base/__symbols__/spi_m_clk /sys/firmware/devicetree/base/__symbols__/spi1 /sys/firmware/devicetree/base/__symbols__/spin_ctrl_2 /sys/firmware/devicetree/base/soc/spi@ff809000 /sys/firmware/devicetree/base/soc/spi@ffda5000 /sys/firmware/devicetree/base/soc/spi@ffda5000/resource-manager@0/spi-max-frequency /sys/firmware/devicetree/base/soc/clkmgr@ffd04000/clocks/spi_m_clk /sys/firmware/devicetree/base/soc/spi@ffda4000 /sys/firmware/devicetree/base/spi@0xc00c0800 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0 /sys/firmware/devicetree/base/spi@0xc00c0800/spidev@0/spi-max-frequency /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@200/spin-rph /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller /sys/firmware/devicetree/base/testcase-data-2/fairway-1/ride@100/spin-controller-names /sys/firmware/devicetree/base/testcase-data-2/substation@100/motor-1/spin /sys/bus/platform/drivers/spi_altera /sys/bus/spi /sys/bus/spi/devices/spi0.0 /sys/bus/spi/drivers/spi-nor /sys/bus/spi/drivers/altr_a10sr/spi0.0 /sys/bus/spi/drivers/spidev /sys/module/spidev /sys/module/spidev/drivers/spi:spidev /sys/module/spi_altera



On 2021-03-18 03:44, Zoran wrote:
I am guessing here.... But what do you have while executing the
following command being in /sys
 as root?

root@arm:/sys# find . -name spi*

Zee
_______

On Wed, Mar 17, 2021 at 5:41 PM jchludzinski via
lists.yoctoproject.org
<jchludzinski=vivaldi.net@...> wrote:

In the YOCTO/Linux source tree there's drivers/spi/ which has all the source for SPI drivers. There's only 1 file, spidev.c, which has:

static int __init spidev_init(void)
{
        int status;

        /* 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);
        if (status < 0)
                return status;

        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);
        }

        status = spi_register_driver(&spidev_spi_driver);
        if (status < 0) {
                class_destroy(spidev_class);
                unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
        }
        return status;
}
module_init(spidev_init);

... for creating device files in udev.

So when I use 'make nconfig' to specifiy that I want a loadable module for the ALTERA SPI driver, why don't I see a spidev.o file in drivers/spi/ ?

How does spi-altera.ko create device files without a call to register_chrdev(...).

How is it a loadable module without module_init(...)?

When I separately build spidev.c as an .ko and try loading it, I get: "Device or resourse busy"

---John





-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#52762): https://lists.yoctoproject.org/g/yocto/message/52762
Mute This Topic: https://lists.yoctoproject.org/mt/81407811/5071304
Group Owner: yocto+owner@...
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[jchludzinski@...]

Join yocto@lists.yoctoproject.org to automatically receive all group messages.