drivers: sensors: Convert to new DT_INST macros

Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-03-30 10:08:08 -05:00 committed by Maureen Helm
commit 9872dc16b5
66 changed files with 491 additions and 399 deletions

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT ams_iaqcore
#include <device.h>
#include <drivers/i2c.h>
#include <kernel.h>
@ -33,7 +35,7 @@ static int iaqcore_sample_fetch(struct device *dev, enum sensor_channel chan)
for (tries = 0; tries < CONFIG_IAQ_CORE_MAX_READ_RETRIES; tries++) {
ret = i2c_transfer(drv_data->i2c, &msg, 1,
DT_INST_0_AMS_IAQCORE_BASE_ADDRESS);
DT_INST_REG_ADDR(0));
if (ret < 0) {
LOG_ERR("Failed to read registers data [%d].", ret);
return -EIO;
@ -99,10 +101,10 @@ static int iaq_core_init(struct device *dev)
{
struct iaq_core_data *drv_data = dev->driver_data;
drv_data->i2c = device_get_binding(DT_INST_0_AMS_IAQCORE_BUS_NAME);
drv_data->i2c = device_get_binding(DT_INST_BUS_LABEL(0));
if (drv_data->i2c == NULL) {
LOG_ERR("Failed to get pointer to %s device!",
DT_INST_0_AMS_IAQCORE_BUS_NAME);
DT_INST_BUS_LABEL(0));
return -EINVAL;
}
@ -111,6 +113,6 @@ static int iaq_core_init(struct device *dev)
static struct iaq_core_data iaq_core_driver;
DEVICE_AND_API_INIT(iaq_core, DT_INST_0_AMS_IAQCORE_LABEL, iaq_core_init,
DEVICE_AND_API_INIT(iaq_core, DT_INST_LABEL(0), iaq_core_init,
&iaq_core_driver, NULL, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &iaq_core_driver_api);