aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-12-29 08:51:51 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-01-07 15:16:54 -0500
commita02308e931ad0bba19803779bec491c4b2d67b47 (patch)
treea4b4f475811c87b5e0b0e4b5dff36777b6c085c9 /drivers/net
parente1b97c9bc5902ec8b36247bcb7c3552895611485 (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.c9
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.h8
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c35
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c12
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
4674void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) 4674int 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}
4681EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); 4683EXPORT_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
120static inline void rt2800_read_eeprom(struct rt2x00_dev *rt2x00dev) 120static 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
127static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev) 127static inline bool rt2800_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
@@ -207,7 +207,7 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev);
207void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev); 207void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
208 208
209int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); 209int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
210void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); 210int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
211 211
212int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev); 212int 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)
93static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) 93static 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
102static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) 106static 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
138static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) 143static 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
169static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) 176static 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
174static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) 181static 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
179static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) 186static inline int rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
180{ 187{
188 return -EOPNOTSUPP;
181} 189}
182 190
183static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) 191static 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
188static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) 196static 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 */
973static void rt2800pci_read_eeprom(struct rt2x00_dev *rt2x00dev) 982static 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
983static const struct ieee80211_ops rt2800pci_mac80211_ops = { 996static 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 */
738static void rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev) 738static 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
747static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) 751static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)