我有以下设备树覆盖片段,加载时spidev
会添加两次:
fragment@0 {
target = <&fpga>;
__overlay__ {
#address-cells = <1>;
#size-cells = <1>;
spi2@600 {
status = "okay";
compatible = "opencores,spiocv2";
#address-cells = <1>;
#size-cells = <0>;
reg = <0 0x800>;
cell-index = <2>; // bus number
spidev0 {
spi-max-frequency = <25000000>;
reg = <0>;
compatible = "spidev";
};
};
};
};
- 第一个通路
of_overlay_create -> ... -> notifier_call_chain -> of_platform_notify -> ... -> device_attach -> ... -> spioc_driver_probe -> spi_register_master -> of_register_spi_devices -> of_register_spi_device -> spi_add_device
- 然后再次通过
of_overlay_create -> ... -> notifier_call_chain -> of_spi_notify -> of_register_spi_device -> spi_add_device
因为它首先正确加载,/dev/spidev2.0
可用且工作正常,但第二次调用会导致丑陋的错误:
[ 1.814623] opencores_spi 13e0000f3300000.spi2: chipselect 0 already in use
[ 1.836491] spi_master spi2: spi_device register error /fpga/spi2@600/spidev0
[ 1.857652] of_spi_notify: failed to create for '/fpga/spi2@600/spidev0'
[ 1.877495] __of_changeset_entry_notify: notifier error @/fpga/spi2@600/spidev0
什么是防止重复加载的干净且正确的方法?或者如何阻止通知者通知平台和SPI?