Skip to content
Permalink
Browse files

sensor: lis2dh: Use general DT_<COMPAT>_BUS_<BUS> define.

Match what other drivers are doing and use the general BUS define.
Change DT_ST_LIS2DH_0_BUS_SPI to DT_ST_LIS2DH_BUS_SPI

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
  • Loading branch information...
galak committed Jun 22, 2019
1 parent 9f857c3 commit 0a99f53c80edabfb2ecbe31d66332430d9c355f8
Showing with 11 additions and 11 deletions.
  1. +10 −10 drivers/sensor/lis2dh/lis2dh.h
  2. +1 −1 tests/drivers/build_all/dts_fixup.h
@@ -18,7 +18,7 @@
#define LIS2DH_BUS_ADDRESS DT_INST_0_ST_LIS2DH_BASE_ADDRESS
#define LIS2DH_BUS_DEV_NAME DT_INST_0_ST_LIS2DH_BUS_NAME

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
#include <spi.h>

#define LIS2DH_SPI_READ_BIT BIT(7)
@@ -161,7 +161,7 @@
#define LIS2DH_REG_INT2_DUR 0x37

/* sample buffer size includes status register */
#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
#define LIS2DH_BUF_SZ 8
#define LIS2DH_DATA_OFS 1
#else
@@ -184,7 +184,7 @@
union lis2dh_sample {
u8_t raw[LIS2DH_BUF_SZ];
struct {
#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
u8_t dummy;
#endif
u8_t status;
@@ -193,7 +193,7 @@ union lis2dh_sample {
};

struct lis2dh_data {
#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
struct device *spi;
struct spi_config spi_cfg;
#else
@@ -226,7 +226,7 @@ struct lis2dh_data {
#endif /* CONFIG_LIS2DH_TRIGGER */
};

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
int lis2dh_spi_access(struct lis2dh_data *ctx, u8_t cmd,
void *data, size_t length);
#endif
@@ -235,7 +235,7 @@ static inline int lis2dh_bus_configure(struct device *dev)
{
struct lis2dh_data *lis2dh = dev->driver_data;

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
lis2dh->spi = device_get_binding(LIS2DH_BUS_DEV_NAME);
if (lis2dh->spi == NULL) {
LOG_ERR("Could not get pointer to %s device",
@@ -267,7 +267,7 @@ static inline int lis2dh_burst_read(struct device *dev, u8_t start_addr,
{
struct lis2dh_data *lis2dh = dev->driver_data;

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
start_addr |= LIS2DH_SPI_READ_BIT | LIS2DH_SPI_AUTOINC_ADDR;

return lis2dh_spi_access(lis2dh, start_addr, buf, num_bytes);
@@ -285,7 +285,7 @@ static inline int lis2dh_reg_read_byte(struct device *dev, u8_t reg_addr,
{
struct lis2dh_data *lis2dh = dev->driver_data;

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
reg_addr |= LIS2DH_SPI_READ_BIT;

return lis2dh_spi_access(lis2dh, reg_addr, value, 1);
@@ -302,7 +302,7 @@ static inline int lis2dh_burst_write(struct device *dev, u8_t start_addr,
{
struct lis2dh_data *lis2dh = dev->driver_data;

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
start_addr |= LIS2DH_SPI_AUTOINC_ADDR;

return lis2dh_spi_access(lis2dh, start_addr, buf, num_bytes);
@@ -320,7 +320,7 @@ static inline int lis2dh_reg_write_byte(struct device *dev, u8_t reg_addr,
{
struct lis2dh_data *lis2dh = dev->driver_data;

#if defined(DT_ST_LIS2DH_0_BUS_SPI)
#if defined(DT_ST_LIS2DH_BUS_SPI)
reg_addr &= LIS2DH_SPI_ADDR_MASK;

return lis2dh_spi_access(lis2dh, reg_addr, &value, 1);
@@ -243,7 +243,7 @@
#define DT_INST_0_ST_LIS2DH_IRQ_GPIOS_CONTROLLER ""
#define DT_INST_0_ST_LIS2DH_IRQ_GPIOS_PIN 0
#define DT_INST_0_ST_LIS2DH_SPI_MAX_FREQUENCY 6400000
#define DT_ST_LIS2DH_0_BUS_SPI 1
#define DT_ST_LIS2DH_BUS_SPI 1
#endif

#ifndef DT_INST_0_ST_LSM6DSL_LABEL

0 comments on commit 0a99f53

Please sign in to comment.
You can’t perform that action at this time.