drivers: wifi: rote conversion of k_work API

Replace all existing deprecated API with the recommended alternative.

Be aware that this does not address architectural errors in the use
of the work API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2021-03-31 10:31:30 -05:00 committed by Anas Nashif
commit 9fcd75160e
8 changed files with 28 additions and 28 deletions

View file

@ -443,8 +443,8 @@ static void esp_ip_addr_work(struct k_work *work)
ESP_CMD_TIMEOUT);
if (ret < 0) {
LOG_WRN("Failed to query IP settings: ret %d", ret);
k_delayed_work_submit_to_queue(&dev->workq, &dev->ip_addr_work,
K_SECONDS(5));
k_work_reschedule_for_queue(&dev->workq, &dev->ip_addr_work,
K_SECONDS(5));
return;
}
@ -471,8 +471,8 @@ MODEM_CMD_DEFINE(on_cmd_got_ip)
struct esp_data *dev = CONTAINER_OF(data, struct esp_data,
cmd_handler_data);
k_delayed_work_submit_to_queue(&dev->workq, &dev->ip_addr_work,
K_SECONDS(1));
k_work_reschedule_for_queue(&dev->workq, &dev->ip_addr_work,
K_SECONDS(1));
return 0;
}
@ -1087,7 +1087,7 @@ static int esp_init(const struct device *dev)
k_sem_init(&data->sem_if_up, 0, 1);
k_work_init(&data->init_work, esp_init_work);
k_delayed_work_init(&data->ip_addr_work, esp_ip_addr_work);
k_work_init_delayable(&data->ip_addr_work, esp_ip_addr_work);
k_work_init(&data->scan_work, esp_mgmt_scan_work);
k_work_init(&data->connect_work, esp_mgmt_connect_work);
k_work_init(&data->mode_switch_work, esp_mode_switch_work);
@ -1098,9 +1098,10 @@ static int esp_init(const struct device *dev)
esp_socket_init(data);
/* initialize the work queue */
k_work_q_start(&data->workq, esp_workq_stack,
K_KERNEL_STACK_SIZEOF(esp_workq_stack),
K_PRIO_COOP(CONFIG_WIFI_ESP_WORKQ_THREAD_PRIORITY));
k_work_queue_start(&data->workq, esp_workq_stack,
K_KERNEL_STACK_SIZEOF(esp_workq_stack),
K_PRIO_COOP(CONFIG_WIFI_ESP_WORKQ_THREAD_PRIORITY),
NULL);
k_thread_name_set(&data->workq.thread, "esp_workq");
/* cmd handler */

View file

@ -218,7 +218,7 @@ struct esp_data {
/* work */
struct k_work_q workq;
struct k_work init_work;
struct k_delayed_work ip_addr_work;
struct k_work_delayable ip_addr_work;
struct k_work scan_work;
struct k_work connect_work;
struct k_work mode_switch_work;

View file

@ -669,9 +669,9 @@ static int eswifi_init(const struct device *dev)
DT_INST_GPIO_FLAGS(0, wakeup_gpios) |
GPIO_OUTPUT_ACTIVE);
k_work_q_start(&eswifi->work_q, eswifi_work_q_stack,
K_KERNEL_STACK_SIZEOF(eswifi_work_q_stack),
CONFIG_SYSTEM_WORKQUEUE_PRIORITY - 1);
k_work_queue_start(&eswifi->work_q, eswifi_work_q_stack,
K_KERNEL_STACK_SIZEOF(eswifi_work_q_stack),
CONFIG_SYSTEM_WORKQUEUE_PRIORITY - 1, NULL);
k_work_init(&eswifi->request_work, eswifi_request_work);

View file

@ -433,8 +433,8 @@ static int eswifi_off_get(sa_family_t family,
k_sem_init(&socket->read_sem, 1, 1);
k_sem_init(&socket->accept_sem, 1, 1);
k_delayed_work_submit_to_queue(&eswifi->work_q, &socket->read_work,
K_MSEC(500));
k_work_reschedule_for_queue(&eswifi->work_q, &socket->read_work,
K_MSEC(500));
unlock:
eswifi_unlock(eswifi);

View file

@ -42,7 +42,7 @@ struct eswifi_off_socket {
struct net_pkt *tx_pkt;
struct k_work connect_work;
struct k_work send_work;
struct k_delayed_work read_work;
struct k_work_delayable read_work;
struct sockaddr peer_addr;
struct k_sem read_sem;
struct k_sem accept_sem;

View file

@ -150,9 +150,8 @@ do_recv_cb:
next_timeout_ms = 0;
done:
err = k_delayed_work_submit_to_queue(&eswifi->work_q,
&socket->read_work,
K_MSEC(next_timeout_ms));
err = k_work_reschedule_for_queue(&eswifi->work_q, &socket->read_work,
K_MSEC(next_timeout_ms));
if (err) {
LOG_ERR("Rescheduling socket read error");
}
@ -237,7 +236,7 @@ int __eswifi_socket_free(struct eswifi_dev *eswifi,
struct eswifi_off_socket *socket)
{
__select_socket(eswifi, socket->index);
k_delayed_work_cancel(&socket->read_work);
k_work_cancel_delayable(&socket->read_work);
__select_socket(eswifi, socket->index);
__stop_socket(eswifi, socket);
@ -298,7 +297,7 @@ int __eswifi_socket_new(struct eswifi_dev *eswifi, int family, int type,
return -EIO;
}
k_delayed_work_init(&socket->read_work, eswifi_off_read_work);
k_work_init_delayable(&socket->read_work, eswifi_off_read_work);
socket->usage = 1;
LOG_DBG("Socket index %d", socket->index);

View file

@ -410,8 +410,8 @@ static int eswifi_socket_open(int family, int type, int proto)
socket->recv_cb = __process_received;
socket->recv_data = socket;
k_delayed_work_submit_to_queue(&eswifi->work_q, &socket->read_work,
K_MSEC(500));
k_work_reschedule_for_queue(&eswifi->work_q, &socket->read_work,
K_MSEC(500));
unlock:
eswifi_unlock(eswifi);

View file

@ -32,7 +32,7 @@ struct simplelink_data {
unsigned char mac[6];
/* Fields for scan API to emulate an asynchronous scan: */
struct k_delayed_work work;
struct k_work_delayable work;
scan_result_cb_t cb;
int num_results_or_err;
int scan_retries;
@ -126,7 +126,7 @@ static void simplelink_scan_work_handler(struct k_work *work)
if (delay > 0) {
LOG_DBG("Retrying scan...");
}
k_delayed_work_submit(&simplelink_data.work, K_MSEC(delay));
k_work_reschedule(&simplelink_data.work, K_MSEC(delay));
} else {
/* Encountered an error, or max retries exceeded: */
@ -143,7 +143,7 @@ static int simplelink_mgmt_scan(const struct device *dev, scan_result_cb_t cb)
int status;
/* Cancel any previous scan processing in progress: */
k_delayed_work_cancel(&simplelink_data.work);
k_work_cancel_delayable(&simplelink_data.work);
/* "Request" the scan: */
err = z_simplelink_start_scan();
@ -160,7 +160,7 @@ static int simplelink_mgmt_scan(const struct device *dev, scan_result_cb_t cb)
simplelink_data.num_results_or_err = err;
simplelink_data.scan_retries = 0;
k_delayed_work_submit(&simplelink_data.work, K_MSEC(delay));
k_work_reschedule(&simplelink_data.work, K_MSEC(delay));
status = 0;
} else {
status = -EIO;
@ -274,8 +274,8 @@ static int simplelink_init(const struct device *dev)
ARG_UNUSED(dev);
/* We use system workqueue to deal with scan retries: */
k_delayed_work_init(&simplelink_data.work,
simplelink_scan_work_handler);
k_work_init_delayable(&simplelink_data.work,
simplelink_scan_work_handler);
LOG_DBG("SimpleLink driver Initialized");