#endif
#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.61:2021:07:13"
-#define NEURONSPI_MAX_DEVS 3
+#define NEURONSPI_MAX_DEVS 7 //Maximal SPI card count
#define NEURONSPI_MAX_UART 16
#define NEURONSPI_BUFFER_MAX 1152
#define NEURONSPI_HEADER_LENGTH 10
struct neuronspi_board_combination NEURONSPI_BOARD_E4AI4AOU4DI5RO_HW_COMBINATION[] = {NEURONSPI_BOARD_E4AI4AOU4DI5RO_HW_DEFINITION};
-// E-16Di_U-14Di (M303)
+// IRIS_BOARD_ICDIS4
#define IRIS_BOARD_ICDIS4_HW_DEFINITION_BLOCK_SIZE 28 //Reg count + 4
static u32 IRIS_BOARD_ICDIS4_HW_DEFINITION_BLOCK[IRIS_BOARD_ICDIS4_HW_DEFINITION_BLOCK_SIZE] = {
0, 10, // Register block beginning and size
//devtype = (struct neuronspi_devtype *)id_entry->driver_data;
}
+ //Validate board index range
+ if ((n_spi->neuron_index < 0) || ((n_spi->neuron_index > NEURONSPI_MAX_DEVS))) {
+ printk(KERN_ERR "UNIPISPI: %s has invalid board index (%d)!\n", *(&spi->dev.of_node->full_name), n_spi->neuron_index);
+ kfree(n_spi);
+ return -ENODEV;
+ }
+
+ //Check if board index is not already assigned
+ if (neuronspi_s_dev[n_spi->neuron_index] != NULL) {
+ printk(KERN_ERR "UNIPISPI: %s has duplicit board index (%d)!\n", *(&spi->dev.of_node->full_name), n_spi->neuron_index);
+ kfree(n_spi);
+ return -ENODEV;
+ }
// We perform an initial probe of registers 1000-1004 to identify the device, using a premade message
neuronspi_spi_send_const_op(spi, &UNIPISPI_IDLE_MESSAGE, &recv_op, 0, NEURONSPI_DEFAULT_FREQ, 25);
spi_set_drvdata(spi, n_spi);
neuronspi_s_dev[n_spi->neuron_index] = spi;
- if (neuronspi_probe_count == NEURONSPI_MAX_DEVS) {
+ if (neuronspi_probe_count == NEURONSPI_MAX_DEVS) { //TODO - model guess procedure is obsolete - will be removed
neuronspi_model_id = neuronspi_find_model_id(neuronspi_probe_count);
}
spin_unlock_irqrestore(neuronspi_probe_spinlock, flags);