rearrange delayed_work to avoid the use of container_of while leaving it in
authorjmatthew <jmatthew@openbsd.org>
Mon, 8 Jun 2015 08:47:38 +0000 (08:47 +0000)
committerjmatthew <jmatthew@openbsd.org>
Mon, 8 Jun 2015 08:47:38 +0000 (08:47 +0000)
more or less the same shape.

ok uebayasi@

sys/dev/usb/dwc2/dwc2.c
sys/dev/usb/dwc2/dwc2.h
sys/dev/usb/dwc2/dwc2_coreintr.c
sys/dev/usb/dwc2/dwc2_hcd.c
sys/dev/usb/dwc2/dwc2_hcd.h

index c5d98b3..b90ff51 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2.c,v 1.27 2015/06/08 00:58:23 jmatthew Exp $      */
+/*     $OpenBSD: dwc2.c,v 1.28 2015/06/08 08:47:38 jmatthew Exp $      */
 /*     $NetBSD: dwc2.c,v 1.32 2014/09/02 23:26:20 macallan Exp $       */
 
 /*-
@@ -1696,7 +1696,7 @@ dw_timeout(void *arg)
 {
        struct delayed_work *dw = arg;
 
-       task_set(&dw->work, dw->dw_fn, arg);
+       task_set(&dw->work, dw->dw_fn, dw->dw_arg);
        task_add(dw->dw_wq, &dw->work);
 }
 
index c9db5c6..b3dc647 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2.h,v 1.11 2015/02/12 07:51:51 uebayasi Exp $      */
+/*     $OpenBSD: dwc2.h,v 1.12 2015/06/08 08:47:38 jmatthew Exp $      */
 /*     $NetBSD: dwc2.h,v 1.4 2014/12/23 16:20:06 macallan Exp $        */
 
 /*-
@@ -213,18 +213,21 @@ struct delayed_work {
 
        struct taskq *dw_wq;
        void (*dw_fn)(void *);
+       void *dw_arg;
 };
 
 STATIC_INLINE void
-INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct task *))
+INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(void *), void *arg)
 {
-       dw->dw_fn = (void (*)(void *))fn;
+       dw->dw_fn = fn;
+       dw->dw_arg = arg;
        timeout_set(&dw->dw_timer, dw_timeout, dw);
 }
 
 STATIC_INLINE void
 queue_delayed_work(struct taskq *wq, struct delayed_work *dw, int j)
 {
+       dw->dw_wq = wq;
        timeout_add(&dw->dw_timer, j);
 }
 
index 826d093..4febcc3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2_coreintr.c,v 1.6 2015/02/12 06:46:23 uebayasi Exp $      */
+/*     $OpenBSD: dwc2_coreintr.c,v 1.7 2015/06/08 08:47:38 jmatthew Exp $      */
 /*     $NetBSD: dwc2_coreintr.c,v 1.8 2014/04/04 05:40:57 skrll Exp $  */
 
 /*
@@ -305,6 +305,7 @@ STATIC void dwc2_handle_conn_id_status_change_intr(struct dwc2_hsotg *hsotg)
         * scheduling.
         */
        spin_unlock(&hsotg->lock);
+       task_set(&hsotg->wf_otg, dwc2_conn_id_status_change, hsotg);
        task_add(hsotg->wq_otg, &hsotg->wf_otg);
        spin_lock(&hsotg->lock);
 
index 383ded4..a7f6d75 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2_hcd.c,v 1.14 2015/02/12 11:42:58 uebayasi Exp $  */
+/*     $OpenBSD: dwc2_hcd.c,v 1.15 2015/06/08 08:47:38 jmatthew Exp $  */
 /*     $NetBSD: dwc2_hcd.c,v 1.15 2014/11/24 10:14:14 skrll Exp $      */
 
 /*
@@ -1312,10 +1312,9 @@ void dwc2_hcd_queue_transactions(struct dwc2_hsotg *hsotg,
 }
 
 void
-dwc2_conn_id_status_change(struct task *work)
+dwc2_conn_id_status_change(void *data)
 {
-       struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
-                                               wf_otg);
+       struct dwc2_hsotg *hsotg = data;
        u32 count = 0;
        u32 gotgctl;
 
@@ -2034,10 +2033,9 @@ void dwc2_host_disconnect(struct dwc2_hsotg *hsotg)
  * Work queue function for starting the HCD when A-Cable is connected
  */
 void
-dwc2_hcd_start_func(struct task *work)
+dwc2_hcd_start_func(void *data)
 {
-       struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
-                                               start_work.work);
+       struct dwc2_hsotg *hsotg = data;
 
        dev_dbg(hsotg->dev, "%s() %p\n", __func__, hsotg);
        dwc2_host_start(hsotg);
@@ -2047,10 +2045,9 @@ dwc2_hcd_start_func(struct task *work)
  * Reset work queue function
  */
 void
-dwc2_hcd_reset_func(struct task *work)
+dwc2_hcd_reset_func(void *data)
 {
-       struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
-                                               reset_work.work);
+       struct dwc2_hsotg *hsotg = data;
        u32 hprt0;
 
        dev_dbg(hsotg->dev, "USB RESET function called\n");
@@ -2265,10 +2262,10 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg,
                dwc2_hcd_init_usecs(hsotg);
 
        /* Initialize hsotg start work */
-       INIT_DELAYED_WORK(&hsotg->start_work, dwc2_hcd_start_func);
+       INIT_DELAYED_WORK(&hsotg->start_work, dwc2_hcd_start_func, hsotg);
 
        /* Initialize port reset work */
-       INIT_DELAYED_WORK(&hsotg->reset_work, dwc2_hcd_reset_func);
+       INIT_DELAYED_WORK(&hsotg->reset_work, dwc2_hcd_reset_func, hsotg);
 
        /*
         * Allocate space for storing data on status transactions. Normally no
index 279a24b..a68e02e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2_hcd.h,v 1.11 2015/02/12 11:42:58 uebayasi Exp $  */
+/*     $OpenBSD: dwc2_hcd.h,v 1.12 2015/06/08 08:47:38 jmatthew Exp $  */
 /*     $NetBSD: dwc2_hcd.h,v 1.9 2014/09/03 10:00:08 skrll Exp $       */
 
 /*
@@ -782,9 +782,9 @@ int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *, struct dwc2_hcd_urb *, void **,
 void dwc2_hcd_urb_set_pipeinfo(struct dwc2_hsotg *, struct dwc2_hcd_urb *,
                               u8 ,u8, u8, u8, u16);
 
-void dwc2_conn_id_status_change(struct task *);
-void dwc2_hcd_start_func(struct task *);
-void dwc2_hcd_reset_func(struct task *);
+void dwc2_conn_id_status_change(void *);
+void dwc2_hcd_start_func(void *);
+void dwc2_hcd_reset_func(void *);
 
 struct dwc2_hcd_urb * dwc2_hcd_urb_alloc(struct dwc2_hsotg *, int, gfp_t);
 void dwc2_hcd_urb_free(struct dwc2_hsotg *, struct dwc2_hcd_urb *, int);