David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * IPWireless 3G PCMCIA Network Driver |
| 3 | * |
| 4 | * Original code |
| 5 | * by Stephen Blackheath <stephen@blacksapphire.com>, |
| 6 | * Ben Martel <benm@symmetric.co.nz> |
| 7 | * |
| 8 | * Copyrighted as follows: |
| 9 | * Copyright (C) 2004 by Symmetric Systems Ltd (NZ) |
| 10 | * |
| 11 | * Various driver changes and rewrites, port to new kernels |
| 12 | * Copyright (C) 2006-2007 Jiri Kosina |
| 13 | * |
| 14 | * Misc code cleanups and updates |
| 15 | * Copyright (C) 2007 David Sterba |
| 16 | */ |
| 17 | |
| 18 | #include "hardware.h" |
| 19 | #include "network.h" |
| 20 | #include "main.h" |
| 21 | #include "tty.h" |
| 22 | |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/init.h> |
| 25 | #include <linux/io.h> |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/sched.h> |
| 29 | #include <linux/slab.h> |
| 30 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 31 | #include <pcmcia/cisreg.h> |
| 32 | #include <pcmcia/device_id.h> |
| 33 | #include <pcmcia/ss.h> |
| 34 | #include <pcmcia/ds.h> |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 35 | |
Joe Perches | 25f8f54 | 2011-05-03 19:29:01 -0700 | [diff] [blame] | 36 | static const struct pcmcia_device_id ipw_ids[] = { |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 37 | PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100), |
| 38 | PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0200), |
| 39 | PCMCIA_DEVICE_NULL |
| 40 | }; |
| 41 | MODULE_DEVICE_TABLE(pcmcia, ipw_ids); |
| 42 | |
| 43 | static void ipwireless_detach(struct pcmcia_device *link); |
| 44 | |
| 45 | /* |
| 46 | * Module params |
| 47 | */ |
| 48 | /* Debug mode: more verbose, print sent/recv bytes */ |
| 49 | int ipwireless_debug; |
| 50 | int ipwireless_loopback; |
David Sterba | bee9c7c | 2008-07-28 16:53:21 +0200 | [diff] [blame] | 51 | int ipwireless_out_queue = 10; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 52 | |
| 53 | module_param_named(debug, ipwireless_debug, int, 0); |
| 54 | module_param_named(loopback, ipwireless_loopback, int, 0); |
| 55 | module_param_named(out_queue, ipwireless_out_queue, int, 0); |
| 56 | MODULE_PARM_DESC(debug, "switch on debug messages [0]"); |
| 57 | MODULE_PARM_DESC(loopback, |
| 58 | "debug: enable ras_raw channel [0]"); |
David Sterba | bee9c7c | 2008-07-28 16:53:21 +0200 | [diff] [blame] | 59 | MODULE_PARM_DESC(out_queue, "debug: set size of outgoing PPP queue [10]"); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 60 | |
| 61 | /* Executes in process context. */ |
| 62 | static void signalled_reboot_work(struct work_struct *work_reboot) |
| 63 | { |
| 64 | struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev, |
| 65 | work_reboot); |
| 66 | struct pcmcia_device *link = ipw->link; |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 67 | pcmcia_reset_card(link->socket); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static void signalled_reboot_callback(void *callback_data) |
| 71 | { |
| 72 | struct ipw_dev *ipw = (struct ipw_dev *) callback_data; |
| 73 | |
| 74 | /* Delegate to process context. */ |
| 75 | schedule_work(&ipw->work_reboot); |
| 76 | } |
| 77 | |
Dominik Brodowski | 00990e7 | 2010-07-30 13:13:46 +0200 | [diff] [blame] | 78 | static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) |
Dominik Brodowski | aaa8cfd | 2009-10-18 18:28:39 +0200 | [diff] [blame] | 79 | { |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 80 | struct ipw_dev *ipw = priv_data; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 81 | int ret; |
| 82 | |
Dominik Brodowski | 00990e7 | 2010-07-30 13:13:46 +0200 | [diff] [blame] | 83 | p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; |
Dominik Brodowski | 90abdc3 | 2010-07-24 17:23:51 +0200 | [diff] [blame] | 84 | p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; |
Dominik Brodowski | aaa8cfd | 2009-10-18 18:28:39 +0200 | [diff] [blame] | 85 | |
Dominik Brodowski | aaa8cfd | 2009-10-18 18:28:39 +0200 | [diff] [blame] | 86 | /* 0x40 causes it to generate level mode interrupts. */ |
| 87 | /* 0x04 enables IREQ pin. */ |
Dominik Brodowski | 00990e7 | 2010-07-30 13:13:46 +0200 | [diff] [blame] | 88 | p_dev->config_index |= 0x44; |
Dominik Brodowski | 90abdc3 | 2010-07-24 17:23:51 +0200 | [diff] [blame] | 89 | p_dev->io_lines = 16; |
| 90 | ret = pcmcia_request_io(p_dev); |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 91 | if (ret) |
| 92 | return ret; |
| 93 | |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 94 | if (!request_region(p_dev->resource[0]->start, |
| 95 | resource_size(p_dev->resource[0]), |
| 96 | IPWIRELESS_PCCARD_NAME)) { |
| 97 | ret = -EBUSY; |
| 98 | goto exit; |
| 99 | } |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 100 | |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 101 | p_dev->resource[2]->flags |= |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 102 | WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 103 | |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 104 | ret = pcmcia_request_window(p_dev, p_dev->resource[2], 0); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 105 | if (ret != 0) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 106 | goto exit1; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 107 | |
Dominik Brodowski | 00990e7 | 2010-07-30 13:13:46 +0200 | [diff] [blame] | 108 | ret = pcmcia_map_mem_page(p_dev, p_dev->resource[2], p_dev->card_addr); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 109 | if (ret != 0) |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 110 | goto exit1; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 111 | |
Dominik Brodowski | 00990e7 | 2010-07-30 13:13:46 +0200 | [diff] [blame] | 112 | ipw->is_v2_card = resource_size(p_dev->resource[2]) == 0x100; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 113 | |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 114 | ipw->common_memory = ioremap(p_dev->resource[2]->start, |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 115 | resource_size(p_dev->resource[2])); |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 116 | if (!request_mem_region(p_dev->resource[2]->start, |
| 117 | resource_size(p_dev->resource[2]), |
| 118 | IPWIRELESS_PCCARD_NAME)) { |
| 119 | ret = -EBUSY; |
| 120 | goto exit2; |
| 121 | } |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 122 | |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 123 | p_dev->resource[3]->flags |= WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM | |
| 124 | WIN_ENABLE; |
| 125 | p_dev->resource[3]->end = 0; /* this used to be 0x1000 */ |
| 126 | ret = pcmcia_request_window(p_dev, p_dev->resource[3], 0); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 127 | if (ret != 0) |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 128 | goto exit3; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 129 | |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 130 | ret = pcmcia_map_mem_page(p_dev, p_dev->resource[3], 0); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 131 | if (ret != 0) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 132 | goto exit3; |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 133 | |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 134 | ipw->attr_memory = ioremap(p_dev->resource[3]->start, |
| 135 | resource_size(p_dev->resource[3])); |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 136 | if (!request_mem_region(p_dev->resource[3]->start, |
| 137 | resource_size(p_dev->resource[3]), |
| 138 | IPWIRELESS_PCCARD_NAME)) { |
| 139 | ret = -EBUSY; |
| 140 | goto exit4; |
| 141 | } |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 142 | |
| 143 | return 0; |
| 144 | |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 145 | exit4: |
| 146 | iounmap(ipw->attr_memory); |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 147 | exit3: |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 148 | release_mem_region(p_dev->resource[2]->start, |
| 149 | resource_size(p_dev->resource[2])); |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 150 | exit2: |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 151 | iounmap(ipw->common_memory); |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 152 | exit1: |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 153 | release_region(p_dev->resource[0]->start, |
| 154 | resource_size(p_dev->resource[0])); |
| 155 | exit: |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 156 | pcmcia_disable_device(p_dev); |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 157 | return ret; |
Dominik Brodowski | aaa8cfd | 2009-10-18 18:28:39 +0200 | [diff] [blame] | 158 | } |
| 159 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 160 | static int config_ipwireless(struct ipw_dev *ipw) |
| 161 | { |
| 162 | struct pcmcia_device *link = ipw->link; |
Dominik Brodowski | aaa8cfd | 2009-10-18 18:28:39 +0200 | [diff] [blame] | 163 | int ret = 0; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 164 | |
| 165 | ipw->is_v2_card = 0; |
Dominik Brodowski | 00990e7 | 2010-07-30 13:13:46 +0200 | [diff] [blame] | 166 | link->config_flags |= CONF_AUTO_SET_IO | CONF_AUTO_SET_IOMEM | |
| 167 | CONF_ENABLE_IRQ; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 168 | |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 169 | ret = pcmcia_loop_config(link, ipwireless_probe, ipw); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 170 | if (ret != 0) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 171 | return ret; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 172 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 173 | INIT_WORK(&ipw->work_reboot, signalled_reboot_work); |
| 174 | |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame] | 175 | ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start, |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 176 | ipw->attr_memory, ipw->common_memory, |
| 177 | ipw->is_v2_card, signalled_reboot_callback, |
| 178 | ipw); |
| 179 | |
Dominik Brodowski | eb14120 | 2010-03-07 12:21:16 +0100 | [diff] [blame] | 180 | ret = pcmcia_request_irq(link, ipwireless_interrupt); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 181 | if (ret != 0) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 182 | goto exit; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 183 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 184 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n", |
| 185 | ipw->is_v2_card ? "V2/V3" : "V1"); |
| 186 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame] | 187 | ": I/O ports %pR, irq %d\n", link->resource[0], |
Dominik Brodowski | eb14120 | 2010-03-07 12:21:16 +0100 | [diff] [blame] | 188 | (unsigned int) link->irq); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 189 | if (ipw->attr_memory && ipw->common_memory) |
| 190 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 191 | ": attr memory %pR, common memory %pR\n", |
| 192 | link->resource[3], |
| 193 | link->resource[2]); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 194 | |
| 195 | ipw->network = ipwireless_network_create(ipw->hardware); |
| 196 | if (!ipw->network) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 197 | goto exit; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 198 | |
Dominik Brodowski | b498ada | 2010-03-20 19:43:26 +0100 | [diff] [blame] | 199 | ipw->tty = ipwireless_tty_create(ipw->hardware, ipw->network); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 200 | if (!ipw->tty) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 201 | goto exit; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 202 | |
| 203 | ipwireless_init_hardware_v2_v3(ipw->hardware); |
| 204 | |
| 205 | /* |
| 206 | * Do the RequestConfiguration last, because it enables interrupts. |
| 207 | * Then we don't get any interrupts before we're ready for them. |
| 208 | */ |
Dominik Brodowski | 1ac71e5 | 2010-07-29 19:27:09 +0200 | [diff] [blame] | 209 | ret = pcmcia_enable_device(link); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 210 | if (ret != 0) |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 211 | goto exit; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 212 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 213 | return 0; |
| 214 | |
Dominik Brodowski | af757923 | 2009-10-18 19:48:39 +0200 | [diff] [blame] | 215 | exit: |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 216 | if (ipw->common_memory) { |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 217 | release_mem_region(link->resource[2]->start, |
| 218 | resource_size(link->resource[2])); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 219 | iounmap(ipw->common_memory); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 220 | } |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 221 | if (ipw->attr_memory) { |
| 222 | release_mem_region(link->resource[3]->start, |
| 223 | resource_size(link->resource[3])); |
| 224 | iounmap(ipw->attr_memory); |
| 225 | } |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 226 | pcmcia_disable_device(link); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 227 | return -1; |
| 228 | } |
| 229 | |
| 230 | static void release_ipwireless(struct ipw_dev *ipw) |
| 231 | { |
Julia Lawall | d5bb292 | 2011-02-13 13:12:10 +0100 | [diff] [blame] | 232 | release_region(ipw->link->resource[0]->start, |
| 233 | resource_size(ipw->link->resource[0])); |
David Sterba | 09e491e | 2008-07-28 16:53:16 +0200 | [diff] [blame] | 234 | if (ipw->common_memory) { |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 235 | release_mem_region(ipw->link->resource[2]->start, |
| 236 | resource_size(ipw->link->resource[2])); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 237 | iounmap(ipw->common_memory); |
David Sterba | 09e491e | 2008-07-28 16:53:16 +0200 | [diff] [blame] | 238 | } |
| 239 | if (ipw->attr_memory) { |
Dominik Brodowski | cdb1380 | 2010-07-28 10:59:06 +0200 | [diff] [blame] | 240 | release_mem_region(ipw->link->resource[3]->start, |
| 241 | resource_size(ipw->link->resource[3])); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 242 | iounmap(ipw->attr_memory); |
David Sterba | 09e491e | 2008-07-28 16:53:16 +0200 | [diff] [blame] | 243 | } |
David Sterba | 09e491e | 2008-07-28 16:53:16 +0200 | [diff] [blame] | 244 | pcmcia_disable_device(ipw->link); |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* |
| 248 | * ipwireless_attach() creates an "instance" of the driver, allocating |
| 249 | * local data structures for one device (one interface). The device |
| 250 | * is registered with Card Services. |
| 251 | * |
| 252 | * The pcmcia_device structure is initialized, but we don't actually |
| 253 | * configure the card at this point -- we wait until we receive a |
| 254 | * card insertion event. |
| 255 | */ |
| 256 | static int ipwireless_attach(struct pcmcia_device *link) |
| 257 | { |
| 258 | struct ipw_dev *ipw; |
| 259 | int ret; |
| 260 | |
| 261 | ipw = kzalloc(sizeof(struct ipw_dev), GFP_KERNEL); |
| 262 | if (!ipw) |
| 263 | return -ENOMEM; |
| 264 | |
| 265 | ipw->link = link; |
| 266 | link->priv = ipw; |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 267 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 268 | ipw->hardware = ipwireless_hardware_create(); |
| 269 | if (!ipw->hardware) { |
| 270 | kfree(ipw); |
| 271 | return -ENOMEM; |
| 272 | } |
| 273 | /* RegisterClient will call config_ipwireless */ |
| 274 | |
| 275 | ret = config_ipwireless(ipw); |
| 276 | |
| 277 | if (ret != 0) { |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 278 | ipwireless_detach(link); |
| 279 | return ret; |
| 280 | } |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | /* |
| 286 | * This deletes a driver "instance". The device is de-registered with |
| 287 | * Card Services. If it has been released, all local data structures |
| 288 | * are freed. Otherwise, the structures will be freed when the device |
| 289 | * is released. |
| 290 | */ |
| 291 | static void ipwireless_detach(struct pcmcia_device *link) |
| 292 | { |
| 293 | struct ipw_dev *ipw = link->priv; |
| 294 | |
| 295 | release_ipwireless(ipw); |
| 296 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 297 | if (ipw->tty != NULL) |
| 298 | ipwireless_tty_free(ipw->tty); |
| 299 | if (ipw->network != NULL) |
| 300 | ipwireless_network_free(ipw->network); |
| 301 | if (ipw->hardware != NULL) |
| 302 | ipwireless_hardware_free(ipw->hardware); |
| 303 | kfree(ipw); |
| 304 | } |
| 305 | |
| 306 | static struct pcmcia_driver me = { |
| 307 | .owner = THIS_MODULE, |
| 308 | .probe = ipwireless_attach, |
| 309 | .remove = ipwireless_detach, |
Dominik Brodowski | 2e9b981 | 2010-08-08 11:36:26 +0200 | [diff] [blame] | 310 | .name = IPWIRELESS_PCCARD_NAME, |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 311 | .id_table = ipw_ids |
| 312 | }; |
| 313 | |
| 314 | /* |
| 315 | * Module insertion : initialisation of the module. |
| 316 | * Register the card with cardmgr... |
| 317 | */ |
| 318 | static int __init init_ipwireless(void) |
| 319 | { |
| 320 | int ret; |
| 321 | |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 322 | ret = ipwireless_tty_init(); |
| 323 | if (ret != 0) |
| 324 | return ret; |
| 325 | |
| 326 | ret = pcmcia_register_driver(&me); |
| 327 | if (ret != 0) |
| 328 | ipwireless_tty_release(); |
| 329 | |
| 330 | return ret; |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | * Module removal |
| 335 | */ |
| 336 | static void __exit exit_ipwireless(void) |
| 337 | { |
David Sterba | 099dc4f | 2008-02-07 10:57:12 +0100 | [diff] [blame] | 338 | pcmcia_unregister_driver(&me); |
| 339 | ipwireless_tty_release(); |
| 340 | } |
| 341 | |
| 342 | module_init(init_ipwireless); |
| 343 | module_exit(exit_ipwireless); |
| 344 | |
| 345 | MODULE_AUTHOR(IPWIRELESS_PCMCIA_AUTHOR); |
| 346 | MODULE_DESCRIPTION(IPWIRELESS_PCCARD_NAME " " IPWIRELESS_PCMCIA_VERSION); |
| 347 | MODULE_LICENSE("GPL"); |