diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 15:25:51 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-05 18:03:24 -0500 |
commit | f8cfa618dccbdc6dab5297f75779566a388a98fd (patch) | |
tree | b91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/parport | |
parent | b463581154f3f3eecda27cae60df813fefcd84d3 (diff) |
[PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback
Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified
probe() callback. As all in-kernel drivers are changed to this new
callback, there will be no temporary backwards-compatibility. Inside a
probe() function, each driver _must_ set struct pcmcia_device
*p_dev->instance and instance->handle correctly.
With these patches, the basic driver interface for 16-bit PCMCIA drivers
now has the classic four callbacks known also from other buses:
int (*probe) (struct pcmcia_device *dev);
void (*remove) (struct pcmcia_device *dev);
int (*suspend) (struct pcmcia_device *dev);
int (*resume) (struct pcmcia_device *dev);
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/parport')
-rw-r--r-- | drivers/parport/parport_cs.c | 61 |
1 files changed, 12 insertions, 49 deletions
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 763f91a79085..158d92563259 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c | |||
@@ -87,14 +87,9 @@ typedef struct parport_info_t { | |||
87 | struct parport *port; | 87 | struct parport *port; |
88 | } parport_info_t; | 88 | } parport_info_t; |
89 | 89 | ||
90 | static dev_link_t *parport_attach(void); | ||
91 | static void parport_detach(struct pcmcia_device *p_dev); | 90 | static void parport_detach(struct pcmcia_device *p_dev); |
92 | static void parport_config(dev_link_t *link); | 91 | static void parport_config(dev_link_t *link); |
93 | static void parport_cs_release(dev_link_t *); | 92 | static void parport_cs_release(dev_link_t *); |
94 | static int parport_event(event_t event, int priority, | ||
95 | event_callback_args_t *args); | ||
96 | |||
97 | static dev_info_t dev_info = "parport_cs"; | ||
98 | 93 | ||
99 | /*====================================================================== | 94 | /*====================================================================== |
100 | 95 | ||
@@ -104,18 +99,16 @@ static dev_info_t dev_info = "parport_cs"; | |||
104 | 99 | ||
105 | ======================================================================*/ | 100 | ======================================================================*/ |
106 | 101 | ||
107 | static dev_link_t *parport_attach(void) | 102 | static int parport_attach(struct pcmcia_device *p_dev) |
108 | { | 103 | { |
109 | parport_info_t *info; | 104 | parport_info_t *info; |
110 | dev_link_t *link; | 105 | dev_link_t *link; |
111 | client_reg_t client_reg; | 106 | |
112 | int ret; | ||
113 | |||
114 | DEBUG(0, "parport_attach()\n"); | 107 | DEBUG(0, "parport_attach()\n"); |
115 | 108 | ||
116 | /* Create new parport device */ | 109 | /* Create new parport device */ |
117 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 110 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
118 | if (!info) return NULL; | 111 | if (!info) return -ENOMEM; |
119 | memset(info, 0, sizeof(*info)); | 112 | memset(info, 0, sizeof(*info)); |
120 | link = &info->link; link->priv = info; | 113 | link = &info->link; link->priv = info; |
121 | 114 | ||
@@ -126,20 +119,14 @@ static dev_link_t *parport_attach(void) | |||
126 | link->conf.Attributes = CONF_ENABLE_IRQ; | 119 | link->conf.Attributes = CONF_ENABLE_IRQ; |
127 | link->conf.Vcc = 50; | 120 | link->conf.Vcc = 50; |
128 | link->conf.IntType = INT_MEMORY_AND_IO; | 121 | link->conf.IntType = INT_MEMORY_AND_IO; |
129 | 122 | ||
130 | /* Register with Card Services */ | 123 | link->handle = p_dev; |
131 | link->next = NULL; | 124 | p_dev->instance = link; |
132 | client_reg.dev_info = &dev_info; | 125 | |
133 | client_reg.Version = 0x0210; | 126 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
134 | client_reg.event_callback_args.client_data = link; | 127 | parport_config(link); |
135 | ret = pcmcia_register_client(&link->handle, &client_reg); | 128 | |
136 | if (ret != CS_SUCCESS) { | 129 | return 0; |
137 | cs_error(link->handle, RegisterClient, ret); | ||
138 | parport_detach(link->handle); | ||
139 | return NULL; | ||
140 | } | ||
141 | |||
142 | return link; | ||
143 | } /* parport_attach */ | 130 | } /* parport_attach */ |
144 | 131 | ||
145 | /*====================================================================== | 132 | /*====================================================================== |
@@ -329,29 +316,6 @@ static int parport_resume(struct pcmcia_device *dev) | |||
329 | return 0; | 316 | return 0; |
330 | } | 317 | } |
331 | 318 | ||
332 | /*====================================================================== | ||
333 | |||
334 | The card status event handler. Mostly, this schedules other | ||
335 | stuff to run after an event is received. | ||
336 | |||
337 | ======================================================================*/ | ||
338 | |||
339 | int parport_event(event_t event, int priority, | ||
340 | event_callback_args_t *args) | ||
341 | { | ||
342 | dev_link_t *link = args->client_data; | ||
343 | |||
344 | DEBUG(1, "parport_event(0x%06x)\n", event); | ||
345 | |||
346 | switch (event) { | ||
347 | case CS_EVENT_CARD_INSERTION: | ||
348 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
349 | parport_config(link); | ||
350 | break; | ||
351 | } | ||
352 | return 0; | ||
353 | } /* parport_event */ | ||
354 | |||
355 | static struct pcmcia_device_id parport_ids[] = { | 319 | static struct pcmcia_device_id parport_ids[] = { |
356 | PCMCIA_DEVICE_FUNC_ID(3), | 320 | PCMCIA_DEVICE_FUNC_ID(3), |
357 | PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), | 321 | PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), |
@@ -364,8 +328,7 @@ static struct pcmcia_driver parport_cs_driver = { | |||
364 | .drv = { | 328 | .drv = { |
365 | .name = "parport_cs", | 329 | .name = "parport_cs", |
366 | }, | 330 | }, |
367 | .attach = parport_attach, | 331 | .probe = parport_attach, |
368 | .event = parport_event, | ||
369 | .remove = parport_detach, | 332 | .remove = parport_detach, |
370 | .id_table = parport_ids, | 333 | .id_table = parport_ids, |
371 | .suspend = parport_suspend, | 334 | .suspend = parport_suspend, |