Skip to content

mass conversion of k_work API #33924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8e1919f
DNM: kwork.cocci: script for converting deprecated k_work API
pabigot Mar 31, 2021
8a21279
benchmarks: rote conversion of k_work API
pabigot Mar 31, 2021
5605a43
bluetooth: rote conversion of k_work API
pabigot Mar 31, 2021
dd4b028
canbus: rote conversion of k_work API
pabigot Mar 31, 2021
1a6b7d9
console: rote conversion of k_work API
pabigot Mar 31, 2021
f2eb19e
ethernet: rote conversion of k_work API
pabigot Mar 31, 2021
93d6e2f
ipc: rote conversion of k_work API
pabigot Mar 31, 2021
0344ae5
ieee802154: rote conversion of k_work API
pabigot Mar 31, 2021
bd8f856
kernel: rote conversion of k_work API
pabigot Mar 31, 2021
d4987a0
led_sx1509b_intensity: rote conversion of k_work API
pabigot Mar 31, 2021
f9be435
mgmt: rote conversion of k_work API
pabigot Mar 31, 2021
e0e7173
modem: rote conversion of k_work API
pabigot Mar 31, 2021
71a1cff
net: rote conversion of k_work API
pabigot Mar 31, 2021
1acb195
FIXUP net: missed uses
pabigot Apr 1, 2021
ad24365
serial: rote conversion of k_work API
pabigot Mar 31, 2021
78b93df
shell: rote conversion of k_work API
pabigot Mar 31, 2021
6a21548
tracing: rote conversion of k_work API
pabigot Mar 31, 2021
8a3ea0f
usb: rote conversion of k_work API
pabigot Mar 31, 2021
5772213
video: rote conversion of k_work API
pabigot Mar 31, 2021
45711cd
wifi: rote conversion of k_work API
pabigot Mar 31, 2021
e63c3ce
boards: rote conversion of k_work API
pabigot Apr 1, 2021
0b2668f
Revert "DNM: kwork.cocci: script for converting deprecated k_work API"
pabigot Mar 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions drivers/bluetooth/hci/h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ static K_KERNEL_STACK_DEFINE(rx_stack, 256);
static struct k_thread tx_thread_data;
static struct k_thread rx_thread_data;

static struct k_delayed_work ack_work;
static struct k_delayed_work retx_work;
static struct k_work_delayable ack_work;
static struct k_work_delayable retx_work;

#define HCI_3WIRE_ACK_PKT 0x00
#define HCI_COMMAND_PKT 0x01
Expand Down Expand Up @@ -292,7 +292,7 @@ static void h5_send(const uint8_t *payload, uint8_t type, int len)

/* Set ACK for outgoing packet and stop delayed work */
H5_SET_ACK(hdr, h5.tx_ack);
k_delayed_work_cancel(&ack_work);
k_work_cancel_delayable(&ack_work);

if (reliable_packet(type)) {
H5_SET_RELIABLE(hdr);
Expand Down Expand Up @@ -377,7 +377,7 @@ static void h5_process_complete_packet(uint8_t *hdr)
/* For reliable packet increment next transmit ack number */
h5.tx_ack = (h5.tx_ack + 1) % 8;
/* Submit delayed work to ack the packet */
k_delayed_work_submit(&ack_work, H5_RX_ACK_TIMEOUT);
k_work_reschedule(&ack_work, H5_RX_ACK_TIMEOUT);
}

h5_print_header(hdr, "RX: >");
Expand Down Expand Up @@ -636,7 +636,7 @@ static void tx_thread(void)
net_buf_put(&h5.unack_queue, buf);
unack_queue_len++;

k_delayed_work_submit(&retx_work, H5_TX_ACK_TIMEOUT);
k_work_reschedule(&retx_work, H5_TX_ACK_TIMEOUT);

break;
}
Expand Down Expand Up @@ -735,8 +735,8 @@ static void h5_init(void)
k_fifo_init(&h5.unack_queue);

/* Init delayed work */
k_delayed_work_init(&ack_work, ack_timeout);
k_delayed_work_init(&retx_work, retx_timeout);
k_work_init_delayable(&ack_work, ack_timeout);
k_work_init_delayable(&retx_work, retx_timeout);
}

static int h5_open(void)
Expand Down
26 changes: 13 additions & 13 deletions drivers/console/gsm_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct gsm_mux {
uint16_t msg_len; /* message length */
uint16_t received; /* bytes so far received */

struct k_delayed_work t2_timer;
struct k_work_delayable t2_timer;
sys_slist_t pending_ctrls;

uint16_t t1_timeout_value; /* T1 default value */
Expand Down Expand Up @@ -169,7 +169,7 @@ static struct gsm_mux muxes[CONFIG_GSM_MUX_MAX];
static struct gsm_dlci dlcis[CONFIG_GSM_MUX_DLCI_MAX];
static sys_slist_t dlci_free_entries;
static sys_slist_t dlci_active_t1_timers;
static struct k_delayed_work t1_timer;
static struct k_work_delayable t1_timer;

static struct gsm_control_msg ctrls[CONFIG_GSM_MUX_PENDING_CMD_MAX];
static sys_slist_t ctrls_free_entries;
Expand Down Expand Up @@ -454,8 +454,8 @@ static void dlci_run_timer(uint32_t current_time)
struct gsm_dlci *dlci, *next;
uint32_t new_timer = UINT_MAX;

if (k_delayed_work_remaining_get(&t1_timer)) {
k_delayed_work_cancel(&t1_timer);
if (k_ticks_to_ms_ceil32(k_work_delayable_remaining_get(&t1_timer))) {
k_work_cancel_delayable(&t1_timer);
}

SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&dlci_active_t1_timers,
Expand All @@ -467,7 +467,7 @@ static void dlci_run_timer(uint32_t current_time)
}

if (new_timer != UINT_MAX) {
k_delayed_work_submit(&t1_timer, K_MSEC(new_timer));
k_work_reschedule(&t1_timer, K_MSEC(new_timer));
}
}

Expand Down Expand Up @@ -631,7 +631,7 @@ static void gsm_mux_t2_timeout(struct k_work *work)
}

if (entry) {
k_delayed_work_submit(&mux->t2_timer,
k_work_reschedule(&mux->t2_timer,
K_MSEC(entry->req_start + T2_MSEC -
current_time));
}
Expand Down Expand Up @@ -674,8 +674,8 @@ static int gsm_mux_send_control_message(struct gsm_mux *mux, uint8_t dlci_addres
ctrl->req_start = k_uptime_get_32();

/* Let's start the timer if necessary */
if (!k_delayed_work_remaining_get(&mux->t2_timer)) {
k_delayed_work_submit(&mux->t2_timer, K_MSEC(T2_MSEC));
if (!k_ticks_to_ms_ceil32(k_work_delayable_remaining_get(&mux->t2_timer))) {
k_work_reschedule(&mux->t2_timer, K_MSEC(T2_MSEC));
}

return gsm_mux_modem_send(mux, buf->data, buf->len);
Expand All @@ -692,8 +692,8 @@ static int gsm_dlci_opening_or_closing(struct gsm_dlci *dlci,
dlci->command_cb = cb;

/* Let's start the timer if necessary */
if (!k_delayed_work_remaining_get(&t1_timer)) {
k_delayed_work_submit(&t1_timer,
if (!k_ticks_to_ms_ceil32(k_work_delayable_remaining_get(&t1_timer))) {
k_work_reschedule(&t1_timer,
K_MSEC(dlci->mux->t1_timeout_value));
}

Expand Down Expand Up @@ -739,7 +739,7 @@ int gsm_mux_disconnect(struct gsm_mux *mux, k_timeout_t timeout)
(void)gsm_mux_send_control_message(dlci->mux, dlci->num,
CMD_CLD, NULL, 0);

k_delayed_work_cancel(&mux->t2_timer);
k_work_cancel_delayable(&mux->t2_timer);

(void)gsm_dlci_closing(dlci, NULL);

Expand Down Expand Up @@ -1474,7 +1474,7 @@ struct gsm_mux *gsm_mux_create(const struct device *uart)
mux->state = GSM_MUX_SOF;
mux->buf = NULL;

k_delayed_work_init(&mux->t2_timer, gsm_mux_t2_timeout);
k_work_init_delayable(&mux->t2_timer, gsm_mux_t2_timeout);
sys_slist_init(&mux->pending_ctrls);

/* The system will continue after the control DLCI is
Expand Down Expand Up @@ -1538,5 +1538,5 @@ void gsm_mux_init(void)
sys_slist_prepend(&dlci_free_entries, &dlcis[i].node);
}

k_delayed_work_init(&t1_timer, dlci_t1_timeout);
k_work_init_delayable(&t1_timer, dlci_t1_timeout);
}
4 changes: 2 additions & 2 deletions drivers/console/uart_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,9 @@ static int init_uart_mux(const struct device *dev)
{
ARG_UNUSED(dev);

k_work_q_start(&uart_mux_workq, uart_mux_stack,
k_work_queue_start(&uart_mux_workq, uart_mux_stack,
K_KERNEL_STACK_SIZEOF(uart_mux_stack),
K_PRIO_COOP(UART_MUX_WORKQ_PRIORITY));
K_PRIO_COOP(UART_MUX_WORKQ_PRIORITY), NULL);
k_thread_name_set(&uart_mux_workq.thread, "uart_mux_workq");

return 0;
Expand Down
6 changes: 3 additions & 3 deletions drivers/ethernet/dsa_ksz8794.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ static void dsa_delayed_work(struct k_work *item)
context->link_up[i] = link_state;
}

k_delayed_work_submit(&context->dsa_work, DSA_STATUS_PERIOD_MS);
k_work_reschedule(&context->dsa_work, DSA_STATUS_PERIOD_MS);
}

int dsa_port_init(const struct device *dev)
Expand All @@ -703,8 +703,8 @@ int dsa_port_init(const struct device *dev)
}

dsa_hw_init(NULL);
k_delayed_work_init(&context->dsa_work, dsa_delayed_work);
k_delayed_work_submit(&context->dsa_work, DSA_STATUS_PERIOD_MS);
k_work_init_delayable(&context->dsa_work, dsa_delayed_work);
k_work_reschedule(&context->dsa_work, DSA_STATUS_PERIOD_MS);

return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions drivers/ethernet/eth_mcux.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct eth_context {
uint8_t mac_addr[6];
void (*generate_mac)(uint8_t *);
struct k_work phy_work;
struct k_delayed_work delayed_phy_work;
struct k_work_delayable delayed_phy_work;
/* TODO: FIXME. This Ethernet frame sized buffer is used for
* interfacing with MCUX. How it works is that hardware uses
* DMA scatter buffers to receive a frame, and then public
Expand Down Expand Up @@ -381,7 +381,7 @@ void eth_mcux_phy_stop(struct eth_context *context)
context->phy_state = eth_mcux_phy_state_closing;
break;
case eth_mcux_phy_state_wait:
k_delayed_work_cancel(&context->delayed_phy_work);
k_work_cancel_delayable(&context->delayed_phy_work);
/* @todo, actually power downt he PHY ? */
context->phy_state = eth_mcux_phy_state_initial;
break;
Expand Down Expand Up @@ -437,7 +437,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
context->phy_state = eth_mcux_phy_state_reset;
}

k_delayed_work_submit(&context->delayed_phy_work, K_MSEC(1));
k_work_reschedule(&context->delayed_phy_work, K_MSEC(1));
#endif
break;
case eth_mcux_phy_state_closing:
Expand Down Expand Up @@ -520,12 +520,12 @@ static void eth_mcux_phy_event(struct eth_context *context)
} else if (!link_up && context->link_up) {
LOG_INF("%s link down", eth_name(context->base));
context->link_up = link_up;
k_delayed_work_submit(&context->delayed_phy_work,
k_work_reschedule(&context->delayed_phy_work,
K_MSEC(CONFIG_ETH_MCUX_PHY_TICK_MS));
context->phy_state = eth_mcux_phy_state_wait;
net_eth_carrier_off(context->iface);
} else {
k_delayed_work_submit(&context->delayed_phy_work,
k_work_reschedule(&context->delayed_phy_work,
K_MSEC(CONFIG_ETH_MCUX_PHY_TICK_MS));
context->phy_state = eth_mcux_phy_state_wait;
}
Expand Down Expand Up @@ -555,7 +555,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
eth_name(context->base),
(phy_speed ? "100" : "10"),
(phy_duplex ? "full" : "half"));
k_delayed_work_submit(&context->delayed_phy_work,
k_work_reschedule(&context->delayed_phy_work,
K_MSEC(CONFIG_ETH_MCUX_PHY_TICK_MS));
context->phy_state = eth_mcux_phy_state_wait;
break;
Expand Down Expand Up @@ -1005,7 +1005,7 @@ static int eth_init(const struct device *dev)
k_sem_init(&context->tx_buf_sem,
0, CONFIG_ETH_MCUX_TX_BUFFERS);
k_work_init(&context->phy_work, eth_mcux_phy_work);
k_delayed_work_init(&context->delayed_phy_work,
k_work_init_delayable(&context->delayed_phy_work,
eth_mcux_delayed_phy_work);

if (context->generate_mac) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/ethernet/eth_sam_gmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ static void monitor_work_handler(struct k_work *work)

finally:
/* Submit delayed work */
k_delayed_work_submit(&dev_data->monitor_work,
k_work_reschedule(&dev_data->monitor_work,
K_MSEC(CONFIG_ETH_SAM_GMAC_MONITOR_PERIOD));
}

Expand Down Expand Up @@ -1970,8 +1970,8 @@ static void eth0_iface_init(struct net_if *iface)
}

/* Initialise monitor */
k_delayed_work_init(&dev_data->monitor_work, monitor_work_handler);
k_delayed_work_submit(&dev_data->monitor_work,
k_work_init_delayable(&dev_data->monitor_work, monitor_work_handler);
k_work_reschedule(&dev_data->monitor_work,
K_MSEC(CONFIG_ETH_SAM_GMAC_MONITOR_PERIOD));

/* Do not start the interface until PHY link is up */
Expand Down
2 changes: 1 addition & 1 deletion drivers/ethernet/eth_sam_gmac_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ struct eth_sam_dev_data {
const struct device *ptp_clock;
#endif
uint8_t mac_addr[6];
struct k_delayed_work monitor_work;
struct k_work_delayable monitor_work;
bool link_up;
struct gmac_queue queue_list[GMAC_QUEUE_NUM];
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/ieee802154/ieee802154_dw1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,10 +1607,10 @@ static int dw1000_init(const struct device *dev)
DWT_SYS_MASK_MRXSFDTO);

/* Initialize IRQ event work queue */
k_work_q_start(&dwt_work_queue,
k_work_queue_start(&dwt_work_queue,
dwt_work_queue_stack,
K_KERNEL_STACK_SIZEOF(dwt_work_queue_stack),
CONFIG_SYSTEM_WORKQUEUE_PRIORITY);
CONFIG_SYSTEM_WORKQUEUE_PRIORITY, NULL);

k_work_init(&ctx->irq_cb_work, dwt_irq_work_handler);

Expand Down
24 changes: 12 additions & 12 deletions drivers/modem/gsm_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static struct gsm_modem {
struct k_sem sem_response;

struct modem_iface_uart_data gsm_data;
struct k_delayed_work gsm_configure_work;
struct k_work_delayable gsm_configure_work;
char gsm_rx_rb_buf[PPP_MRU * 3];

uint8_t *ppp_recv_buf;
Expand Down Expand Up @@ -360,7 +360,7 @@ static void gsm_finalize_connection(struct gsm_modem *gsm)
if (ret < 0) {
LOG_ERR("modem setup returned %d, %s",
ret, "retrying...");
(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_SECONDS(1));
return;
}
Expand All @@ -387,7 +387,7 @@ static void gsm_finalize_connection(struct gsm_modem *gsm)
if (ret < 0) {
LOG_DBG("modem setup returned %d, %s",
ret, "retrying...");
(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_SECONDS(1));
return;
}
Expand All @@ -401,7 +401,7 @@ static void gsm_finalize_connection(struct gsm_modem *gsm)
GSM_CMD_SETUP_TIMEOUT);
if (ret < 0) {
LOG_DBG("Not attached, %s", "retrying...");
(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_SECONDS(1));
return;
}
Expand All @@ -418,7 +418,7 @@ static void gsm_finalize_connection(struct gsm_modem *gsm)
if (ret < 0) {
LOG_DBG("modem setup returned %d, %s",
ret, "retrying...");
(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_SECONDS(1));
return;
}
Expand Down Expand Up @@ -500,7 +500,7 @@ static int mux_enable(struct gsm_modem *gsm)

static void mux_setup_next(struct gsm_modem *gsm)
{
(void)k_delayed_work_submit(&gsm->gsm_configure_work, K_MSEC(1));
(void) k_work_reschedule(&gsm->gsm_configure_work, K_MSEC(1));
}

static void mux_attach_cb(const struct device *mux, int dlci_address,
Expand Down Expand Up @@ -651,7 +651,7 @@ static void gsm_configure(struct k_work *work)
if (ret < 0) {
LOG_DBG("modem not ready %d", ret);

(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_NO_WAIT);

return;
Expand All @@ -666,7 +666,7 @@ static void gsm_configure(struct k_work *work)
gsm->mux_enabled = true;
} else {
gsm->mux_enabled = false;
(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_NO_WAIT);
return;
}
Expand All @@ -677,10 +677,10 @@ static void gsm_configure(struct k_work *work)
if (gsm->mux_enabled) {
gsm->state = STATE_INIT;

k_delayed_work_init(&gsm->gsm_configure_work,
k_work_init_delayable(&gsm->gsm_configure_work,
mux_setup);

(void)k_delayed_work_submit(&gsm->gsm_configure_work,
(void) k_work_reschedule(&gsm->gsm_configure_work,
K_NO_WAIT);
return;
}
Expand All @@ -701,8 +701,8 @@ void gsm_ppp_start(const struct device *dev)
return;
}

k_delayed_work_init(&gsm->gsm_configure_work, gsm_configure);
(void)k_delayed_work_submit(&gsm->gsm_configure_work, K_NO_WAIT);
k_work_init_delayable(&gsm->gsm_configure_work, gsm_configure);
(void) k_work_reschedule(&gsm->gsm_configure_work, K_NO_WAIT);
}

void gsm_ppp_stop(const struct device *dev)
Expand Down
Loading