Skip to content

Commit

Permalink
sensor: adxl372: Convert to new DT_<COMPAT>_<INSTANCE> defines
Browse files Browse the repository at this point in the history
Convert adxl372 sensor driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak authored and MaureenHelm committed Jan 30, 2019
1 parent 0610044 commit 1d210dc
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 41 deletions.
16 changes: 8 additions & 8 deletions drivers/sensor/adxl372/adxl372.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,21 +925,21 @@ static struct adxl372_data adxl372_data;

static const struct adxl372_dev_config adxl372_config = {
#ifdef CONFIG_ADXL372_I2C
.i2c_port = DT_ADXL372_I2C_MASTER_DEV_NAME,
.i2c_addr = DT_ADXL372_I2C_ADDR,
.i2c_port = DT_ADI_ADXL372_0_BUS_NAME,
.i2c_addr = DT_ADI_ADXL372_0_BASE_ADDRESS,
#endif
#ifdef CONFIG_ADXL372_SPI
.spi_port = DT_ADXL372_SPI_DEV_NAME,
.spi_slave = DT_ADXL372_SPI_DEV_SLAVE,
.spi_max_frequency = DT_ADXL372_SPI_BUS_FREQ,
.spi_port = DT_ADI_ADXL372_0_BUS_NAME,
.spi_slave = DT_ADI_ADXL372_0_BASE_ADDRESS,
.spi_max_frequency = DT_ADI_ADXL372_0_SPI_MAX_FREQUENCY,
#ifdef CONFIG_ADXL372_SPI_GPIO_CS
.gpio_cs_port = CONFIG_ADXL372_SPI_GPIO_CS_DRV_NAME,
.cs_gpio = CONFIG_ADXL372_SPI_GPIO_CS_PIN,
#endif
#endif
#ifdef CONFIG_ADXL372_TRIGGER
.gpio_port = DT_ADXL372_GPIO_DEV_NAME,
.int_gpio = DT_ADXL372_GPIO_PIN_NUM,
.gpio_port = DT_ADI_ADXL372_0_INT1_GPIOS_CONTROLLER,
.int_gpio = DT_ADI_ADXL372_0_INT1_GPIOS_PIN,
#endif

.max_peak_detect_mode = IS_ENABLED(CONFIG_ADXL372_PEAK_DETECT_MODE),
Expand Down Expand Up @@ -1011,6 +1011,6 @@ static const struct adxl372_dev_config adxl372_config = {
.op_mode = ADXL372_FULL_BW_MEASUREMENT,
};

DEVICE_AND_API_INIT(adxl372, DT_ADXL372_DEV_NAME, adxl372_init,
DEVICE_AND_API_INIT(adxl372, DT_ADI_ADXL372_0_LABEL, adxl372_init,
&adxl372_data, &adxl372_config, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &adxl372_api_funcs);
File renamed without changes.
2 changes: 1 addition & 1 deletion dts/bindings/sensor/adi,adxl372-spi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inherits:

properties:
compatible:
constraint: "adi,adxl372-spi"
constraint: "adi,adxl372"

int1-gpios:
type: compound
Expand Down
24 changes: 0 additions & 24 deletions samples/sensor/adxl372/dts_fixup.h

This file was deleted.

16 changes: 16 additions & 0 deletions samples/sensor/adxl372/frdm_k64f.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

&i2c1 {
status = "ok";
clock-frequency = <I2C_BITRATE_STANDARD>;
adxl372@11 {
compatible = "adi,adxl372";
reg = <0x11>;
label = "ADXL372";
int1-gpios = <&gpioc 6 0>;
};
};
16 changes: 16 additions & 0 deletions samples/sensor/adxl372/nrf52_pca10040.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

&spi2 {

adxl372@0 {
compatible = "adi,adxl372";
reg = <0>;
spi-max-frequency = <8000000>;
label = "ADXL372";
int1-gpios = <&gpio0 6 0>;
};
};
2 changes: 2 additions & 0 deletions samples/sensor/adxl372/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ tests:
harness: sensor
tags: sensors
depends_on: spi
platform_whitelist: nrf52_pca10040
test_i2c:
harness: sensor
tags: sensors
depends_on: i2c
platform_whitelist: frdm_k64f
extra_args: "CONF_FILE=prj_i2c.conf"
4 changes: 2 additions & 2 deletions samples/sensor/adxl372/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ void main(void)
int i;
char meter[200];

struct device *dev = device_get_binding(DT_ADXL372_DEV_NAME);
struct device *dev = device_get_binding(DT_ADI_ADXL372_0_LABEL);

if (dev == NULL) {
printf("Could not get %s device\n", DT_ADXL372_DEV_NAME);
printf("Could not get %s device\n", DT_ADI_ADXL372_0_LABEL);
return;
}

Expand Down
12 changes: 6 additions & 6 deletions tests/drivers/build_all/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#define DT_ADXL362_SPI_MAX_FREQUENCY 0
#endif

#ifndef DT_ADXL372_DEV_NAME
#define DT_ADXL372_DEV_NAME ""
#define DT_ADXL372_I2C_ADDR 0
#define DT_ADXL372_I2C_MASTER_DEV_NAME ""
#define DT_ADXL372_GPIO_DEV_NAME ""
#define DT_ADXL372_GPIO_PIN_NUM 0
#ifndef DT_ADI_ADXL372_0_LABEL
#define DT_ADI_ADXL372_0_LABEL ""
#define DT_ADI_ADXL372_0_BUS_NAME ""
#define DT_ADI_ADXL372_0_BASE_ADDRESS 0
#define DT_ADI_ADXL372_0_INT1_GPIOS_CONTROLLER ""
#define DT_ADI_ADXL372_0_INT1_GPIOS_PIN 0
#endif

#ifndef DT_AVAGO_APDS9960_0_LABEL
Expand Down

0 comments on commit 1d210dc

Please sign in to comment.