From 10a442824ad03cdcafdc9b898b20731e7c3c52f6 Mon Sep 17 00:00:00 2001 From: Dan Kalowsky Date: Thu, 11 Feb 2016 13:13:47 -0800 Subject: [PATCH] samples : incorrectly addressing SPI port Correcting the discovery method for SPI port. The current method is based upon knowledge of a specific port and a *_DRV_NAME value. Instead this should be based upon the use of the device_get_binding() for SPI_0. Change-Id: I250f5dddf2a2e79c4714addf647b0c74bd79ec5a Signed-off-by: Dan Kalowsky --- samples/drivers/spi_lsm9ds0/src/main.c | 10 +--------- samples/drivers/w25q80bl/src/main.c | 13 +++---------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/samples/drivers/spi_lsm9ds0/src/main.c b/samples/drivers/spi_lsm9ds0/src/main.c index 5c63f50d15..f86d3d2cfc 100644 --- a/samples/drivers/spi_lsm9ds0/src/main.c +++ b/samples/drivers/spi_lsm9ds0/src/main.c @@ -21,14 +21,6 @@ #include -#if defined(CONFIG_SPI_QMSI_PORT_0_DRV_NAME) -#define SPI_PORT_0 CONFIG_SPI_QMSI_PORT_0_DRV_NAME -#elif defined(CONFIG_SPI_DW_PORT_0_DRV_NAME) -#define SPI_PORT_0 CONFIG_SPI_DW_PORT_0_DRV_NAME -#else -#error "Unknown SPI driver implementation" -#endif - #define LSM9DS0_WHOAMI_G 0xf #define LSM9DS0_READ_MASK 0x80 @@ -53,7 +45,7 @@ static uint8_t lsm9ds0_read_whoami_g(struct device *dev) void main(void) { struct spi_config config = { 0 }; - struct device *spi_mst_0 = device_get_binding(SPI_PORT_0); + struct device *spi_mst_0 = device_get_binding("SPI_0"); uint8_t id; int err; diff --git a/samples/drivers/w25q80bl/src/main.c b/samples/drivers/w25q80bl/src/main.c index 4e93f70860..fc9640385e 100644 --- a/samples/drivers/w25q80bl/src/main.c +++ b/samples/drivers/w25q80bl/src/main.c @@ -25,14 +25,6 @@ #error "This sample requires the GPIO pin as Chip Select feature" #endif -#if defined(CONFIG_SPI_QMSI_PORT_0_DRV_NAME) -#define SPI_PORT_0 CONFIG_SPI_QMSI_PORT_0_DRV_NAME -#elif defined(CONFIG_SPI_DW_PORT_0_DRV_NAME) -#define SPI_PORT_0 CONFIG_SPI_DW_PORT_0_DRV_NAME -#else -#error "Unknown SPI driver implementation" -#endif - #define W25Q80BL_MANUFACTURER_ID 0x90 static uint8_t rx_buffer[6], tx_buffer[6]; @@ -62,7 +54,7 @@ int w25q80bl_read_id(struct device *dev, uint8_t *manufacturer, uint8_t *devicei int main(void) { struct spi_config config = { 0 }; - struct device *spi_mst_0 = device_get_binding(SPI_PORT_0); + struct device *spi_mst_0 = device_get_binding("SPI_0"); uint8_t manufacturer, device_id; int err; @@ -92,7 +84,8 @@ int main(void) return DEV_FAIL; } - printk("SPI Flash Manufacturer %x Device Id %x\n", manufacturer, device_id); + printk("SPI Flash Manufacturer %x Device Id %x\n", manufacturer, + device_id); return DEV_OK; }