diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-12-29 08:51:51 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-01-07 15:16:54 -0500 |
commit | a02308e931ad0bba19803779bec491c4b2d67b47 (patch) | |
tree | a4b4f475811c87b5e0b0e4b5dff36777b6c085c9 /drivers/net | |
parent | e1b97c9bc5902ec8b36247bcb7c3552895611485 (diff) |
rt2x00: rt2800: convert read_eeprom functions to return an int value
Both the rtt2x00usb_eeprom_read and the ioremap
functions are allowed to fail, however their
return values are not checked in the read_eeprom
functions in the rt2800{pci,usb} drivers.
The patch adds the missing checks, and converts
all read_eeprom functions to return an int value,
so the error values can be propagated up to the
'rt2800_validate_eeprom' function.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 9 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 35 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 12 |
4 files changed, 43 insertions, 21 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 0ece3537106d..f139a913c25a 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -4671,12 +4671,14 @@ static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i) | |||
4671 | mutex_unlock(&rt2x00dev->csr_mutex); | 4671 | mutex_unlock(&rt2x00dev->csr_mutex); |
4672 | } | 4672 | } |
4673 | 4673 | ||
4674 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) | 4674 | int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) |
4675 | { | 4675 | { |
4676 | unsigned int i; | 4676 | unsigned int i; |
4677 | 4677 | ||
4678 | for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8) | 4678 | for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8) |
4679 | rt2800_efuse_read(rt2x00dev, i); | 4679 | rt2800_efuse_read(rt2x00dev, i); |
4680 | |||
4681 | return 0; | ||
4680 | } | 4682 | } |
4681 | EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); | 4683 | EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); |
4682 | 4684 | ||
@@ -4686,11 +4688,14 @@ static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
4686 | u16 word; | 4688 | u16 word; |
4687 | u8 *mac; | 4689 | u8 *mac; |
4688 | u8 default_lna_gain; | 4690 | u8 default_lna_gain; |
4691 | int retval; | ||
4689 | 4692 | ||
4690 | /* | 4693 | /* |
4691 | * Read the EEPROM. | 4694 | * Read the EEPROM. |
4692 | */ | 4695 | */ |
4693 | rt2800_read_eeprom(rt2x00dev); | 4696 | retval = rt2800_read_eeprom(rt2x00dev); |
4697 | if (retval) | ||
4698 | return retval; | ||
4694 | 4699 | ||
4695 | /* | 4700 | /* |
4696 | * Start validation of the data that has been read. | 4701 | * Start validation of the data that has been read. |
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h index a128ceadcb3e..6ec739466db4 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/rt2x00/rt2800lib.h | |||
@@ -43,7 +43,7 @@ struct rt2800_ops { | |||
43 | const unsigned int offset, | 43 | const unsigned int offset, |
44 | const struct rt2x00_field32 field, u32 *reg); | 44 | const struct rt2x00_field32 field, u32 *reg); |
45 | 45 | ||
46 | void (*read_eeprom)(struct rt2x00_dev *rt2x00dev); | 46 | int (*read_eeprom)(struct rt2x00_dev *rt2x00dev); |
47 | bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev); | 47 | bool (*hwcrypt_disabled)(struct rt2x00_dev *rt2x00dev); |
48 | 48 | ||
49 | int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev, | 49 | int (*drv_write_firmware)(struct rt2x00_dev *rt2x00dev, |
@@ -117,11 +117,11 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, | |||
117 | return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg); | 117 | return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg); |
118 | } | 118 | } |
119 | 119 | ||
120 | static inline void rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev) | 120 | static inline int rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev) |
121 | { | 121 | { |
122 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; | 122 | const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; |
123 | 123 | ||
124 | rt2800ops->read_eeprom(rt2x00dev); | 124 | return rt2800ops->read_eeprom(rt2x00dev); |
125 | } | 125 | } |
126 | 126 | ||
127 | static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) | 127 | static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) |
@@ -207,7 +207,7 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev); | |||
207 | void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev); | 207 | void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev); |
208 | 208 | ||
209 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); | 209 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); |
210 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); | 210 | int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); |
211 | 211 | ||
212 | int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev); | 212 | int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev); |
213 | 213 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 9224d874bf24..0e8d1705e368 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -90,17 +90,22 @@ static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token) | |||
90 | } | 90 | } |
91 | 91 | ||
92 | #if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X) | 92 | #if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X) |
93 | static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) | 93 | static int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) |
94 | { | 94 | { |
95 | void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE); | 95 | void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE); |
96 | 96 | ||
97 | if (!base_addr) | ||
98 | return -ENOMEM; | ||
99 | |||
97 | memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); | 100 | memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); |
98 | 101 | ||
99 | iounmap(base_addr); | 102 | iounmap(base_addr); |
103 | return 0; | ||
100 | } | 104 | } |
101 | #else | 105 | #else |
102 | static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) | 106 | static inline int rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) |
103 | { | 107 | { |
108 | return -ENOMEM; | ||
104 | } | 109 | } |
105 | #endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */ | 110 | #endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */ |
106 | 111 | ||
@@ -135,7 +140,7 @@ static void rt2800pci_eepromregister_write(struct eeprom_93cx6 *eeprom) | |||
135 | rt2x00pci_register_write(rt2x00dev, E2PROM_CSR, reg); | 140 | rt2x00pci_register_write(rt2x00dev, E2PROM_CSR, reg); |
136 | } | 141 | } |
137 | 142 | ||
138 | static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) | 143 | static int rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) |
139 | { | 144 | { |
140 | struct eeprom_93cx6 eeprom; | 145 | struct eeprom_93cx6 eeprom; |
141 | u32 reg; | 146 | u32 reg; |
@@ -164,6 +169,8 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) | |||
164 | 169 | ||
165 | eeprom_93cx6_multiread(&eeprom, EEPROM_BASE, rt2x00dev->eeprom, | 170 | eeprom_93cx6_multiread(&eeprom, EEPROM_BASE, rt2x00dev->eeprom, |
166 | EEPROM_SIZE / sizeof(u16)); | 171 | EEPROM_SIZE / sizeof(u16)); |
172 | |||
173 | return 0; | ||
167 | } | 174 | } |
168 | 175 | ||
169 | static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) | 176 | static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) |
@@ -171,13 +178,14 @@ static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) | |||
171 | return rt2800_efuse_detect(rt2x00dev); | 178 | return rt2800_efuse_detect(rt2x00dev); |
172 | } | 179 | } |
173 | 180 | ||
174 | static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) | 181 | static inline int rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) |
175 | { | 182 | { |
176 | rt2800_read_eeprom_efuse(rt2x00dev); | 183 | return rt2800_read_eeprom_efuse(rt2x00dev); |
177 | } | 184 | } |
178 | #else | 185 | #else |
179 | static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) | 186 | static inline int rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) |
180 | { | 187 | { |
188 | return -EOPNOTSUPP; | ||
181 | } | 189 | } |
182 | 190 | ||
183 | static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) | 191 | static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) |
@@ -185,8 +193,9 @@ static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) | |||
185 | return 0; | 193 | return 0; |
186 | } | 194 | } |
187 | 195 | ||
188 | static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) | 196 | static inline int rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) |
189 | { | 197 | { |
198 | return -EOPNOTSUPP; | ||
190 | } | 199 | } |
191 | #endif /* CONFIG_PCI */ | 200 | #endif /* CONFIG_PCI */ |
192 | 201 | ||
@@ -970,14 +979,18 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) | |||
970 | /* | 979 | /* |
971 | * Device probe functions. | 980 | * Device probe functions. |
972 | */ | 981 | */ |
973 | static void rt2800pci_read_eeprom(struct rt2x00_dev *rt2x00dev) | 982 | static int rt2800pci_read_eeprom(struct rt2x00_dev *rt2x00dev) |
974 | { | 983 | { |
984 | int retval; | ||
985 | |||
975 | if (rt2x00_is_soc(rt2x00dev)) | 986 | if (rt2x00_is_soc(rt2x00dev)) |
976 | rt2800pci_read_eeprom_soc(rt2x00dev); | 987 | retval = rt2800pci_read_eeprom_soc(rt2x00dev); |
977 | else if (rt2800pci_efuse_detect(rt2x00dev)) | 988 | else if (rt2800pci_efuse_detect(rt2x00dev)) |
978 | rt2800pci_read_eeprom_efuse(rt2x00dev); | 989 | retval = rt2800pci_read_eeprom_efuse(rt2x00dev); |
979 | else | 990 | else |
980 | rt2800pci_read_eeprom_pci(rt2x00dev); | 991 | retval = rt2800pci_read_eeprom_pci(rt2x00dev); |
992 | |||
993 | return retval; | ||
981 | } | 994 | } |
982 | 995 | ||
983 | static const struct ieee80211_ops rt2800pci_mac80211_ops = { | 996 | static const struct ieee80211_ops rt2800pci_mac80211_ops = { |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 5c149b58ab46..4721cada1591 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -735,13 +735,17 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry, | |||
735 | /* | 735 | /* |
736 | * Device probe functions. | 736 | * Device probe functions. |
737 | */ | 737 | */ |
738 | static void rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev) | 738 | static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev) |
739 | { | 739 | { |
740 | int retval; | ||
741 | |||
740 | if (rt2800_efuse_detect(rt2x00dev)) | 742 | if (rt2800_efuse_detect(rt2x00dev)) |
741 | rt2800_read_eeprom_efuse(rt2x00dev); | 743 | retval = rt2800_read_eeprom_efuse(rt2x00dev); |
742 | else | 744 | else |
743 | rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, | 745 | retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, |
744 | EEPROM_SIZE); | 746 | EEPROM_SIZE); |
747 | |||
748 | return retval; | ||
745 | } | 749 | } |
746 | 750 | ||
747 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) | 751 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) |