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 <daniel.kalowsky@intel.com>
This commit is contained in:
Dan Kalowsky 2016-02-11 13:13:47 -08:00 committed by Gerrit Code Review
parent a3edcaa816
commit 10a442824a
2 changed files with 4 additions and 19 deletions

View file

@ -21,14 +21,6 @@
#include <misc/printk.h>
#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;

View file

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