.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/drivers/net/wireless/libertas/if_spi.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
10 | 11 | * Colin McCabe <colin@cozybit.com> |
---|
11 | 12 | * |
---|
12 | 13 | * Inspired by if_sdio.c, Copyright 2007-2008 Pierre Ossman |
---|
13 | | - * |
---|
14 | | - * This program is free software; you can redistribute it and/or modify |
---|
15 | | - * it under the terms of the GNU General Public License as published by |
---|
16 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
17 | | - * (at your option) any later version. |
---|
18 | 14 | */ |
---|
19 | 15 | |
---|
20 | 16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
39 | 35 | struct if_spi_packet { |
---|
40 | 36 | struct list_head list; |
---|
41 | 37 | u16 blen; |
---|
42 | | - u8 buffer[0] __attribute__((aligned(4))); |
---|
| 38 | + u8 buffer[] __aligned(4); |
---|
43 | 39 | }; |
---|
44 | 40 | |
---|
45 | 41 | struct if_spi_card { |
---|
.. | .. |
---|
239 | 235 | spi_message_add_tail(&dummy_trans, &m); |
---|
240 | 236 | } else { |
---|
241 | 237 | /* Busy-wait while the SPU fills the FIFO */ |
---|
242 | | - reg_trans.delay_usecs = |
---|
| 238 | + reg_trans.delay.value = |
---|
243 | 239 | DIV_ROUND_UP((100 + (delay * 10)), 1000); |
---|
| 240 | + reg_trans.delay.unit = SPI_DELAY_UNIT_USECS; |
---|
244 | 241 | } |
---|
245 | 242 | |
---|
246 | 243 | /* read in data */ |
---|
.. | .. |
---|
770 | 767 | |
---|
771 | 768 | /* Read the data from the WLAN module into our skb... */ |
---|
772 | 769 | err = spu_read(card, IF_SPI_DATA_RDWRPORT_REG, data, ALIGN(len, 4)); |
---|
773 | | - if (err) |
---|
774 | | - goto free_skb; |
---|
| 770 | + if (err) { |
---|
| 771 | + dev_kfree_skb(skb); |
---|
| 772 | + goto out; |
---|
| 773 | + } |
---|
775 | 774 | |
---|
776 | 775 | /* pass the SKB to libertas */ |
---|
777 | 776 | err = lbs_process_rxed_packet(card->priv, skb); |
---|
778 | | - if (err) |
---|
779 | | - goto free_skb; |
---|
| 777 | + /* lbs_process_rxed_packet() consumes the skb */ |
---|
780 | 778 | |
---|
781 | | - /* success */ |
---|
782 | | - goto out; |
---|
783 | | - |
---|
784 | | -free_skb: |
---|
785 | | - dev_kfree_skb(skb); |
---|
786 | 779 | out: |
---|
787 | 780 | if (err) |
---|
788 | 781 | netdev_err(priv->dev, "%s: err=%d\n", __func__, err); |
---|
.. | .. |
---|
796 | 789 | { |
---|
797 | 790 | struct lbs_private *priv = card->priv; |
---|
798 | 791 | int err = 0; |
---|
799 | | - u16 int_type, port_reg; |
---|
| 792 | + u16 port_reg; |
---|
800 | 793 | |
---|
801 | 794 | switch (type) { |
---|
802 | 795 | case MVMS_DAT: |
---|
803 | | - int_type = IF_SPI_CIC_TX_DOWNLOAD_OVER; |
---|
804 | 796 | port_reg = IF_SPI_DATA_RDWRPORT_REG; |
---|
805 | 797 | break; |
---|
806 | 798 | case MVMS_CMD: |
---|
807 | | - int_type = IF_SPI_CIC_CMD_DOWNLOAD_OVER; |
---|
808 | 799 | port_reg = IF_SPI_CMD_RDWRPORT_REG; |
---|
809 | 800 | break; |
---|
810 | 801 | default: |
---|
.. | .. |
---|
1146 | 1137 | * This will call alloc_etherdev. |
---|
1147 | 1138 | */ |
---|
1148 | 1139 | priv = lbs_add_card(card, &spi->dev); |
---|
1149 | | - if (!priv) { |
---|
1150 | | - err = -ENOMEM; |
---|
| 1140 | + if (IS_ERR(priv)) { |
---|
| 1141 | + err = PTR_ERR(priv); |
---|
1151 | 1142 | goto free_card; |
---|
1152 | 1143 | } |
---|
1153 | 1144 | card->priv = priv; |
---|