From: jmatthew Date: Mon, 8 Jun 2015 08:47:38 +0000 (+0000) Subject: rearrange delayed_work to avoid the use of container_of while leaving it in X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ea6872ec01c371ce47687f6513d57c282a765463;p=openbsd rearrange delayed_work to avoid the use of container_of while leaving it in more or less the same shape. ok uebayasi@ --- diff --git a/sys/dev/usb/dwc2/dwc2.c b/sys/dev/usb/dwc2/dwc2.c index c5d98b35a51..b90ff51de0d 100644 --- a/sys/dev/usb/dwc2/dwc2.c +++ b/sys/dev/usb/dwc2/dwc2.c @@ -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); } diff --git a/sys/dev/usb/dwc2/dwc2.h b/sys/dev/usb/dwc2/dwc2.h index c9db5c60158..b3dc6479acd 100644 --- a/sys/dev/usb/dwc2/dwc2.h +++ b/sys/dev/usb/dwc2/dwc2.h @@ -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); } diff --git a/sys/dev/usb/dwc2/dwc2_coreintr.c b/sys/dev/usb/dwc2/dwc2_coreintr.c index 826d0931d7a..4febcc3c472 100644 --- a/sys/dev/usb/dwc2/dwc2_coreintr.c +++ b/sys/dev/usb/dwc2/dwc2_coreintr.c @@ -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); diff --git a/sys/dev/usb/dwc2/dwc2_hcd.c b/sys/dev/usb/dwc2/dwc2_hcd.c index 383ded4d790..a7f6d753e7e 100644 --- a/sys/dev/usb/dwc2/dwc2_hcd.c +++ b/sys/dev/usb/dwc2/dwc2_hcd.c @@ -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 diff --git a/sys/dev/usb/dwc2/dwc2_hcd.h b/sys/dev/usb/dwc2/dwc2_hcd.h index 279a24b766e..a68e02ebbdf 100644 --- a/sys/dev/usb/dwc2/dwc2_hcd.h +++ b/sys/dev/usb/dwc2/dwc2_hcd.h @@ -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);