pm: device: remove usage of local states
The device PM subsystem already holds the device state, so there is no need to keep duplicates inside the device. The pm_device_state_get has been refactored to just return the device state. Note that this is still not safe, but the same applied to the previous implementation. This problem will be addressed later. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
1c0ed94601
commit
c2cf1ad203
48 changed files with 198 additions and 715 deletions
|
@ -40,9 +40,6 @@ struct uart_npcx_data {
|
|||
uart_irq_callback_user_data_t user_cb;
|
||||
void *user_data;
|
||||
#endif
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
enum pm_device_state pm_state;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Driver convenience defines */
|
||||
|
@ -441,20 +438,9 @@ static inline bool uart_npcx_device_is_transmitting(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int uart_npcx_get_power_state(const struct device *dev,
|
||||
enum pm_device_state *state)
|
||||
{
|
||||
const struct uart_npcx_data *const data = DRV_DATA(dev);
|
||||
|
||||
*state = data->pm_state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int uart_npcx_set_power_state(const struct device *dev,
|
||||
enum pm_device_state next_state)
|
||||
{
|
||||
struct uart_npcx_data *const data = DRV_DATA(dev);
|
||||
|
||||
/* If next device power state is LOW or SUSPEND power state */
|
||||
if (next_state == PM_DEVICE_STATE_LOW_POWER ||
|
||||
next_state == PM_DEVICE_STATE_SUSPEND) {
|
||||
|
@ -467,7 +453,6 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
data->pm_state = next_state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -481,9 +466,6 @@ static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
|||
case PM_DEVICE_STATE_SET:
|
||||
ret = uart_npcx_set_power_state(dev, *state);
|
||||
break;
|
||||
case PM_DEVICE_STATE_GET:
|
||||
ret = uart_npcx_get_power_state(dev, state);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue