pm: cleanup pm control callback implementations

- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
  drivers, but better take off with consistency in place after current
  changes).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-07-05 10:35:15 +02:00 committed by Anas Nashif
commit 495672ab62
33 changed files with 263 additions and 334 deletions

View file

@ -264,26 +264,25 @@ static int post_notify_fxn(unsigned int eventType, uintptr_t eventArg,
#endif
#ifdef CONFIG_PM_DEVICE
static int entropy_cc13xx_cc26xx_set_power_state(const struct device *dev,
enum pm_device_state state)
{
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
if (state == PM_DEVICE_STATE_ACTIVE) {
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
start_trng(data);
} else {
stop_trng(data);
Power_releaseDependency(PowerCC26XX_PERIPH_TRNG);
}
return 0;
}
static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
enum pm_device_state state)
{
return entropy_cc13xx_cc26xx_set_power_state(dev, state);
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
switch (state) {
case PM_DEVICE_STATE_ACTIVE:
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
start_trng(data);
break;
case PM_DEVICE_STATE_SUSPENDED:
stop_trng(data);
Power_releaseDependency(PowerCC26XX_PERIPH_TRNG);
break;
default:
return -ENOTSUP;
}
return 0;
}
#endif /* CONFIG_PM_DEVICE */