.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2008, cozybit Inc. |
---|
3 | 4 | * Copyright (C) 2003-2006, Marvell International Ltd. |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or (at |
---|
8 | | - * your option) any later version. |
---|
9 | 5 | */ |
---|
10 | 6 | #define DRV_NAME "lbtf_usb" |
---|
11 | 7 | |
---|
.. | .. |
---|
42 | 38 | |
---|
43 | 39 | static void if_usb_receive(struct urb *urb); |
---|
44 | 40 | static void if_usb_receive_fwload(struct urb *urb); |
---|
45 | | -static int if_usb_prog_firmware(struct if_usb_card *cardp); |
---|
| 41 | +static int if_usb_prog_firmware(struct lbtf_private *priv); |
---|
46 | 42 | static int if_usb_host_to_card(struct lbtf_private *priv, uint8_t type, |
---|
47 | 43 | uint8_t *payload, uint16_t nb); |
---|
48 | 44 | static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload, |
---|
49 | 45 | uint16_t nb, u8 data); |
---|
50 | 46 | static void if_usb_free(struct if_usb_card *cardp); |
---|
51 | 47 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp); |
---|
52 | | -static int if_usb_reset_device(struct if_usb_card *cardp); |
---|
| 48 | +static int if_usb_reset_device(struct lbtf_private *priv); |
---|
53 | 49 | |
---|
54 | 50 | /** |
---|
55 | 51 | * if_usb_wrike_bulk_callback - call back to handle URB status |
---|
56 | 52 | * |
---|
57 | | - * @param urb pointer to urb structure |
---|
| 53 | + * @urb: pointer to urb structure |
---|
58 | 54 | */ |
---|
59 | 55 | static void if_usb_write_bulk_callback(struct urb *urb) |
---|
60 | 56 | { |
---|
.. | .. |
---|
71 | 67 | /** |
---|
72 | 68 | * if_usb_free - free tx/rx urb, skb and rx buffer |
---|
73 | 69 | * |
---|
74 | | - * @param cardp pointer if_usb_card |
---|
| 70 | + * @cardp: pointer if_usb_card |
---|
75 | 71 | */ |
---|
76 | 72 | static void if_usb_free(struct if_usb_card *cardp) |
---|
77 | 73 | { |
---|
.. | .. |
---|
131 | 127 | lbtf_deb_leave(LBTF_DEB_USB); |
---|
132 | 128 | } |
---|
133 | 129 | |
---|
| 130 | +static const struct lbtf_ops if_usb_ops = { |
---|
| 131 | + .hw_host_to_card = if_usb_host_to_card, |
---|
| 132 | + .hw_prog_firmware = if_usb_prog_firmware, |
---|
| 133 | + .hw_reset_device = if_usb_reset_device, |
---|
| 134 | +}; |
---|
| 135 | + |
---|
134 | 136 | /** |
---|
135 | 137 | * if_usb_probe - sets the configuration values |
---|
136 | 138 | * |
---|
137 | | - * @ifnum interface number |
---|
138 | | - * @id pointer to usb_device_id |
---|
| 139 | + * @intf: USB interface structure |
---|
| 140 | + * @id: pointer to usb_device_id |
---|
139 | 141 | * |
---|
140 | 142 | * Returns: 0 on success, error code on failure |
---|
141 | 143 | */ |
---|
.. | .. |
---|
216 | 218 | goto dealloc; |
---|
217 | 219 | } |
---|
218 | 220 | |
---|
219 | | - priv = lbtf_add_card(cardp, &udev->dev); |
---|
| 221 | + cardp->boot2_version = udev->descriptor.bcdDevice; |
---|
| 222 | + priv = lbtf_add_card(cardp, &udev->dev, &if_usb_ops); |
---|
220 | 223 | if (!priv) |
---|
221 | 224 | goto dealloc; |
---|
222 | | - |
---|
223 | | - cardp->priv = priv; |
---|
224 | | - |
---|
225 | | - priv->hw_host_to_card = if_usb_host_to_card; |
---|
226 | | - priv->hw_prog_firmware = if_usb_prog_firmware; |
---|
227 | | - priv->hw_reset_device = if_usb_reset_device; |
---|
228 | | - cardp->boot2_version = udev->descriptor.bcdDevice; |
---|
229 | 225 | |
---|
230 | 226 | usb_get_dev(udev); |
---|
231 | 227 | usb_set_intfdata(intf, cardp); |
---|
.. | .. |
---|
243 | 239 | /** |
---|
244 | 240 | * if_usb_disconnect - free resource and cleanup |
---|
245 | 241 | * |
---|
246 | | - * @intf USB interface structure |
---|
| 242 | + * @intf: USB interface structure |
---|
247 | 243 | */ |
---|
248 | 244 | static void if_usb_disconnect(struct usb_interface *intf) |
---|
249 | 245 | { |
---|
.. | .. |
---|
252 | 248 | |
---|
253 | 249 | lbtf_deb_enter(LBTF_DEB_MAIN); |
---|
254 | 250 | |
---|
255 | | - if_usb_reset_device(cardp); |
---|
256 | | - |
---|
257 | | - if (priv) |
---|
| 251 | + if (priv) { |
---|
| 252 | + if_usb_reset_device(priv); |
---|
258 | 253 | lbtf_remove_card(priv); |
---|
| 254 | + } |
---|
259 | 255 | |
---|
260 | 256 | /* Unlink and free urb */ |
---|
261 | 257 | if_usb_free(cardp); |
---|
.. | .. |
---|
270 | 266 | /** |
---|
271 | 267 | * if_usb_send_fw_pkt - This function downloads the FW |
---|
272 | 268 | * |
---|
273 | | - * @priv pointer to struct lbtf_private |
---|
| 269 | + * @cardp: pointer if_usb_card |
---|
274 | 270 | * |
---|
275 | 271 | * Returns: 0 |
---|
276 | 272 | */ |
---|
.. | .. |
---|
321 | 317 | } else if (fwdata->hdr.dnldcmd == cpu_to_le32(FW_HAS_LAST_BLOCK)) { |
---|
322 | 318 | lbtf_deb_usb2(&cardp->udev->dev, |
---|
323 | 319 | "Host has finished FW downloading\n"); |
---|
324 | | - lbtf_deb_usb2(&cardp->udev->dev, "Donwloading FW JUMP BLOCK\n"); |
---|
| 320 | + lbtf_deb_usb2(&cardp->udev->dev, "Downloading FW JUMP BLOCK\n"); |
---|
325 | 321 | |
---|
326 | 322 | /* Host has finished FW downloading |
---|
327 | 323 | * Donwloading FW JUMP BLOCK |
---|
.. | .. |
---|
336 | 332 | return 0; |
---|
337 | 333 | } |
---|
338 | 334 | |
---|
339 | | -static int if_usb_reset_device(struct if_usb_card *cardp) |
---|
| 335 | +static int if_usb_reset_device(struct lbtf_private *priv) |
---|
340 | 336 | { |
---|
| 337 | + struct if_usb_card *cardp = priv->card; |
---|
341 | 338 | struct cmd_ds_802_11_reset *cmd = cardp->ep_out_buf + 4; |
---|
342 | 339 | int ret; |
---|
343 | 340 | |
---|
.. | .. |
---|
365 | 362 | /** |
---|
366 | 363 | * usb_tx_block - transfer data to the device |
---|
367 | 364 | * |
---|
368 | | - * @priv pointer to struct lbtf_private |
---|
369 | | - * @payload pointer to payload data |
---|
370 | | - * @nb data length |
---|
371 | | - * @data non-zero for data, zero for commands |
---|
| 365 | + * @cardp: pointer if_usb_card |
---|
| 366 | + * @payload: pointer to payload data |
---|
| 367 | + * @nb: data length |
---|
| 368 | + * @data: non-zero for data, zero for commands |
---|
372 | 369 | * |
---|
373 | 370 | * Returns: 0 on success, nonzero otherwise. |
---|
374 | 371 | */ |
---|
.. | .. |
---|
616 | 613 | spin_lock_irqsave(&priv->driver_lock, flags); |
---|
617 | 614 | memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN, |
---|
618 | 615 | recvlength - MESSAGE_HEADER_LEN); |
---|
619 | | - kfree_skb(skb); |
---|
| 616 | + dev_kfree_skb_irq(skb); |
---|
620 | 617 | lbtf_cmd_response_rx(priv); |
---|
621 | 618 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
---|
622 | 619 | } |
---|
.. | .. |
---|
624 | 621 | /** |
---|
625 | 622 | * if_usb_receive - read data received from the device. |
---|
626 | 623 | * |
---|
627 | | - * @urb pointer to struct urb |
---|
| 624 | + * @urb: pointer to struct urb |
---|
628 | 625 | */ |
---|
629 | 626 | static void if_usb_receive(struct urb *urb) |
---|
630 | 627 | { |
---|
.. | .. |
---|
707 | 704 | /** |
---|
708 | 705 | * if_usb_host_to_card - Download data to the device |
---|
709 | 706 | * |
---|
710 | | - * @priv pointer to struct lbtf_private structure |
---|
711 | | - * @type type of data |
---|
712 | | - * @buf pointer to data buffer |
---|
713 | | - * @len number of bytes |
---|
| 707 | + * @priv: pointer to struct lbtf_private structure |
---|
| 708 | + * @type: type of data |
---|
| 709 | + * @payload: pointer to payload buffer |
---|
| 710 | + * @nb: number of bytes |
---|
714 | 711 | * |
---|
715 | 712 | * Returns: 0 on success, nonzero otherwise |
---|
716 | 713 | */ |
---|
.. | .. |
---|
739 | 736 | /** |
---|
740 | 737 | * if_usb_issue_boot_command - Issue boot command to Boot2. |
---|
741 | 738 | * |
---|
742 | | - * @ivalue 1 boots from FW by USB-Download, 2 boots from FW in EEPROM. |
---|
| 739 | + * @cardp: pointer if_usb_card |
---|
| 740 | + * @ivalue: 1 boots from FW by USB-Download, 2 boots from FW in EEPROM. |
---|
743 | 741 | * |
---|
744 | 742 | * Returns: 0 |
---|
745 | 743 | */ |
---|
.. | .. |
---|
762 | 760 | /** |
---|
763 | 761 | * check_fwfile_format - Check the validity of Boot2/FW image. |
---|
764 | 762 | * |
---|
765 | | - * @data pointer to image |
---|
766 | | - * @totlen image length |
---|
| 763 | + * @data: pointer to image |
---|
| 764 | + * @totlen: image length |
---|
767 | 765 | * |
---|
768 | 766 | * Returns: 0 if the image is valid, nonzero otherwise. |
---|
769 | 767 | */ |
---|
.. | .. |
---|
808 | 806 | } |
---|
809 | 807 | |
---|
810 | 808 | |
---|
811 | | -static int if_usb_prog_firmware(struct if_usb_card *cardp) |
---|
| 809 | +static int if_usb_prog_firmware(struct lbtf_private *priv) |
---|
812 | 810 | { |
---|
| 811 | + struct if_usb_card *cardp = priv->card; |
---|
813 | 812 | int i = 0; |
---|
814 | 813 | static int reset_count = 10; |
---|
815 | 814 | int ret = 0; |
---|
816 | 815 | |
---|
817 | 816 | lbtf_deb_enter(LBTF_DEB_USB); |
---|
| 817 | + |
---|
| 818 | + cardp->priv = priv; |
---|
818 | 819 | |
---|
819 | 820 | kernel_param_lock(THIS_MODULE); |
---|
820 | 821 | ret = request_firmware(&cardp->fw, lbtf_fw_name, &cardp->udev->dev); |
---|
.. | .. |
---|
851 | 852 | |
---|
852 | 853 | if (cardp->bootcmdresp <= 0) { |
---|
853 | 854 | if (--reset_count >= 0) { |
---|
854 | | - if_usb_reset_device(cardp); |
---|
| 855 | + if_usb_reset_device(priv); |
---|
855 | 856 | goto restart; |
---|
856 | 857 | } |
---|
857 | 858 | return -1; |
---|
.. | .. |
---|
880 | 881 | if (!cardp->fwdnldover) { |
---|
881 | 882 | pr_info("failed to load fw, resetting device!\n"); |
---|
882 | 883 | if (--reset_count >= 0) { |
---|
883 | | - if_usb_reset_device(cardp); |
---|
| 884 | + if_usb_reset_device(priv); |
---|
884 | 885 | goto restart; |
---|
885 | 886 | } |
---|
886 | 887 | |
---|
.. | .. |
---|
888 | 889 | ret = -1; |
---|
889 | 890 | goto release_fw; |
---|
890 | 891 | } |
---|
891 | | - |
---|
892 | | - cardp->priv->fw_ready = 1; |
---|
893 | 892 | |
---|
894 | 893 | release_fw: |
---|
895 | 894 | release_firmware(cardp->fw); |
---|