aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/ehci-mem.c')
-rw-r--r--drivers/usb/host/ehci-mem.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index bdb29e618058..8816d09903d0 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -64,9 +64,8 @@ static inline void ehci_qtd_free (struct ehci_hcd *ehci, struct ehci_qtd *qtd)
64} 64}
65 65
66 66
67static void qh_destroy (struct kref *kref) 67static void qh_destroy(struct ehci_qh *qh)
68{ 68{
69 struct ehci_qh *qh = container_of(kref, struct ehci_qh, kref);
70 struct ehci_hcd *ehci = qh->ehci; 69 struct ehci_hcd *ehci = qh->ehci;
71 70
72 /* clean qtds first, and know this is not linked */ 71 /* clean qtds first, and know this is not linked */
@@ -90,7 +89,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags)
90 return qh; 89 return qh;
91 90
92 memset (qh, 0, sizeof *qh); 91 memset (qh, 0, sizeof *qh);
93 kref_init(&qh->kref); 92 qh->refcount = 1;
94 qh->ehci = ehci; 93 qh->ehci = ehci;
95 qh->qh_dma = dma; 94 qh->qh_dma = dma;
96 // INIT_LIST_HEAD (&qh->qh_list); 95 // INIT_LIST_HEAD (&qh->qh_list);
@@ -112,13 +111,15 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags)
112/* to share a qh (cpu threads, or hc) */ 111/* to share a qh (cpu threads, or hc) */
113static inline struct ehci_qh *qh_get (struct ehci_qh *qh) 112static inline struct ehci_qh *qh_get (struct ehci_qh *qh)
114{ 113{
115 kref_get(&qh->kref); 114 WARN_ON(!qh->refcount);
115 qh->refcount++;
116 return qh; 116 return qh;
117} 117}
118 118
119static inline void qh_put (struct ehci_qh *qh) 119static inline void qh_put (struct ehci_qh *qh)
120{ 120{
121 kref_put(&qh->kref, qh_destroy); 121 if (!--qh->refcount)
122 qh_destroy(qh);
122} 123}
123 124
124/*-------------------------------------------------------------------------*/ 125/*-------------------------------------------------------------------------*/