.. | .. |
---|
153 | 153 | return usb_submit_urb(phy->ack_urb, flags); |
---|
154 | 154 | } |
---|
155 | 155 | |
---|
| 156 | +struct pn533_out_arg { |
---|
| 157 | + struct pn533_usb_phy *phy; |
---|
| 158 | + struct completion done; |
---|
| 159 | +}; |
---|
| 160 | + |
---|
156 | 161 | static int pn533_usb_send_frame(struct pn533 *dev, |
---|
157 | 162 | struct sk_buff *out) |
---|
158 | 163 | { |
---|
159 | 164 | struct pn533_usb_phy *phy = dev->phy; |
---|
| 165 | + struct pn533_out_arg arg; |
---|
| 166 | + void *cntx; |
---|
160 | 167 | int rc; |
---|
161 | 168 | |
---|
162 | 169 | if (phy->priv == NULL) |
---|
.. | .. |
---|
168 | 175 | print_hex_dump_debug("PN533 TX: ", DUMP_PREFIX_NONE, 16, 1, |
---|
169 | 176 | out->data, out->len, false); |
---|
170 | 177 | |
---|
| 178 | + arg.phy = phy; |
---|
| 179 | + init_completion(&arg.done); |
---|
| 180 | + cntx = phy->out_urb->context; |
---|
| 181 | + phy->out_urb->context = &arg; |
---|
| 182 | + |
---|
171 | 183 | rc = usb_submit_urb(phy->out_urb, GFP_KERNEL); |
---|
172 | 184 | if (rc) |
---|
173 | 185 | return rc; |
---|
| 186 | + |
---|
| 187 | + wait_for_completion(&arg.done); |
---|
| 188 | + phy->out_urb->context = cntx; |
---|
174 | 189 | |
---|
175 | 190 | if (dev->protocol_type == PN533_PROTO_REQ_RESP) { |
---|
176 | 191 | /* request for response for sent packet directly */ |
---|
.. | .. |
---|
412 | 427 | return arg.rc; |
---|
413 | 428 | } |
---|
414 | 429 | |
---|
415 | | -static void pn533_send_complete(struct urb *urb) |
---|
| 430 | +static void pn533_out_complete(struct urb *urb) |
---|
| 431 | +{ |
---|
| 432 | + struct pn533_out_arg *arg = urb->context; |
---|
| 433 | + struct pn533_usb_phy *phy = arg->phy; |
---|
| 434 | + |
---|
| 435 | + switch (urb->status) { |
---|
| 436 | + case 0: |
---|
| 437 | + break; /* success */ |
---|
| 438 | + case -ECONNRESET: |
---|
| 439 | + case -ENOENT: |
---|
| 440 | + dev_dbg(&phy->udev->dev, |
---|
| 441 | + "The urb has been stopped (status %d)\n", |
---|
| 442 | + urb->status); |
---|
| 443 | + break; |
---|
| 444 | + case -ESHUTDOWN: |
---|
| 445 | + default: |
---|
| 446 | + nfc_err(&phy->udev->dev, |
---|
| 447 | + "Urb failure (status %d)\n", |
---|
| 448 | + urb->status); |
---|
| 449 | + } |
---|
| 450 | + |
---|
| 451 | + complete(&arg->done); |
---|
| 452 | +} |
---|
| 453 | + |
---|
| 454 | +static void pn533_ack_complete(struct urb *urb) |
---|
416 | 455 | { |
---|
417 | 456 | struct pn533_usb_phy *phy = urb->context; |
---|
418 | 457 | |
---|
.. | .. |
---|
500 | 539 | |
---|
501 | 540 | usb_fill_bulk_urb(phy->out_urb, phy->udev, |
---|
502 | 541 | usb_sndbulkpipe(phy->udev, out_endpoint), |
---|
503 | | - NULL, 0, pn533_send_complete, phy); |
---|
| 542 | + NULL, 0, pn533_out_complete, phy); |
---|
504 | 543 | usb_fill_bulk_urb(phy->ack_urb, phy->udev, |
---|
505 | 544 | usb_sndbulkpipe(phy->udev, out_endpoint), |
---|
506 | | - NULL, 0, pn533_send_complete, phy); |
---|
| 545 | + NULL, 0, pn533_ack_complete, phy); |
---|
507 | 546 | |
---|
508 | 547 | switch (id->driver_info) { |
---|
509 | 548 | case PN533_DEVICE_STD: |
---|