Skip to content

Commit 5afcea0

Browse files
benjaminbjornssonMaureenHelm
authored andcommitted
drivers: sensor: ens210: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers. Signed-off-by: Benjamin Björnsson <[email protected]>
1 parent a7dc80f commit 5afcea0

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

drivers/sensor/ens210/ens210.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ static uint32_t ens210_crc7(uint32_t bitstream)
4040

4141
#if defined(CONFIG_ENS210_TEMPERATURE_SINGLE) \
4242
|| defined(CONFIG_ENS210_HUMIDITY_SINGLE)
43-
static int ens210_measure(const struct device *i2c_dev,
44-
enum sensor_channel chan)
43+
static int ens210_measure(const struct device *dev, enum sensor_channel chan)
4544
{
45+
struct ens210_data *drv_data = dev->data;
4646
uint8_t buf;
4747
int ret;
4848
const struct ens210_sens_start sense_start = {
@@ -53,7 +53,7 @@ static int ens210_measure(const struct device *i2c_dev,
5353
};
5454

5555
/* Start measuring */
56-
ret = i2c_reg_write_byte(i2c_dev,
56+
ret = i2c_reg_write_byte(drv_data->i2c,
5757
DT_INST_REG_ADDR(0),
5858
ENS210_REG_SENS_START, *(uint8_t *)&sense_start);
5959

@@ -66,7 +66,7 @@ static int ens210_measure(const struct device *i2c_dev,
6666
/* Wait for measurement to be completed */
6767
do {
6868
k_sleep(K_MSEC(2));
69-
ret = i2c_reg_read_byte(i2c_dev,
69+
ret = i2c_reg_read_byte(drv_data->i2c,
7070
DT_INST_REG_ADDR(0),
7171
ENS210_REG_SENS_START, &buf);
7272

@@ -96,7 +96,7 @@ static int ens210_sample_fetch(const struct device *dev,
9696

9797
#if defined(CONFIG_ENS210_TEMPERATURE_SINGLE) \
9898
|| defined(CONFIG_ENS210_HUMIDITY_SINGLE)
99-
ret = ens210_measure(drv_data->i2c, chan);
99+
ret = ens210_measure(dev, chan);
100100
if (ret < 0) {
101101
LOG_ERR("Failed to measure");
102102
return ret;
@@ -190,46 +190,52 @@ static int ens210_channel_get(const struct device *dev,
190190
return 0;
191191
}
192192

193-
static int ens210_sys_reset(const struct device *i2c_dev)
193+
static int ens210_sys_reset(const struct device *dev)
194194
{
195+
struct ens210_data *drv_data = dev->data;
196+
195197
const struct ens210_sys_ctrl sys_ctrl = {
196198
.low_power = 0,
197199
.reset = 1
198200
};
199201
int ret;
200202

201-
ret = i2c_reg_write_byte(i2c_dev, DT_INST_REG_ADDR(0),
203+
ret = i2c_reg_write_byte(drv_data->i2c, DT_INST_REG_ADDR(0),
202204
ENS210_REG_SYS_CTRL, *(uint8_t *)&sys_ctrl);
203205
if (ret < 0) {
204206
LOG_ERR("Failed to set SYS_CTRL to 0x%x", *(uint8_t *)&sys_ctrl);
205207
}
206208
return ret;
207209
}
208210

209-
static int ens210_sys_enable(const struct device *i2c_dev, uint8_t low_power)
211+
static int ens210_sys_enable(const struct device *dev, uint8_t low_power)
210212
{
213+
struct ens210_data *drv_data = dev->data;
214+
211215
const struct ens210_sys_ctrl sys_ctrl = {
212216
.low_power = low_power,
213217
.reset = 0
214218
};
215219
int ret;
216220

217-
ret = i2c_reg_write_byte(i2c_dev, DT_INST_REG_ADDR(0),
221+
ret = i2c_reg_write_byte(drv_data->i2c, DT_INST_REG_ADDR(0),
218222
ENS210_REG_SYS_CTRL, *(uint8_t *)&sys_ctrl);
219223
if (ret < 0) {
220224
LOG_ERR("Failed to set SYS_CTRL to 0x%x", *(uint8_t *)&sys_ctrl);
221225
}
222226
return ret;
223227
}
224228

225-
static int ens210_wait_boot(const struct device *i2c_dev)
229+
static int ens210_wait_boot(const struct device *dev)
226230
{
231+
struct ens210_data *drv_data = dev->data;
232+
227233
int cnt;
228234
int ret;
229235
struct ens210_sys_stat sys_stat;
230236

231237
for (cnt = 0; cnt <= CONFIG_ENS210_MAX_STAT_RETRIES; cnt++) {
232-
ret = i2c_reg_read_byte(i2c_dev, DT_INST_REG_ADDR(0),
238+
ret = i2c_reg_read_byte(drv_data->i2c, DT_INST_REG_ADDR(0),
233239
ENS210_REG_SYS_STAT,
234240
(uint8_t *)&sys_stat);
235241

@@ -243,10 +249,10 @@ static int ens210_wait_boot(const struct device *i2c_dev)
243249
}
244250

245251
if (cnt == 0) {
246-
ens210_sys_reset(i2c_dev);
252+
ens210_sys_reset(dev);
247253
}
248254

249-
ens210_sys_enable(i2c_dev, 0);
255+
ens210_sys_enable(dev, 0);
250256

251257
k_sleep(K_MSEC(2));
252258
}
@@ -292,7 +298,7 @@ static int ens210_init(const struct device *dev)
292298
}
293299

294300
/* Wait until the device is ready. */
295-
ret = ens210_wait_boot(drv_data->i2c);
301+
ret = ens210_wait_boot(dev);
296302
if (ret < 0) {
297303
return -EIO;
298304
}
@@ -316,7 +322,7 @@ static int ens210_init(const struct device *dev)
316322

317323
/* Enable low power mode */
318324
if ((ENS210_T_RUN | ENS210_H_RUN) == 0) {
319-
ens210_sys_enable(drv_data->i2c, 1);
325+
ens210_sys_enable(dev, 1);
320326
}
321327

322328
/* Set measurement mode*/

0 commit comments

Comments
 (0)