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:
parent
d41dadc569
commit
495672ab62
33 changed files with 263 additions and 334 deletions
|
@ -1422,13 +1422,14 @@ static int uart_stm32_init(const struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
static int uart_stm32_set_power_state(const struct device *dev,
|
||||
enum pm_device_state state)
|
||||
static int uart_stm32_pm_control(const struct device *dev,
|
||||
enum pm_device_state state)
|
||||
{
|
||||
USART_TypeDef *UartInstance = UART_STRUCT(dev);
|
||||
|
||||
/* setting a low power mode */
|
||||
if (state != PM_DEVICE_STATE_ACTIVE) {
|
||||
switch (state) {
|
||||
case PM_DEVICE_STATE_SUSPENDED:
|
||||
#ifdef USART_ISR_BUSY
|
||||
/* Make sure that no USART transfer is on-going */
|
||||
while (LL_USART_IsActiveFlag_BUSY(UartInstance) == 1) {
|
||||
|
@ -1444,28 +1445,14 @@ static int uart_stm32_set_power_state(const struct device *dev,
|
|||
/* Clear OVERRUN flag */
|
||||
LL_USART_ClearFlag_ORE(UartInstance);
|
||||
/* Leave UartInstance unchanged */
|
||||
break;
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* UartInstance returning to active mode has nothing special to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief disable the UART channel
|
||||
*
|
||||
* This routine is called to put the device in low power mode.
|
||||
*
|
||||
* @param dev UART device struct
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
static int uart_stm32_pm_control(const struct device *dev,
|
||||
enum pm_device_state state)
|
||||
{
|
||||
uart_stm32_set_power_state(dev, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_PM_DEVICE */
|
||||
|
||||
#ifdef CONFIG_UART_ASYNC_API
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue