sensor: adt7420: Convert to new DT_<COMPAT>_<INSTANCE> defines

Convert adt7420 sensor driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2019-01-29 13:47:38 -06:00 committed by Maureen Helm
commit 4f334970ad
6 changed files with 29 additions and 21 deletions

View file

@ -216,14 +216,14 @@ static int adt7420_init(struct device *dev)
static struct adt7420_data adt7420_driver; static struct adt7420_data adt7420_driver;
static const struct adt7420_dev_config adt7420_config = { static const struct adt7420_dev_config adt7420_config = {
.i2c_port = DT_ADT7420_I2C_MASTER_DEV_NAME, .i2c_port = DT_ADI_ADT7420_0_BUS_NAME,
.i2c_addr = DT_ADT7420_I2C_ADDR, .i2c_addr = DT_ADI_ADT7420_0_BASE_ADDRESS,
#ifdef CONFIG_ADT7420_TRIGGER #ifdef CONFIG_ADT7420_TRIGGER
.gpio_port = DT_ADT7420_GPIO_DEV_NAME, .gpio_port = DT_ADI_ADT7420_0_INT_GPIOS_CONTROLLER,
.int_gpio = DT_ADT7420_GPIO_PIN_NUM, .int_gpio = DT_ADI_ADT7420_0_INT_GPIOS_PIN,
#endif #endif
}; };
DEVICE_AND_API_INIT(adt7420, DT_ADT7420_NAME, adt7420_init, &adt7420_driver, DEVICE_AND_API_INIT(adt7420, DT_ADI_ADT7420_0_LABEL, adt7420_init, &adt7420_driver,
&adt7420_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &adt7420_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
&adt7420_driver_api); &adt7420_driver_api);

View file

@ -1,9 +0,0 @@
#if defined(CONFIG_HAS_DTS_I2C)
#ifndef DT_ADT7420_NAME
#define DT_ADT7420_NAME ""
#define DT_ADT7420_I2C_ADDR 0
#define DT_ADT7420_I2C_MASTER_DEV_NAME ""
#endif
#endif /* CONFIG_HAS_DTS_I2C */

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
&i2c1 {
status = "ok";
clock-frequency = <I2C_BITRATE_STANDARD>;
adt7420@13 {
compatible = "adi,adt7420";
reg = <0x13>;
label = "ADT7420";
int-gpios = <&gpioc 6 0>;
};
};

View file

@ -4,4 +4,5 @@ tests:
test: test:
harness: sensor harness: sensor
tags: sensors tags: sensors
platform_whitelist: frdm_k64f
depends_on: i2c depends_on: i2c

View file

@ -91,7 +91,7 @@ static void process(struct device *dev)
void main(void) void main(void)
{ {
struct device *dev = device_get_binding(DT_ADT7420_NAME); struct device *dev = device_get_binding(DT_ADI_ADT7420_0_LABEL);
__ASSERT(dev != NULL, "Failed to get device binding"); __ASSERT(dev != NULL, "Failed to get device binding");
printf("device is %p, name is %s\n", dev, dev->config->name); printf("device is %p, name is %s\n", dev, dev->config->name);

View file

@ -1,11 +1,11 @@
#if defined(CONFIG_HAS_DTS_I2C) #if defined(CONFIG_HAS_DTS_I2C)
#ifndef DT_ADT7420_NAME #ifndef DT_ADI_ADT7420_0_LABEL
#define DT_ADT7420_NAME "" #define DT_ADI_ADT7420_0_LABEL ""
#define DT_ADT7420_I2C_ADDR 0 #define DT_ADI_ADT7420_0_BASE_ADDRESS 0
#define DT_ADT7420_I2C_MASTER_DEV_NAME "" #define DT_ADI_ADT7420_0_BUS_NAME ""
#define DT_ADT7420_GPIO_DEV_NAME "" #define DT_ADI_ADT7420_0_INT_GPIOS_CONTROLLER ""
#define DT_ADT7420_GPIO_PIN_NUM 0 #define DT_ADI_ADT7420_0_INT_GPIOS_PIN 0
#endif #endif
#ifndef DT_ADXL362_DEV_NAME #ifndef DT_ADXL362_DEV_NAME