aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw/zd_mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/zd1211rw/zd_mac.c')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 522de3f0dfaf..f6c487aa8246 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -86,28 +86,33 @@ out:
86 return r; 86 return r;
87} 87}
88 88
89int zd_mac_init_hw(struct zd_mac *mac, u8 device_type) 89int zd_mac_preinit_hw(struct zd_mac *mac)
90{ 90{
91 int r; 91 int r;
92 struct zd_chip *chip = &mac->chip;
93 u8 addr[ETH_ALEN]; 92 u8 addr[ETH_ALEN];
93
94 r = zd_chip_read_mac_addr_fw(&mac->chip, addr);
95 if (r)
96 return r;
97
98 memcpy(mac->netdev->dev_addr, addr, ETH_ALEN);
99 return 0;
100}
101
102int zd_mac_init_hw(struct zd_mac *mac)
103{
104 int r;
105 struct zd_chip *chip = &mac->chip;
94 u8 default_regdomain; 106 u8 default_regdomain;
95 107
96 r = zd_chip_enable_int(chip); 108 r = zd_chip_enable_int(chip);
97 if (r) 109 if (r)
98 goto out; 110 goto out;
99 r = zd_chip_init_hw(chip, device_type); 111 r = zd_chip_init_hw(chip);
100 if (r) 112 if (r)
101 goto disable_int; 113 goto disable_int;
102 114
103 zd_get_e2p_mac_addr(chip, addr);
104 r = zd_write_mac_addr(chip, addr);
105 if (r)
106 goto disable_int;
107 ZD_ASSERT(!irqs_disabled()); 115 ZD_ASSERT(!irqs_disabled());
108 spin_lock_irq(&mac->lock);
109 memcpy(mac->netdev->dev_addr, addr, ETH_ALEN);
110 spin_unlock_irq(&mac->lock);
111 116
112 r = zd_read_regdomain(chip, &default_regdomain); 117 r = zd_read_regdomain(chip, &default_regdomain);
113 if (r) 118 if (r)
@@ -167,14 +172,25 @@ int zd_mac_open(struct net_device *netdev)
167{ 172{
168 struct zd_mac *mac = zd_netdev_mac(netdev); 173 struct zd_mac *mac = zd_netdev_mac(netdev);
169 struct zd_chip *chip = &mac->chip; 174 struct zd_chip *chip = &mac->chip;
175 struct zd_usb *usb = &chip->usb;
170 int r; 176 int r;
171 177
178 if (!usb->initialized) {
179 r = zd_usb_init_hw(usb);
180 if (r)
181 goto out;
182 }
183
172 tasklet_enable(&mac->rx_tasklet); 184 tasklet_enable(&mac->rx_tasklet);
173 185
174 r = zd_chip_enable_int(chip); 186 r = zd_chip_enable_int(chip);
175 if (r < 0) 187 if (r < 0)
176 goto out; 188 goto out;
177 189
190 r = zd_write_mac_addr(chip, netdev->dev_addr);
191 if (r)
192 goto disable_int;
193
178 r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G); 194 r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G);
179 if (r < 0) 195 if (r < 0)
180 goto disable_int; 196 goto disable_int;
@@ -254,9 +270,11 @@ int zd_mac_set_mac_address(struct net_device *netdev, void *p)
254 dev_dbg_f(zd_mac_dev(mac), 270 dev_dbg_f(zd_mac_dev(mac),
255 "Setting MAC to " MAC_FMT "\n", MAC_ARG(addr->sa_data)); 271 "Setting MAC to " MAC_FMT "\n", MAC_ARG(addr->sa_data));
256 272
257 r = zd_write_mac_addr(chip, addr->sa_data); 273 if (netdev->flags & IFF_UP) {
258 if (r) 274 r = zd_write_mac_addr(chip, addr->sa_data);
259 return r; 275 if (r)
276 return r;
277 }
260 278
261 spin_lock_irqsave(&mac->lock, flags); 279 spin_lock_irqsave(&mac->lock, flags);
262 memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN); 280 memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN);
@@ -858,7 +876,7 @@ static int fill_ctrlset(struct zd_mac *mac,
858 /* ZD1211B: Computing the length difference this way, gives us 876 /* ZD1211B: Computing the length difference this way, gives us
859 * flexibility to compute the packet length. 877 * flexibility to compute the packet length.
860 */ 878 */
861 cs->packet_length = cpu_to_le16(mac->chip.is_zd1211b ? 879 cs->packet_length = cpu_to_le16(zd_chip_is_zd1211b(&mac->chip) ?
862 packet_length - frag_len : packet_length); 880 packet_length - frag_len : packet_length);
863 881
864 /* 882 /*