From 8bf8a0d7b5786762a8a29184b44871ac9f3bfb8b Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Fri, 9 Jan 2015 13:52:10 +0100 Subject: [PATCH] connection, reply: move worker function to reply.h Change kdbus_reply_list_scan() so it becomes the worker callback, so we can remove the the glue from connection.c. Signed-off-by: Daniel Mack --- connection.c | 10 +--------- reply.c | 12 +++++++++--- reply.h | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/connection.c b/connection.c index 87f90b3..ac0599c 100644 --- a/connection.c +++ b/connection.c @@ -104,14 +104,6 @@ static int kdbus_conn_queue_user_quota(const struct kdbus_conn *conn_src, return 0; } -static void kdbus_conn_work(struct work_struct *work) -{ - struct kdbus_conn *conn = - container_of(work, struct kdbus_conn, work.work); - - kdbus_reply_list_scan(conn); -} - /** * kdbus_cmd_msg_recv() - receive a message from the queue * @conn: Connection to work on @@ -1534,7 +1526,7 @@ struct kdbus_conn *kdbus_conn_new(struct kdbus_ep *ep, atomic_set(&conn->name_count, 0); atomic_set(&conn->request_count, 0); atomic_set(&conn->lost_count, 0); - INIT_DELAYED_WORK(&conn->work, kdbus_conn_work); + INIT_DELAYED_WORK(&conn->work, kdbus_reply_list_scan_work); conn->cred = get_current_cred(); init_waitqueue_head(&conn->wait); kdbus_queue_init(&conn->queue); diff --git a/reply.c b/reply.c index d979a0b..9e3559d 100644 --- a/reply.c +++ b/reply.c @@ -189,16 +189,22 @@ struct kdbus_reply *kdbus_reply_find(struct kdbus_conn *replying, } /** - * kdbus_reply_list_scan() - Scan the replies of a connection - * @conn: Connection to scan + * kdbus_reply_list_scan_work() - Worker callback to scan the replies of a + * connection for exceeded timeouts + * @work: Work struct of the connection to scan * * Walk the list of replies stored with a connection and look for entries * that have exceeded their timeout. If such an entry is found, a timeout * notification is sent to the waiting peer, and the reply is removed from * the list. + * + * The work is rescheduled to the nearest timeout found during the list + * iteration. */ -void kdbus_reply_list_scan(struct kdbus_conn *conn) +void kdbus_reply_list_scan_work(struct work_struct *work) { + struct kdbus_conn *conn = + container_of(work, struct kdbus_conn, work.work); struct kdbus_reply *reply, *reply_tmp; u64 deadline = ~0ULL; struct timespec64 ts; diff --git a/reply.h b/reply.h index 832fccb..a1d4c76 100644 --- a/reply.h +++ b/reply.h @@ -63,6 +63,6 @@ struct kdbus_reply *kdbus_reply_find(struct kdbus_conn *replying, u64 cookie); void kdbus_sync_reply_wakeup(struct kdbus_reply *reply, int err); -void kdbus_reply_list_scan(struct kdbus_conn *conn); +void kdbus_reply_list_scan_work(struct work_struct *work); #endif /* __KDBUS_REPLY_H */ -- 2.34.1