connection, reply: move worker function to reply.h
authorDaniel Mack <daniel@zonque.org>
Fri, 9 Jan 2015 12:52:10 +0000 (13:52 +0100)
committerDaniel Mack <daniel@zonque.org>
Fri, 9 Jan 2015 12:53:32 +0000 (13:53 +0100)
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 <daniel@zonque.org>
connection.c
reply.c
reply.h

index 87f90b39153bc8ccb89b10a9610498d470d4a6a6..ac0599c3d941d451558847c32f5cf7f47ce31e2a 100644 (file)
@@ -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 d979a0b48fc2d2de18cbcf3d992a059e4c388ade..9e3559d1ed4a2aa52725d0da07c4286cb87f0401 100644 (file)
--- 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 832fccb09ce6b3dad6e46ce811d8d32c2f94fbab..a1d4c76f455f12718b43ca0a8052bdbc19fd5f6a 100644 (file)
--- 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 */