diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-10-31 03:47:44 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-12-12 04:45:05 -0500 |
commit | c5b963f809f378d4fedd6f2f09b36f50c5a37bd5 (patch) | |
tree | 503a06e7ad26343960df9facd17991e57fe0231e /drivers/usb/renesas_usbhs | |
parent | 9c6736523a23371ae58c5427587ee1652ba059c1 (diff) |
usb: gadget: renesas_usbhs: remove usbhsh_request list
mod_host had usbhsh_request active/free list.
it was almost meaningless, and vainly complicated.
This patch remove it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs')
-rw-r--r-- | drivers/usb/renesas_usbhs/mod_host.c | 69 |
1 files changed, 3 insertions, 66 deletions
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 204f9f086846..3f1eaf15e0ba 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c | |||
@@ -74,7 +74,6 @@ struct usbhsh_pipe_info { | |||
74 | struct usbhsh_request { | 74 | struct usbhsh_request { |
75 | struct urb *urb; | 75 | struct urb *urb; |
76 | struct usbhs_pkt pkt; | 76 | struct usbhs_pkt pkt; |
77 | struct list_head ureq_link; /* see hpriv :: ureq_link_xxx */ | ||
78 | }; | 77 | }; |
79 | 78 | ||
80 | struct usbhsh_device { | 79 | struct usbhsh_device { |
@@ -104,10 +103,6 @@ struct usbhsh_hpriv { | |||
104 | u32 port_stat; /* USB_PORT_STAT_xxx */ | 103 | u32 port_stat; /* USB_PORT_STAT_xxx */ |
105 | 104 | ||
106 | struct completion setup_ack_done; | 105 | struct completion setup_ack_done; |
107 | |||
108 | /* see usbhsh_req_alloc/free */ | ||
109 | struct list_head ureq_link_active; | ||
110 | struct list_head ureq_link_free; | ||
111 | }; | 106 | }; |
112 | 107 | ||
113 | 108 | ||
@@ -178,31 +173,6 @@ static const char usbhsh_hcd_name[] = "renesas_usbhs host"; | |||
178 | /* | 173 | /* |
179 | * req alloc/free | 174 | * req alloc/free |
180 | */ | 175 | */ |
181 | static void usbhsh_ureq_list_init(struct usbhsh_hpriv *hpriv) | ||
182 | { | ||
183 | INIT_LIST_HEAD(&hpriv->ureq_link_active); | ||
184 | INIT_LIST_HEAD(&hpriv->ureq_link_free); | ||
185 | } | ||
186 | |||
187 | static void usbhsh_ureq_list_quit(struct usbhsh_hpriv *hpriv) | ||
188 | { | ||
189 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | ||
190 | struct device *dev = usbhsh_hcd_to_dev(hcd); | ||
191 | struct usbhsh_request *ureq, *next; | ||
192 | |||
193 | /* kfree all active ureq */ | ||
194 | list_for_each_entry_safe(ureq, next, | ||
195 | &hpriv->ureq_link_active, | ||
196 | ureq_link) { | ||
197 | dev_err(dev, "active ureq (%p) is force freed\n", ureq); | ||
198 | kfree(ureq); | ||
199 | } | ||
200 | |||
201 | /* kfree all free ureq */ | ||
202 | list_for_each_entry_safe(ureq, next, &hpriv->ureq_link_free, ureq_link) | ||
203 | kfree(ureq); | ||
204 | } | ||
205 | |||
206 | static struct usbhsh_request *usbhsh_ureq_alloc(struct usbhsh_hpriv *hpriv, | 176 | static struct usbhsh_request *usbhsh_ureq_alloc(struct usbhsh_hpriv *hpriv, |
207 | struct urb *urb, | 177 | struct urb *urb, |
208 | gfp_t mem_flags) | 178 | gfp_t mem_flags) |
@@ -211,35 +181,13 @@ static struct usbhsh_request *usbhsh_ureq_alloc(struct usbhsh_hpriv *hpriv, | |||
211 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | 181 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); |
212 | struct device *dev = usbhs_priv_to_dev(priv); | 182 | struct device *dev = usbhs_priv_to_dev(priv); |
213 | 183 | ||
214 | if (list_empty(&hpriv->ureq_link_free)) { | 184 | ureq = kzalloc(sizeof(struct usbhsh_request), mem_flags); |
215 | /* | ||
216 | * create new one if there is no free ureq | ||
217 | */ | ||
218 | ureq = kzalloc(sizeof(struct usbhsh_request), mem_flags); | ||
219 | if (ureq) | ||
220 | INIT_LIST_HEAD(&ureq->ureq_link); | ||
221 | } else { | ||
222 | /* | ||
223 | * reuse "free" ureq if exist | ||
224 | */ | ||
225 | ureq = list_entry(hpriv->ureq_link_free.next, | ||
226 | struct usbhsh_request, | ||
227 | ureq_link); | ||
228 | if (ureq) | ||
229 | list_del_init(&ureq->ureq_link); | ||
230 | } | ||
231 | |||
232 | if (!ureq) { | 185 | if (!ureq) { |
233 | dev_err(dev, "ureq alloc fail\n"); | 186 | dev_err(dev, "ureq alloc fail\n"); |
234 | return NULL; | 187 | return NULL; |
235 | } | 188 | } |
236 | 189 | ||
237 | usbhs_pkt_init(&ureq->pkt); | 190 | usbhs_pkt_init(&ureq->pkt); |
238 | |||
239 | /* | ||
240 | * push it to "active" list | ||
241 | */ | ||
242 | list_add_tail(&ureq->ureq_link, &hpriv->ureq_link_active); | ||
243 | ureq->urb = urb; | 191 | ureq->urb = urb; |
244 | usbhsh_urb_to_ureq(urb) = ureq; | 192 | usbhsh_urb_to_ureq(urb) = ureq; |
245 | 193 | ||
@@ -249,18 +197,10 @@ static struct usbhsh_request *usbhsh_ureq_alloc(struct usbhsh_hpriv *hpriv, | |||
249 | static void usbhsh_ureq_free(struct usbhsh_hpriv *hpriv, | 197 | static void usbhsh_ureq_free(struct usbhsh_hpriv *hpriv, |
250 | struct usbhsh_request *ureq) | 198 | struct usbhsh_request *ureq) |
251 | { | 199 | { |
252 | struct usbhs_pkt *pkt = &ureq->pkt; | ||
253 | |||
254 | usbhs_pkt_init(pkt); | ||
255 | |||
256 | /* | ||
257 | * removed from "active" list, | ||
258 | * and push it to "free" list | ||
259 | */ | ||
260 | usbhsh_urb_to_ureq(ureq->urb) = NULL; | 200 | usbhsh_urb_to_ureq(ureq->urb) = NULL; |
261 | ureq->urb = NULL; | 201 | ureq->urb = NULL; |
262 | list_del_init(&ureq->ureq_link); | 202 | |
263 | list_add_tail(&ureq->ureq_link, &hpriv->ureq_link_free); | 203 | kfree(ureq); |
264 | } | 204 | } |
265 | 205 | ||
266 | /* | 206 | /* |
@@ -1310,7 +1250,6 @@ int usbhs_mod_host_probe(struct usbhs_priv *priv) | |||
1310 | hpriv->mod.stop = usbhsh_stop; | 1250 | hpriv->mod.stop = usbhsh_stop; |
1311 | hpriv->pipe_info = pipe_info; | 1251 | hpriv->pipe_info = pipe_info; |
1312 | hpriv->pipe_size = pipe_size; | 1252 | hpriv->pipe_size = pipe_size; |
1313 | usbhsh_ureq_list_init(hpriv); | ||
1314 | usbhsh_port_stat_init(hpriv); | 1253 | usbhsh_port_stat_init(hpriv); |
1315 | 1254 | ||
1316 | /* init all device */ | 1255 | /* init all device */ |
@@ -1334,8 +1273,6 @@ int usbhs_mod_host_remove(struct usbhs_priv *priv) | |||
1334 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); | 1273 | struct usbhsh_hpriv *hpriv = usbhsh_priv_to_hpriv(priv); |
1335 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); | 1274 | struct usb_hcd *hcd = usbhsh_hpriv_to_hcd(hpriv); |
1336 | 1275 | ||
1337 | usbhsh_ureq_list_quit(hpriv); | ||
1338 | |||
1339 | usb_put_hcd(hcd); | 1276 | usb_put_hcd(hcd); |
1340 | 1277 | ||
1341 | return 0; | 1278 | return 0; |