43 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
45 #include <linux/stddef.h>
46 #include <linux/errno.h>
47 #include <linux/string.h>
48 #include <linux/slab.h>
49 #include <linux/kernel.h>
50 #include <linux/module.h>
52 #include <linux/wanrouter.h>
67 #define CYCX_DRV_VERSION 0
68 #define CYCX_DRV_RELEASE 11
69 #define CYCX_MAX_CARDS 1
71 #define CONFIG_CYCX_CARDS 1
77 static int cycx_wan_shutdown(
struct wan_device *wandev);
87 static const char cycx_drvname[] =
"cyclomx";
88 static const char cycx_fullname[] =
"CYCLOM 2X(tm) Sync Card Driver";
89 static const char cycx_copyright[] =
"(c) 1998-2003 Arnaldo Carvalho de Melo "
92 static struct cycx_device *cycx_card_array;
108 static int __init cycx_init(
void)
118 cycx_ncards =
max_t(
int, cycx_ncards, 1);
119 cycx_card_array = kcalloc(cycx_ncards,
sizeof(
struct cycx_device),
GFP_KERNEL);
120 if (!cycx_card_array)
125 for (cnt = 0; cnt < cycx_ncards; ++
cnt) {
126 struct cycx_device *
card = &cycx_card_array[
cnt];
129 sprintf(card->devname,
"%s%d", cycx_drvname, cnt + 1);
131 wandev->
name = card->devname;
133 wandev->
setup = cycx_wan_setup;
134 wandev->
shutdown = cycx_wan_shutdown;
138 pr_err(
"%s registration failed with error %d!\n",
146 kfree(cycx_card_array);
159 static void __exit cycx_exit(
void)
163 for (; i < cycx_ncards; ++
i) {
164 struct cycx_device *card = &cycx_card_array[
i];
168 kfree(cycx_card_array);
187 struct cycx_device *
card;
192 if (!wandev || !wandev->
private || !conf)
202 pr_err(
"%s: firmware not found in configuration data!\n",
207 if (conf->
irq <= 0) {
208 pr_err(
"%s: can't configure without IRQ!\n", wandev->
name);
213 irq = conf->
irq == 2 ? 9 : conf->
irq;
216 pr_err(
"%s: can't reserve IRQ %d!\n", wandev->
name, irq);
221 memset(&card->hw, 0,
sizeof(card->hw));
235 wandev->
maddr = (
unsigned long)card->hw.dpmbase;
236 wandev->
msize = card->hw.dpmsize;
238 wandev->
hw_opt[3] = card->hw.fwid;
241 switch (card->hw.fwid) {
242 #ifdef CONFIG_CYCLOMX_X25
248 pr_err(
"%s: this firmware is not supported!\n", wandev->
name);
273 static int cycx_wan_shutdown(
struct wan_device *wandev)
276 struct cycx_device *
card;
279 if (!wandev || !wandev->
private)
302 struct cycx_device *card =
dev_id;
308 pr_warn(
"%s: interrupt re-entrancy on IRQ %d!\n",
309 card->devname, card->wandev.irq);
324 char *string_state =
NULL;
328 if (card->wandev.state != state) {
331 string_state =
"connected!";
334 string_state =
"disconnected!";
337 pr_info(
"%s: link %s\n", card->devname, string_state);
338 card->wandev.state =
state;
342 spin_unlock_irqrestore(&card->lock, flags);