diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-10 14:48:59 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-31 10:01:58 -0500 |
commit | 855cdf134dfcf2ecb92ac4ad675cf655d8ceb678 (patch) | |
tree | 167a028b44e1bc043b544357d958a6a20529968b /drivers | |
parent | dbb22f0d65ccc2e9dfeb4c420942f2757a80f8d2 (diff) |
[PATCH] pcmcia: always use device pointer to config_t
Update the remaining users using the static lookup table of the PCMCIA
function configuration to use the struct pcmcia_device-contained pointer.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pcmcia/cs_internal.h | 5 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 57 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 39 |
3 files changed, 58 insertions, 43 deletions
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index f889a44280f5..88c96aee0f45 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h | |||
@@ -126,10 +126,9 @@ extern struct class_interface pccard_sysfs_interface; | |||
126 | extern struct rw_semaphore pcmcia_socket_list_rwsem; | 126 | extern struct rw_semaphore pcmcia_socket_list_rwsem; |
127 | extern struct list_head pcmcia_socket_list; | 127 | extern struct list_head pcmcia_socket_list; |
128 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); | 128 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); |
129 | int pccard_get_configuration_info(struct pcmcia_socket *s, unsigned int function, config_info_t *config); | 129 | int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); |
130 | int pccard_reset_card(struct pcmcia_socket *skt); | 130 | int pccard_reset_card(struct pcmcia_socket *skt); |
131 | int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status); | 131 | int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, cs_status_t *status); |
132 | int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int function, conf_reg_t *reg); | ||
133 | 132 | ||
134 | 133 | ||
135 | struct pcmcia_callback{ | 134 | struct pcmcia_callback{ |
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 80969f7e7a0b..56b625d171ae 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -70,10 +70,26 @@ extern int ds_pc_debug; | |||
70 | #define ds_dbg(lvl, fmt, arg...) do { } while (0) | 70 | #define ds_dbg(lvl, fmt, arg...) do { } while (0) |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s, | ||
74 | unsigned int function) | ||
75 | { | ||
76 | struct pcmcia_device *p_dev = NULL; | ||
77 | unsigned long flags; | ||
78 | |||
79 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | ||
80 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { | ||
81 | if (p_dev->func == function) { | ||
82 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | ||
83 | return pcmcia_get_dev(p_dev); | ||
84 | } | ||
85 | } | ||
86 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | ||
87 | return NULL; | ||
88 | } | ||
73 | 89 | ||
74 | /* backwards-compatible accessing of driver --- by name! */ | 90 | /* backwards-compatible accessing of driver --- by name! */ |
75 | 91 | ||
76 | static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) | 92 | static struct pcmcia_driver *get_pcmcia_driver(dev_info_t *dev_info) |
77 | { | 93 | { |
78 | struct device_driver *drv; | 94 | struct device_driver *drv; |
79 | struct pcmcia_driver *p_drv; | 95 | struct pcmcia_driver *p_drv; |
@@ -583,9 +599,11 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
583 | if (buf->config.Function && | 599 | if (buf->config.Function && |
584 | (buf->config.Function >= s->functions)) | 600 | (buf->config.Function >= s->functions)) |
585 | ret = CS_BAD_ARGS; | 601 | ret = CS_BAD_ARGS; |
586 | else | 602 | else { |
587 | ret = pccard_get_configuration_info(s, | 603 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); |
588 | buf->config.Function, &buf->config); | 604 | ret = pccard_get_configuration_info(s, p_dev, &buf->config); |
605 | pcmcia_put_dev(p_dev); | ||
606 | } | ||
589 | break; | 607 | break; |
590 | case DS_GET_FIRST_TUPLE: | 608 | case DS_GET_FIRST_TUPLE: |
591 | down(&s->skt_sem); | 609 | down(&s->skt_sem); |
@@ -609,12 +627,15 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
609 | ret = pccard_reset_card(s); | 627 | ret = pccard_reset_card(s); |
610 | break; | 628 | break; |
611 | case DS_GET_STATUS: | 629 | case DS_GET_STATUS: |
612 | if (buf->status.Function && | 630 | if (buf->status.Function && |
613 | (buf->status.Function >= s->functions)) | 631 | (buf->status.Function >= s->functions)) |
614 | ret = CS_BAD_ARGS; | 632 | ret = CS_BAD_ARGS; |
615 | else | 633 | else { |
616 | ret = pccard_get_status(s, buf->status.Function, &buf->status); | 634 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); |
617 | break; | 635 | ret = pccard_get_status(s, p_dev, &buf->status); |
636 | pcmcia_put_dev(p_dev); | ||
637 | } | ||
638 | break; | ||
618 | case DS_VALIDATE_CIS: | 639 | case DS_VALIDATE_CIS: |
619 | down(&s->skt_sem); | 640 | down(&s->skt_sem); |
620 | pcmcia_validate_mem(s); | 641 | pcmcia_validate_mem(s); |
@@ -638,12 +659,16 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
638 | err = -EPERM; | 659 | err = -EPERM; |
639 | goto free_out; | 660 | goto free_out; |
640 | } | 661 | } |
641 | if (buf->conf_reg.Function && | 662 | |
642 | (buf->conf_reg.Function >= s->functions)) | 663 | ret = CS_BAD_ARGS; |
643 | ret = CS_BAD_ARGS; | 664 | |
644 | else | 665 | if (!(buf->conf_reg.Function && |
645 | ret = pccard_access_configuration_register(s, | 666 | (buf->conf_reg.Function >= s->functions))) { |
646 | buf->conf_reg.Function, &buf->conf_reg); | 667 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function); |
668 | if (p_dev) | ||
669 | ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg); | ||
670 | pcmcia_put_dev(p_dev); | ||
671 | } | ||
647 | break; | 672 | break; |
648 | case DS_GET_FIRST_REGION: | 673 | case DS_GET_FIRST_REGION: |
649 | case DS_GET_NEXT_REGION: | 674 | case DS_GET_NEXT_REGION: |
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 11a94d9a15fb..aabde8be6470 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -165,21 +165,19 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base, | |||
165 | * this and the tuple reading services. | 165 | * this and the tuple reading services. |
166 | */ | 166 | */ |
167 | 167 | ||
168 | int pccard_access_configuration_register(struct pcmcia_socket *s, | 168 | int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, |
169 | unsigned int function, | ||
170 | conf_reg_t *reg) | 169 | conf_reg_t *reg) |
171 | { | 170 | { |
171 | struct pcmcia_socket *s; | ||
172 | config_t *c; | 172 | config_t *c; |
173 | int addr; | 173 | int addr; |
174 | u_char val; | 174 | u_char val; |
175 | 175 | ||
176 | if (!s || !s->config) | 176 | if (!p_dev || !p_dev->function_config) |
177 | return CS_NO_CARD; | 177 | return CS_NO_CARD; |
178 | 178 | ||
179 | c = &s->config[function]; | 179 | s = p_dev->socket; |
180 | 180 | c = p_dev->function_config; | |
181 | if (c == NULL) | ||
182 | return CS_NO_CARD; | ||
183 | 181 | ||
184 | if (!(c->state & CONFIG_LOCKED)) | 182 | if (!(c->state & CONFIG_LOCKED)) |
185 | return CS_CONFIGURATION_LOCKED; | 183 | return CS_CONFIGURATION_LOCKED; |
@@ -200,20 +198,12 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, | |||
200 | break; | 198 | break; |
201 | } | 199 | } |
202 | return CS_SUCCESS; | 200 | return CS_SUCCESS; |
203 | } /* pccard_access_configuration_register */ | 201 | } /* pcmcia_access_configuration_register */ |
204 | |||
205 | int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | ||
206 | conf_reg_t *reg) | ||
207 | { | ||
208 | return pccard_access_configuration_register(p_dev->socket, | ||
209 | p_dev->func, reg); | ||
210 | } | ||
211 | EXPORT_SYMBOL(pcmcia_access_configuration_register); | 202 | EXPORT_SYMBOL(pcmcia_access_configuration_register); |
212 | 203 | ||
213 | 204 | ||
214 | |||
215 | int pccard_get_configuration_info(struct pcmcia_socket *s, | 205 | int pccard_get_configuration_info(struct pcmcia_socket *s, |
216 | unsigned int function, | 206 | struct pcmcia_device *p_dev, |
217 | config_info_t *config) | 207 | config_info_t *config) |
218 | { | 208 | { |
219 | config_t *c; | 209 | config_t *c; |
@@ -221,7 +211,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, | |||
221 | if (!(s->state & SOCKET_PRESENT)) | 211 | if (!(s->state & SOCKET_PRESENT)) |
222 | return CS_NO_CARD; | 212 | return CS_NO_CARD; |
223 | 213 | ||
224 | config->Function = function; | 214 | config->Function = p_dev->func; |
225 | 215 | ||
226 | #ifdef CONFIG_CARDBUS | 216 | #ifdef CONFIG_CARDBUS |
227 | if (s->state & SOCKET_CARDBUS) { | 217 | if (s->state & SOCKET_CARDBUS) { |
@@ -242,7 +232,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, | |||
242 | } | 232 | } |
243 | #endif | 233 | #endif |
244 | 234 | ||
245 | c = (s->config != NULL) ? &s->config[function] : NULL; | 235 | c = (p_dev) ? p_dev->function_config : NULL; |
246 | 236 | ||
247 | if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { | 237 | if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { |
248 | config->Attributes = 0; | 238 | config->Attributes = 0; |
@@ -271,7 +261,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, | |||
271 | int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, | 261 | int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, |
272 | config_info_t *config) | 262 | config_info_t *config) |
273 | { | 263 | { |
274 | return pccard_get_configuration_info(p_dev->socket, p_dev->func, | 264 | return pccard_get_configuration_info(p_dev->socket, p_dev, |
275 | config); | 265 | config); |
276 | } | 266 | } |
277 | EXPORT_SYMBOL(pcmcia_get_configuration_info); | 267 | EXPORT_SYMBOL(pcmcia_get_configuration_info); |
@@ -317,7 +307,7 @@ EXPORT_SYMBOL(pcmcia_get_window); | |||
317 | * SocketState yet: I haven't seen any point for it. | 307 | * SocketState yet: I haven't seen any point for it. |
318 | */ | 308 | */ |
319 | 309 | ||
320 | int pccard_get_status(struct pcmcia_socket *s, unsigned int function, | 310 | int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, |
321 | cs_status_t *status) | 311 | cs_status_t *status) |
322 | { | 312 | { |
323 | config_t *c; | 313 | config_t *c; |
@@ -334,7 +324,8 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function, | |||
334 | if (!(s->state & SOCKET_PRESENT)) | 324 | if (!(s->state & SOCKET_PRESENT)) |
335 | return CS_NO_CARD; | 325 | return CS_NO_CARD; |
336 | 326 | ||
337 | c = (s->config != NULL) ? &s->config[function] : NULL; | 327 | c = (p_dev) ? p_dev->function_config : NULL; |
328 | |||
338 | if ((c != NULL) && (c->state & CONFIG_LOCKED) && | 329 | if ((c != NULL) && (c->state & CONFIG_LOCKED) && |
339 | (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { | 330 | (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { |
340 | u_char reg; | 331 | u_char reg; |
@@ -370,9 +361,9 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function, | |||
370 | return CS_SUCCESS; | 361 | return CS_SUCCESS; |
371 | } /* pccard_get_status */ | 362 | } /* pccard_get_status */ |
372 | 363 | ||
373 | int pcmcia_get_status(client_handle_t handle, cs_status_t *status) | 364 | int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status) |
374 | { | 365 | { |
375 | return pccard_get_status(handle->socket, handle->func, status); | 366 | return pccard_get_status(p_dev->socket, p_dev, status); |
376 | } | 367 | } |
377 | EXPORT_SYMBOL(pcmcia_get_status); | 368 | EXPORT_SYMBOL(pcmcia_get_status); |
378 | 369 | ||