Skip to content

Commit 45a6de6

Browse files
gmarullgalak
authored andcommitted
drivers: fix pm callback signature
For some reason a few drivers were not converted to the new device PM callback signature. The reason may be because the device PM part is compiled only when CONFIG_PM_DEVICE=y, a condition not enabled in CI by default. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 6ce18c6 commit 45a6de6

File tree

8 files changed

+27
-26
lines changed

8 files changed

+27
-26
lines changed

drivers/display/display_st7735r.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static int st7735r_enter_sleep(struct st7735r_data *data)
520520
}
521521

522522
static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
523-
void *context, pm_device_cb cb, void *arg)
523+
uint32_t *state, pm_device_cb cb, void *arg)
524524
{
525525
int ret = 0;
526526
struct st7735r_data *data = (struct st7735r_data *)dev->data;
@@ -544,7 +544,7 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
544544
break;
545545

546546
case PM_DEVICE_STATE_GET:
547-
*((uint32_t *)context) = data->pm_state;
547+
*state = data->pm_state;
548548

549549
break;
550550

@@ -553,7 +553,7 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
553553
}
554554

555555
if (cb != NULL) {
556-
cb(dev, ret, context, arg);
556+
cb(dev, ret, state, arg);
557557
}
558558

559559
return ret;

drivers/sensor/apds9960/apds9960.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,14 @@ static int apds9960_init_interrupt(const struct device *dev)
410410
#ifdef CONFIG_PM_DEVICE
411411
static int apds9960_device_ctrl(const struct device *dev,
412412
uint32_t ctrl_command,
413-
void *context, pm_device_cb cb, void *arg)
413+
uint32_t *state, pm_device_cb cb, void *arg)
414414
{
415415
const struct apds9960_config *config = dev->config;
416416
struct apds9960_data *data = dev->data;
417417
int ret = 0;
418418

419419
if (ctrl_command == PM_DEVICE_STATE_SET) {
420-
uint32_t device_pm_state = *(uint32_t *)context;
420+
uint32_t device_pm_state = *state;
421421

422422
if (device_pm_state == PM_DEVICE_STATE_ACTIVE) {
423423
if (i2c_reg_update_byte(data->i2c, config->i2c_address,
@@ -442,11 +442,11 @@ static int apds9960_device_ctrl(const struct device *dev,
442442
}
443443

444444
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
445-
*((uint32_t *)context) = PM_DEVICE_STATE_ACTIVE;
445+
*state = PM_DEVICE_STATE_ACTIVE;
446446
}
447447

448448
if (cb) {
449-
cb(dev, ret, context, arg);
449+
cb(dev, ret, state, arg);
450450
}
451451

452452
return ret;

drivers/sensor/bme280/bme280.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,15 @@ static int bme280_chip_init(const struct device *dev)
391391

392392
#ifdef CONFIG_PM_DEVICE
393393
int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
394-
void *context, pm_device_cb cb, void *arg)
394+
uint32_t *state, pm_device_cb cb, void *arg)
395395
{
396396
struct bme280_data *data = to_data(dev);
397397

398398
int ret = 0;
399399

400400
/* Set power state */
401401
if (ctrl_command == PM_DEVICE_STATE_SET) {
402-
uint32_t new_pm_state = *((const uint32_t *)context);
402+
uint32_t new_pm_state = *state;
403403

404404
if (new_pm_state != data->pm_state) {
405405

@@ -430,12 +430,12 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
430430
/* Get power state */
431431
else {
432432
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
433-
*((uint32_t *)context) = data->pm_state;
433+
*state = data->pm_state;
434434
}
435435

436436
/* Invoke callback if any */
437437
if (cb)
438-
cb(dev, ret, context, arg);
438+
cb(dev, ret, state, arg);
439439

440440
return ret;
441441
}

drivers/sensor/bmp388/bmp388.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,20 +589,20 @@ static uint32_t bmp388_get_power_state(const struct device *dev)
589589
static int bmp388_device_ctrl(
590590
const struct device *dev,
591591
uint32_t ctrl_command,
592-
void *context,
592+
uint32_t *state,
593593
pm_device_cb cb,
594594
void *arg)
595595
{
596596
int ret = 0;
597597

598598
if (ctrl_command == PM_DEVICE_STATE_SET) {
599-
ret = bmp388_set_power_state(dev, *((uint32_t *)context));
599+
ret = bmp388_set_power_state(dev, *state);
600600
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
601-
*((uint32_t *)context) = bmp388_get_power_state(dev);
601+
*state = bmp388_get_power_state(dev);
602602
}
603603

604604
if (cb) {
605-
cb(dev, ret, context, arg);
605+
cb(dev, ret, state, arg);
606606
}
607607
return ret;
608608
}

drivers/sensor/fdc2x1x/fdc2x1x.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,15 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
543543

544544
static int fdc2x1x_device_pm_ctrl(const struct device *dev,
545545
uint32_t ctrl_command,
546-
void *context, pm_device_cb cb, void *arg)
546+
uint32_t *state, pm_device_cb cb,
547+
void *arg)
547548
{
548549
struct fdc2x1x_data *data = dev->data;
549550
uint32_t new_state;
550551
int ret = 0;
551552

552553
if (ctrl_command == PM_DEVICE_STATE_SET) {
553-
new_state = *(uint32_t *)context;
554+
new_state = *state;
554555
if (new_state != data->pm_state) {
555556
switch (new_state) {
556557
case PM_DEVICE_STATE_ACTIVE:
@@ -564,11 +565,11 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
564565
}
565566
}
566567
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
567-
*((uint32_t *)context) = data->pm_state;
568+
*state = data->pm_state;
568569
}
569570

570571
if (cb) {
571-
cb(dev, ret, context, arg);
572+
cb(dev, ret, state, arg);
572573
}
573574

574575
return ret;

drivers/sensor/vcnl4040/vcnl4040.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ static int vcnl4040_ambient_setup(const struct device *dev)
219219

220220
#ifdef CONFIG_PM_DEVICE
221221
static int vcnl4040_device_ctrl(const struct device *dev,
222-
uint32_t ctrl_command, void *context,
222+
uint32_t ctrl_command, uint32_t *state,
223223
pm_device_cb cb, void *arg)
224224
{
225225
int ret = 0;
226226

227227
if (ctrl_command == PM_DEVICE_STATE_SET) {
228-
uint32_t device_pm_state = *(uint32_t *)context;
228+
uint32_t device_pm_state = *state;
229229
uint16_t ps_conf;
230230

231231
ret = vcnl4040_read(dev, VCNL4040_REG_PS_CONF, &ps_conf);
@@ -275,11 +275,11 @@ static int vcnl4040_device_ctrl(const struct device *dev,
275275
}
276276

277277
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
278-
*((uint32_t *)context) = PM_DEVICE_STATE_ACTIVE;
278+
*state = PM_DEVICE_STATE_ACTIVE;
279279
}
280280

281281
if (cb) {
282-
cb(dev, ret, context, arg);
282+
cb(dev, ret, state, arg);
283283
}
284284

285285
return ret;

include/drivers/timer/system_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern int sys_clock_driver_init(const struct device *dev);
4848
*/
4949
extern int clock_device_ctrl(const struct device *dev,
5050
uint32_t ctrl_command,
51-
void *context, pm_device_cb cb, void *arg);
51+
uint32_t *state, pm_device_cb cb, void *arg);
5252

5353
/**
5454
* @brief Set system clock timeout

samples/sensor/fdc2x1x/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ static void trigger_handler(const struct device *dev,
3636
#ifdef CONFIG_PM_DEVICE
3737
static void pm_cb(const struct device *dev,
3838
int status,
39-
void *context,
39+
uint32_t *state,
4040
void *arg)
4141
{
4242
ARG_UNUSED(dev);
4343
ARG_UNUSED(arg);
4444

45-
switch (*(uint32_t *)context) {
45+
switch (*state) {
4646
case PM_DEVICE_STATE_ACTIVE:
4747
printk("Enter ACTIVE_STATE ");
4848
break;

0 commit comments

Comments
 (0)