drivers,subsys: fix few missing k_work_delayable_from_work

Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.

This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.

Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2023-08-27 20:05:49 +01:00 committed by Carles Cufí
commit ec71be5d9d
15 changed files with 36 additions and 22 deletions

View file

@ -622,8 +622,9 @@ static void eth_mcux_phy_work(struct k_work *item)
static void eth_mcux_delayed_phy_work(struct k_work *item)
{
struct k_work_delayable *dwork = k_work_delayable_from_work(item);
struct eth_context *context =
CONTAINER_OF(item, struct eth_context, delayed_phy_work);
CONTAINER_OF(dwork, struct eth_context, delayed_phy_work);
eth_mcux_phy_event(context);
}

View file

@ -45,7 +45,8 @@ struct gpio_keys_pin_data {
*/
static void gpio_keys_change_deferred(struct k_work *work)
{
struct gpio_keys_pin_data *pin_data = CONTAINER_OF(work, struct gpio_keys_pin_data, work);
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct gpio_keys_pin_data *pin_data = CONTAINER_OF(dwork, struct gpio_keys_pin_data, work);
const struct device *dev = pin_data->dev;
int key_index = pin_data - (struct gpio_keys_pin_data *)dev->data;
const struct gpio_keys_config *cfg = dev->config;

View file

@ -147,8 +147,9 @@ static void gpio_qdec_irq_setup(const struct device *dev, bool enable)
static void gpio_qdec_idle_worker(struct k_work *work)
{
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct gpio_qdec_data *data = CONTAINER_OF(
work, struct gpio_qdec_data, idle_work);
dwork, struct gpio_qdec_data, idle_work);
const struct device *dev = data->dev;
k_timer_stop(&data->sample_timer);

View file

@ -232,8 +232,9 @@ static int ppp_async_uart_rx_enable(struct ppp_driver_context *context)
static void uart_recovery(struct k_work *work)
{
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct ppp_driver_context *ppp =
CONTAINER_OF(work, struct ppp_driver_context, uart_recovery_work);
CONTAINER_OF(dwork, struct ppp_driver_context, uart_recovery_work);
int ret;
ret = ring_buf_space_get(&ppp->rx_ringbuf);

View file

@ -16,10 +16,7 @@ LOG_MODULE_DECLARE(TMP108, CONFIG_SENSOR_LOG_LEVEL);
void tmp108_trigger_handle_one_shot(struct k_work *work)
{
struct k_work_delayable *delayable_work = CONTAINER_OF(work,
struct k_work_delayable,
work);
struct k_work_delayable *delayable_work = k_work_delayable_from_work(work);
struct tmp108_data *drv_data = CONTAINER_OF(delayable_work,
struct tmp108_data,
scheduled_work);

View file

@ -820,7 +820,8 @@ static int mcux_lpuart_rx_buf_rsp(const struct device *dev, uint8_t *buf, size_t
static void mcux_lpuart_async_rx_timeout(struct k_work *work)
{
struct mcux_lpuart_rx_dma_params *rx_params = CONTAINER_OF(work,
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct mcux_lpuart_rx_dma_params *rx_params = CONTAINER_OF(dwork,
struct mcux_lpuart_rx_dma_params,
timeout_work);
struct mcux_lpuart_async_data *async_data = CONTAINER_OF(rx_params,
@ -834,7 +835,8 @@ static void mcux_lpuart_async_rx_timeout(struct k_work *work)
static void mcux_lpuart_async_tx_timeout(struct k_work *work)
{
struct mcux_lpuart_tx_dma_params *tx_params = CONTAINER_OF(work,
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct mcux_lpuart_tx_dma_params *tx_params = CONTAINER_OF(dwork,
struct mcux_lpuart_tx_dma_params,
timeout_work);
struct mcux_lpuart_async_data *async_data = CONTAINER_OF(tx_params,

View file

@ -424,8 +424,9 @@ static __unused void uart_npcx_rx_wk_isr(const struct device *dev, struct npcx_w
#ifdef CONFIG_UART_CONSOLE_INPUT_EXPIRED
static void uart_npcx_rx_refresh_timeout(struct k_work *work)
{
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct uart_npcx_data *data =
CONTAINER_OF(work, struct uart_npcx_data, rx_refresh_timeout_work);
CONTAINER_OF(dwork, struct uart_npcx_data, rx_refresh_timeout_work);
uart_npcx_pm_policy_state_lock_put(data, UART_PM_POLICY_STATE_RX_FLAG);
}

View file

@ -303,7 +303,8 @@ static void uart_sam0_dma_rx_done(const struct device *dma_dev, void *arg,
static void uart_sam0_rx_timeout(struct k_work *work)
{
struct uart_sam0_dev_data *dev_data = CONTAINER_OF(work,
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
struct uart_sam0_dev_data *dev_data = CONTAINER_OF(dwork,
struct uart_sam0_dev_data, rx_timeout_work);
const struct uart_sam0_dev_cfg *const cfg = dev_data->cfg;
SercomUsart * const regs = cfg->regs;

View file

@ -821,8 +821,9 @@ static void it82xx2_usb_dc_isr(void)
static void suspended_check_handler(struct k_work *item)
{
struct k_work_delayable *dwork = k_work_delayable_from_work(item);
struct usb_it82xx2_data *udata =
CONTAINER_OF(item, struct usb_it82xx2_data, check_suspended_work);
CONTAINER_OF(dwork, struct usb_it82xx2_data, check_suspended_work);
struct usb_it82xx2_regs *const usb_regs =
(struct usb_it82xx2_regs *)it82xx2_get_usb_regs();