aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-07-15 04:25:35 -0400
committerJeff Garzik <jeff@garzik.org>2007-07-17 17:18:29 -0400
commit0566a66382ce82310c2bc98fb3560419e9f4349f (patch)
treef574131004fe9e4af2f6c13f1087ba580481a211 /drivers/isdn/hisax
parent881ebdc9f4fb6466a6198ef7943b8637e0a48232 (diff)
[ISDN] HiSax netjet_s: code movement, prep for hotplug
1) Remove CONFIG_PCI ifdefs. PCI is required in Kconfig. 2) Break up setup_netjet_s() into three separate internal functions. This helps facilitate upcoming use of PCI hotplug API, and in addition makes the code much easier to follow. No code is changed, just moved around. I even kept the out-of-favor "return(0)" style used in the current source code. Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/isdn/hisax')
-rw-r--r--drivers/isdn/hisax/nj_s.c194
1 files changed, 108 insertions, 86 deletions
diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c
index c09ffb135330..fa2db87667c8 100644
--- a/drivers/isdn/hisax/nj_s.c
+++ b/drivers/isdn/hisax/nj_s.c
@@ -148,107 +148,87 @@ NETjet_S_card_msg(struct IsdnCardState *cs, int mt, void *arg)
148 return(0); 148 return(0);
149} 149}
150 150
151static struct pci_dev *dev_netjet __devinitdata = NULL; 151static int __devinit njs_pci_probe(struct pci_dev *dev_netjet,
152 152 struct IsdnCardState *cs)
153int __devinit
154setup_netjet_s(struct IsdnCard *card)
155{ 153{
156 int bytecnt,cfg; 154 int cfg;
157 struct IsdnCardState *cs = card->cs;
158 char tmp[64];
159 155
160#ifdef __BIG_ENDIAN 156 if (pci_enable_device(dev_netjet))
161#error "not running on big endian machines now"
162#endif
163 strcpy(tmp, NETjet_S_revision);
164 printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
165 if (cs->typ != ISDN_CTYPE_NETJET_S)
166 return(0); 157 return(0);
167 test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); 158 pci_set_master(dev_netjet);
159 cs->irq = dev_netjet->irq;
160 if (!cs->irq) {
161 printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n");
162 return(0);
163 }
164 cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
165 if (!cs->hw.njet.base) {
166 printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n");
167 return(0);
168 }
169 /* the TJ300 and TJ320 must be detected, the IRQ handling is different
170 * unfortunatly the chips use the same device ID, but the TJ320 has
171 * the bit20 in status PCI cfg register set
172 */
173 pci_read_config_dword(dev_netjet, 0x04, &cfg);
174 if (cfg & 0x00100000)
175 cs->subtyp = 1; /* TJ320 */
176 else
177 cs->subtyp = 0; /* TJ300 */
178 /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */
179 if ((dev_netjet->subsystem_vendor == 0x55) &&
180 (dev_netjet->subsystem_device == 0x02)) {
181 printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n");
182 printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n");
183 return(0);
184 }
185 /* end new code */
168 186
169#ifdef CONFIG_PCI 187 return(1);
188}
170 189
171 for ( ;; ) 190static int __devinit njs_cs_init(struct IsdnCard *card,
172 { 191 struct IsdnCardState *cs)
173 if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET, 192{
174 PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
175 if (pci_enable_device(dev_netjet))
176 return(0);
177 pci_set_master(dev_netjet);
178 cs->irq = dev_netjet->irq;
179 if (!cs->irq) {
180 printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n");
181 return(0);
182 }
183 cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
184 if (!cs->hw.njet.base) {
185 printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n");
186 return(0);
187 }
188 /* the TJ300 and TJ320 must be detected, the IRQ handling is different
189 * unfortunatly the chips use the same device ID, but the TJ320 has
190 * the bit20 in status PCI cfg register set
191 */
192 pci_read_config_dword(dev_netjet, 0x04, &cfg);
193 if (cfg & 0x00100000)
194 cs->subtyp = 1; /* TJ320 */
195 else
196 cs->subtyp = 0; /* TJ300 */
197 /* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */
198 if ((dev_netjet->subsystem_vendor == 0x55) &&
199 (dev_netjet->subsystem_device == 0x02)) {
200 printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n");
201 printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n");
202 return(0);
203 }
204 /* end new code */
205 } else {
206 printk(KERN_WARNING "NETjet-S: No PCI card found\n");
207 return(0);
208 }
209 193
210 cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA; 194 cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
211 cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF; 195 cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
212 196
213 cs->hw.njet.ctrl_reg = 0xff; /* Reset On */ 197 cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
214 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg); 198 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
215 mdelay(10); 199 mdelay(10);
216 200
217 cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */ 201 cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
218 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg); 202 byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
219 mdelay(10); 203 mdelay(10);
220 204
221 cs->hw.njet.auxd = 0xC0; 205 cs->hw.njet.auxd = 0xC0;
222 cs->hw.njet.dmactrl = 0; 206 cs->hw.njet.dmactrl = 0;
223 207
224 byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ); 208 byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
225 byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ); 209 byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
226 byteout(cs->hw.njet.auxa, cs->hw.njet.auxd); 210 byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
227 211
228 switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) ) 212 switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) )
229 { 213 {
230 case 0 : 214 case 0 :
231 break; 215 return 1; /* end loop */
232 216
233 case 3 : 217 case 3 :
234 printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" ); 218 printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" );
235 continue; 219 return -1; /* continue looping */
236 220
237 default : 221 default :
238 printk( KERN_WARNING "NETjet-S: No PCI card found\n" ); 222 printk( KERN_WARNING "NETjet-S: No PCI card found\n" );
239 return 0; 223 return 0; /* end loop & function */
240 }
241 break;
242 } 224 }
243#else 225 return 1; /* end loop */
244 226}
245 printk(KERN_WARNING "NETjet-S: NO_PCI_BIOS\n");
246 printk(KERN_WARNING "NETjet-S: unable to config NETJET-S PCI\n");
247 return (0);
248
249#endif /* CONFIG_PCI */
250 227
251 bytecnt = 256; 228static int __devinit njs_cs_init_rest(struct IsdnCard *card,
229 struct IsdnCardState *cs)
230{
231 const int bytecnt = 256;
252 232
253 printk(KERN_INFO 233 printk(KERN_INFO
254 "NETjet-S: %s card configured at %#lx IRQ %d\n", 234 "NETjet-S: %s card configured at %#lx IRQ %d\n",
@@ -273,5 +253,47 @@ setup_netjet_s(struct IsdnCard *card)
273 cs->irq_func = &netjet_s_interrupt; 253 cs->irq_func = &netjet_s_interrupt;
274 cs->irq_flags |= IRQF_SHARED; 254 cs->irq_flags |= IRQF_SHARED;
275 ISACVersion(cs, "NETjet-S:"); 255 ISACVersion(cs, "NETjet-S:");
256
276 return (1); 257 return (1);
277} 258}
259
260static struct pci_dev *dev_netjet __devinitdata = NULL;
261
262int __devinit
263setup_netjet_s(struct IsdnCard *card)
264{
265 int ret;
266 struct IsdnCardState *cs = card->cs;
267 char tmp[64];
268
269#ifdef __BIG_ENDIAN
270#error "not running on big endian machines now"
271#endif
272 strcpy(tmp, NETjet_S_revision);
273 printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
274 if (cs->typ != ISDN_CTYPE_NETJET_S)
275 return(0);
276 test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
277
278 for ( ;; )
279 {
280 if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
281 PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
282 ret = njs_pci_probe(dev_netjet, cs);
283 if (!ret)
284 return(0);
285 } else {
286 printk(KERN_WARNING "NETjet-S: No PCI card found\n");
287 return(0);
288 }
289
290 ret = njs_cs_init(card, cs);
291 if (!ret)
292 return(0);
293 if (ret > 0)
294 break;
295 /* otherwise, ret < 0, continue looping */
296 }
297
298 return njs_cs_init_rest(card, cs);
299}