#define PSY_HAVE_PUT
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
+#define SPI_DEV_MODALIAS "spidev"
+#define SPI_NOR_MODALIAS "spi-nor"
+#else
+#define SPI_DEV_MODALIAS "spidev"
+#define SPI_NOR_MODALIAS "m25p80"
+#endif
+
#endif /* __GREYBUS_KERNEL_VER_H */
struct spi_board_info spi_board = { {0} };
struct spi_device *spidev;
int ret;
+ u8 dev_type;
request.chip_select = cs;
if (ret < 0)
return ret;
- memcpy(spi_board.modalias, response.name, sizeof(spi_board.modalias));
+ dev_type = response.device_type;
+
+ if (dev_type == GB_SPI_SPI_DEV)
+ strlcpy(spi_board.modalias, SPI_DEV_MODALIAS,
+ sizeof(spi_board.modalias));
+ else if (dev_type == GB_SPI_SPI_NOR)
+ strlcpy(spi_board.modalias, SPI_NOR_MODALIAS,
+ sizeof(spi_board.modalias));
+ else if (dev_type == GB_SPI_SPI_MODALIAS)
+ memcpy(spi_board.modalias, response.name,
+ sizeof(spi_board.modalias));
+ else
+ return -EINVAL;
+
spi_board.mode = le16_to_cpu(response.mode);
spi_board.bus_num = master->bus_num;
spi_board.chip_select = cs;
spidev = spi_new_device(master, &spi_board);
if (!spidev)
- ret = -EINVAL;
+ return -EINVAL;
return 0;
}