aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/airo_cs.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/wireless/airo_cs.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/wireless/airo_cs.c')
-rw-r--r--drivers/net/wireless/airo_cs.c156
1 files changed, 12 insertions, 144 deletions
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 9a121a5b787c..c983c10e0f6a 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -32,7 +32,6 @@
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/netdevice.h> 33#include <linux/netdevice.h>
34 34
35#include <pcmcia/cs.h>
36#include <pcmcia/cistpl.h> 35#include <pcmcia/cistpl.h>
37#include <pcmcia/cisreg.h> 36#include <pcmcia/cisreg.h>
38#include <pcmcia/ds.h> 37#include <pcmcia/ds.h>
@@ -54,58 +53,21 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
54 53
55/*====================================================================*/ 54/*====================================================================*/
56 55
57/*
58 The event() function is this driver's Card Services event handler.
59 It will be called by Card Services when an appropriate card status
60 event is received. The config() and release() entry points are
61 used to configure or release a socket, in response to card
62 insertion and ejection events. They are invoked from the airo_cs
63 event handler.
64*/
65
66static int airo_config(struct pcmcia_device *link); 56static int airo_config(struct pcmcia_device *link);
67static void airo_release(struct pcmcia_device *link); 57static void airo_release(struct pcmcia_device *link);
68 58
69/*
70 The attach() and detach() entry points are used to create and destroy
71 "instances" of the driver, where each instance represents everything
72 needed to manage one actual PCMCIA card.
73*/
74
75static void airo_detach(struct pcmcia_device *p_dev); 59static void airo_detach(struct pcmcia_device *p_dev);
76 60
77typedef struct local_info_t { 61typedef struct local_info_t {
78 struct net_device *eth_dev; 62 struct net_device *eth_dev;
79} local_info_t; 63} local_info_t;
80 64
81/*======================================================================
82
83 airo_attach() creates an "instance" of the driver, allocating
84 local data structures for one device. The device is registered
85 with Card Services.
86
87 The dev_link structure is initialized, but we don't actually
88 configure the card at this point -- we wait until we receive a
89 card insertion event.
90
91 ======================================================================*/
92
93static int airo_probe(struct pcmcia_device *p_dev) 65static int airo_probe(struct pcmcia_device *p_dev)
94{ 66{
95 local_info_t *local; 67 local_info_t *local;
96 68
97 dev_dbg(&p_dev->dev, "airo_attach()\n"); 69 dev_dbg(&p_dev->dev, "airo_attach()\n");
98 70
99 /*
100 General socket configuration defaults can go here. In this
101 client, we assume very little, and rely on the CIS for almost
102 everything. In most clients, many details (i.e., number, sizes,
103 and attributes of IO windows) are fixed by the nature of the
104 device, and can be hard-wired here.
105 */
106 p_dev->conf.Attributes = 0;
107 p_dev->conf.IntType = INT_MEMORY_AND_IO;
108
109 /* Allocate space for private device-specific data */ 71 /* Allocate space for private device-specific data */
110 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 72 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
111 if (!local) { 73 if (!local) {
@@ -117,15 +79,6 @@ static int airo_probe(struct pcmcia_device *p_dev)
117 return airo_config(p_dev); 79 return airo_config(p_dev);
118} /* airo_attach */ 80} /* airo_attach */
119 81
120/*======================================================================
121
122 This deletes a driver "instance". The device is de-registered
123 with Card Services. If it has been released, all local data
124 structures are freed. Otherwise, the structures will be freed
125 when the device is released.
126
127 ======================================================================*/
128
129static void airo_detach(struct pcmcia_device *link) 82static void airo_detach(struct pcmcia_device *link)
130{ 83{
131 dev_dbg(&link->dev, "airo_detach\n"); 84 dev_dbg(&link->dev, "airo_detach\n");
@@ -140,60 +93,12 @@ static void airo_detach(struct pcmcia_device *link)
140 kfree(link->priv); 93 kfree(link->priv);
141} /* airo_detach */ 94} /* airo_detach */
142 95
143/*====================================================================== 96static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
144
145 airo_config() is scheduled to run after a CARD_INSERTION event
146 is received, to configure the PCMCIA socket, and to make the
147 device available to the system.
148
149 ======================================================================*/
150
151static int airo_cs_config_check(struct pcmcia_device *p_dev,
152 cistpl_cftable_entry_t *cfg,
153 cistpl_cftable_entry_t *dflt,
154 unsigned int vcc,
155 void *priv_data)
156{ 97{
157 if (cfg->index == 0) 98 if (p_dev->config_index == 0)
158 return -ENODEV; 99 return -EINVAL;
159
160 /* Does this card need audio output? */
161 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
162 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
163 p_dev->conf.Status = CCSR_AUDIO_ENA;
164 }
165
166 /* Use power settings for Vcc and Vpp if present */
167 /* Note that the CIS values need to be rescaled */
168 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
169 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
170 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
171 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
172
173 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
174
175 /* IO window settings */
176 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
177 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
178 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
179 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
180 p_dev->resource[0]->flags |=
181 pcmcia_io_cfg_data_width(io->flags);
182 p_dev->resource[0]->start = io->win[0].base;
183 p_dev->resource[0]->end = io->win[0].len;
184 if (io->nwin > 1) {
185 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
186 p_dev->resource[1]->start = io->win[1].base;
187 p_dev->resource[1]->end = io->win[1].len;
188 }
189 }
190 100
191 /* This reserves IO space but doesn't actually enable it */ 101 return pcmcia_request_io(p_dev);
192 if (pcmcia_request_io(p_dev) != 0)
193 return -ENODEV;
194
195 /* If we got this far, we're cool! */
196 return 0;
197} 102}
198 103
199 104
@@ -206,20 +111,9 @@ static int airo_config(struct pcmcia_device *link)
206 111
207 dev_dbg(&link->dev, "airo_config\n"); 112 dev_dbg(&link->dev, "airo_config\n");
208 113
209 /* 114 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
210 * In this loop, we scan the CIS for configuration table 115 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
211 * entries, each of which describes a valid card 116
212 * configuration, including voltage, IO window, memory window,
213 * and interrupt settings.
214 *
215 * We make no assumptions about the card to be configured: we
216 * use just the information available in the CIS. In an ideal
217 * world, this would work for any PCMCIA card, but it requires
218 * a complete and accurate CIS. In practice, a driver usually
219 * "knows" most of these things without consulting the CIS,
220 * and most client drivers will only use the CIS to fill in
221 * implementation-defined details.
222 */
223 ret = pcmcia_loop_config(link, airo_cs_config_check, NULL); 117 ret = pcmcia_loop_config(link, airo_cs_config_check, NULL);
224 if (ret) 118 if (ret)
225 goto failed; 119 goto failed;
@@ -227,12 +121,7 @@ static int airo_config(struct pcmcia_device *link)
227 if (!link->irq) 121 if (!link->irq)
228 goto failed; 122 goto failed;
229 123
230 /* 124 ret = pcmcia_enable_device(link);
231 This actually configures the PCMCIA socket -- setting up
232 the I/O windows and the interrupt mapping, and putting the
233 card and host interface into "Memory and IO" mode.
234 */
235 ret = pcmcia_request_configuration(link, &link->conf);
236 if (ret) 125 if (ret)
237 goto failed; 126 goto failed;
238 ((local_info_t *)link->priv)->eth_dev = 127 ((local_info_t *)link->priv)->eth_dev =
@@ -241,17 +130,6 @@ static int airo_config(struct pcmcia_device *link)
241 if (!((local_info_t *)link->priv)->eth_dev) 130 if (!((local_info_t *)link->priv)->eth_dev)
242 goto failed; 131 goto failed;
243 132
244 /* Finally, report what we've done */
245 dev_info(&link->dev, "index 0x%02x: ",
246 link->conf.ConfigIndex);
247 if (link->conf.Vpp)
248 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
249 printk(", irq %d", link->irq);
250 if (link->resource[0])
251 printk(" & %pR", link->resource[0]);
252 if (link->resource[1])
253 printk(" & %pR", link->resource[1]);
254 printk("\n");
255 return 0; 133 return 0;
256 134
257 failed: 135 failed:
@@ -259,14 +137,6 @@ static int airo_config(struct pcmcia_device *link)
259 return -ENODEV; 137 return -ENODEV;
260} /* airo_config */ 138} /* airo_config */
261 139
262/*======================================================================
263
264 After a card is removed, airo_release() will unregister the
265 device, and release the PCMCIA configuration. If the device is
266 still open, this will be postponed until it is closed.
267
268 ======================================================================*/
269
270static void airo_release(struct pcmcia_device *link) 140static void airo_release(struct pcmcia_device *link)
271{ 141{
272 dev_dbg(&link->dev, "airo_release\n"); 142 dev_dbg(&link->dev, "airo_release\n");
@@ -294,7 +164,7 @@ static int airo_resume(struct pcmcia_device *link)
294 return 0; 164 return 0;
295} 165}
296 166
297static struct pcmcia_device_id airo_ids[] = { 167static const struct pcmcia_device_id airo_ids[] = {
298 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), 168 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a),
299 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005), 169 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005),
300 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007), 170 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007),
@@ -305,9 +175,7 @@ MODULE_DEVICE_TABLE(pcmcia, airo_ids);
305 175
306static struct pcmcia_driver airo_driver = { 176static struct pcmcia_driver airo_driver = {
307 .owner = THIS_MODULE, 177 .owner = THIS_MODULE,
308 .drv = { 178 .name = "airo_cs",
309 .name = "airo_cs",
310 },
311 .probe = airo_probe, 179 .probe = airo_probe,
312 .remove = airo_detach, 180 .remove = airo_detach,
313 .id_table = airo_ids, 181 .id_table = airo_ids,
@@ -315,12 +183,12 @@ static struct pcmcia_driver airo_driver = {
315 .resume = airo_resume, 183 .resume = airo_resume,
316}; 184};
317 185
318static int airo_cs_init(void) 186static int __init airo_cs_init(void)
319{ 187{
320 return pcmcia_register_driver(&airo_driver); 188 return pcmcia_register_driver(&airo_driver);
321} 189}
322 190
323static void airo_cs_cleanup(void) 191static void __exit airo_cs_cleanup(void)
324{ 192{
325 pcmcia_unregister_driver(&airo_driver); 193 pcmcia_unregister_driver(&airo_driver);
326} 194}