pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept out of the enum since they do not represent any state. However, their name has not been changed since they will be removed soon. All drivers and tests have been adjusted accordingly. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
59d07b0247
commit
cc2f0e9c08
53 changed files with 214 additions and 231 deletions
|
@ -292,8 +292,8 @@ static void pwm_nrfx_uninit(const struct device *dev)
|
|||
memset(dev->data, 0, sizeof(struct pwm_nrfx_data));
|
||||
}
|
||||
|
||||
static int pwm_nrfx_set_power_state(uint32_t new_state,
|
||||
uint32_t current_state,
|
||||
static int pwm_nrfx_set_power_state(enum pm_device_state new_state,
|
||||
enum pm_device_state current_state,
|
||||
const struct device *dev)
|
||||
{
|
||||
int err = 0;
|
||||
|
@ -319,13 +319,13 @@ static int pwm_nrfx_set_power_state(uint32_t new_state,
|
|||
|
||||
static int pwm_nrfx_pm_control(const struct device *dev,
|
||||
uint32_t ctrl_command,
|
||||
uint32_t *state,
|
||||
uint32_t *current_state)
|
||||
enum pm_device_state *state,
|
||||
enum pm_device_state *current_state)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||
uint32_t new_state = *((const uint32_t *)state);
|
||||
enum pm_device_state new_state = *state;
|
||||
|
||||
if (new_state != (*current_state)) {
|
||||
err = pwm_nrfx_set_power_state(new_state,
|
||||
|
@ -346,11 +346,11 @@ static int pwm_nrfx_pm_control(const struct device *dev,
|
|||
#define PWM_NRFX_PM_CONTROL(idx) \
|
||||
static int pwm_##idx##_nrfx_pm_control(const struct device *dev, \
|
||||
uint32_t ctrl_command, \
|
||||
uint32_t *state, \
|
||||
enum pm_device_state *state, \
|
||||
pm_device_cb cb, \
|
||||
void *arg) \
|
||||
{ \
|
||||
static uint32_t current_state = PM_DEVICE_STATE_ACTIVE; \
|
||||
static enum pm_device_state current_state = PM_DEVICE_STATE_ACTIVE; \
|
||||
int ret = 0; \
|
||||
ret = pwm_nrfx_pm_control(dev, ctrl_command, state, \
|
||||
¤t_state); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue