diff options
Diffstat (limited to 'drivers/pcmcia/pcmcia_resource.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 54aa1c238cb3..9ba4dade69a4 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -163,7 +163,7 @@ static int pcmcia_access_config(struct pcmcia_device *p_dev, | |||
163 | c = p_dev->function_config; | 163 | c = p_dev->function_config; |
164 | 164 | ||
165 | if (!(c->state & CONFIG_LOCKED)) { | 165 | if (!(c->state & CONFIG_LOCKED)) { |
166 | dev_dbg(&s->dev, "Configuration isnt't locked\n"); | 166 | dev_dbg(&p_dev->dev, "Configuration isnt't locked\n"); |
167 | mutex_unlock(&s->ops_mutex); | 167 | mutex_unlock(&s->ops_mutex); |
168 | return -EACCES; | 168 | return -EACCES; |
169 | } | 169 | } |
@@ -220,7 +220,7 @@ int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, | |||
220 | s->win[w].card_start = offset; | 220 | s->win[w].card_start = offset; |
221 | ret = s->ops->set_mem_map(s, &s->win[w]); | 221 | ret = s->ops->set_mem_map(s, &s->win[w]); |
222 | if (ret) | 222 | if (ret) |
223 | dev_warn(&s->dev, "failed to set_mem_map\n"); | 223 | dev_warn(&p_dev->dev, "failed to set_mem_map\n"); |
224 | mutex_unlock(&s->ops_mutex); | 224 | mutex_unlock(&s->ops_mutex); |
225 | return ret; | 225 | return ret; |
226 | } /* pcmcia_map_mem_page */ | 226 | } /* pcmcia_map_mem_page */ |
@@ -244,18 +244,18 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
244 | c = p_dev->function_config; | 244 | c = p_dev->function_config; |
245 | 245 | ||
246 | if (!(s->state & SOCKET_PRESENT)) { | 246 | if (!(s->state & SOCKET_PRESENT)) { |
247 | dev_dbg(&s->dev, "No card present\n"); | 247 | dev_dbg(&p_dev->dev, "No card present\n"); |
248 | ret = -ENODEV; | 248 | ret = -ENODEV; |
249 | goto unlock; | 249 | goto unlock; |
250 | } | 250 | } |
251 | if (!(c->state & CONFIG_LOCKED)) { | 251 | if (!(c->state & CONFIG_LOCKED)) { |
252 | dev_dbg(&s->dev, "Configuration isnt't locked\n"); | 252 | dev_dbg(&p_dev->dev, "Configuration isnt't locked\n"); |
253 | ret = -EACCES; | 253 | ret = -EACCES; |
254 | goto unlock; | 254 | goto unlock; |
255 | } | 255 | } |
256 | 256 | ||
257 | if (mod->Attributes & (CONF_IRQ_CHANGE_VALID | CONF_VCC_CHANGE_VALID)) { | 257 | if (mod->Attributes & (CONF_IRQ_CHANGE_VALID | CONF_VCC_CHANGE_VALID)) { |
258 | dev_dbg(&s->dev, | 258 | dev_dbg(&p_dev->dev, |
259 | "changing Vcc or IRQ is not allowed at this time\n"); | 259 | "changing Vcc or IRQ is not allowed at this time\n"); |
260 | ret = -EINVAL; | 260 | ret = -EINVAL; |
261 | goto unlock; | 261 | goto unlock; |
@@ -265,20 +265,22 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
265 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && | 265 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && |
266 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { | 266 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
267 | if (mod->Vpp1 != mod->Vpp2) { | 267 | if (mod->Vpp1 != mod->Vpp2) { |
268 | dev_dbg(&s->dev, "Vpp1 and Vpp2 must be the same\n"); | 268 | dev_dbg(&p_dev->dev, |
269 | "Vpp1 and Vpp2 must be the same\n"); | ||
269 | ret = -EINVAL; | 270 | ret = -EINVAL; |
270 | goto unlock; | 271 | goto unlock; |
271 | } | 272 | } |
272 | s->socket.Vpp = mod->Vpp1; | 273 | s->socket.Vpp = mod->Vpp1; |
273 | if (s->ops->set_socket(s, &s->socket)) { | 274 | if (s->ops->set_socket(s, &s->socket)) { |
274 | dev_printk(KERN_WARNING, &s->dev, | 275 | dev_printk(KERN_WARNING, &p_dev->dev, |
275 | "Unable to set VPP\n"); | 276 | "Unable to set VPP\n"); |
276 | ret = -EIO; | 277 | ret = -EIO; |
277 | goto unlock; | 278 | goto unlock; |
278 | } | 279 | } |
279 | } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || | 280 | } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || |
280 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { | 281 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
281 | dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); | 282 | dev_dbg(&p_dev->dev, |
283 | "changing Vcc is not allowed at this time\n"); | ||
282 | ret = -EINVAL; | 284 | ret = -EINVAL; |
283 | goto unlock; | 285 | goto unlock; |
284 | } | 286 | } |
@@ -401,7 +403,7 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res) | |||
401 | win = &s->win[w]; | 403 | win = &s->win[w]; |
402 | 404 | ||
403 | if (!(p_dev->_win & CLIENT_WIN_REQ(w))) { | 405 | if (!(p_dev->_win & CLIENT_WIN_REQ(w))) { |
404 | dev_dbg(&s->dev, "not releasing unknown window\n"); | 406 | dev_dbg(&p_dev->dev, "not releasing unknown window\n"); |
405 | mutex_unlock(&s->ops_mutex); | 407 | mutex_unlock(&s->ops_mutex); |
406 | return -EINVAL; | 408 | return -EINVAL; |
407 | } | 409 | } |
@@ -439,7 +441,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
439 | return -ENODEV; | 441 | return -ENODEV; |
440 | 442 | ||
441 | if (req->IntType & INT_CARDBUS) { | 443 | if (req->IntType & INT_CARDBUS) { |
442 | dev_dbg(&s->dev, "IntType may not be INT_CARDBUS\n"); | 444 | dev_dbg(&p_dev->dev, "IntType may not be INT_CARDBUS\n"); |
443 | return -EINVAL; | 445 | return -EINVAL; |
444 | } | 446 | } |
445 | 447 | ||
@@ -447,7 +449,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
447 | c = p_dev->function_config; | 449 | c = p_dev->function_config; |
448 | if (c->state & CONFIG_LOCKED) { | 450 | if (c->state & CONFIG_LOCKED) { |
449 | mutex_unlock(&s->ops_mutex); | 451 | mutex_unlock(&s->ops_mutex); |
450 | dev_dbg(&s->dev, "Configuration is locked\n"); | 452 | dev_dbg(&p_dev->dev, "Configuration is locked\n"); |
451 | return -EACCES; | 453 | return -EACCES; |
452 | } | 454 | } |
453 | 455 | ||
@@ -455,7 +457,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
455 | s->socket.Vpp = req->Vpp; | 457 | s->socket.Vpp = req->Vpp; |
456 | if (s->ops->set_socket(s, &s->socket)) { | 458 | if (s->ops->set_socket(s, &s->socket)) { |
457 | mutex_unlock(&s->ops_mutex); | 459 | mutex_unlock(&s->ops_mutex); |
458 | dev_printk(KERN_WARNING, &s->dev, | 460 | dev_printk(KERN_WARNING, &p_dev->dev, |
459 | "Unable to set socket state\n"); | 461 | "Unable to set socket state\n"); |
460 | return -EINVAL; | 462 | return -EINVAL; |
461 | } | 463 | } |
@@ -569,19 +571,20 @@ int pcmcia_request_io(struct pcmcia_device *p_dev) | |||
569 | int ret = -EINVAL; | 571 | int ret = -EINVAL; |
570 | 572 | ||
571 | mutex_lock(&s->ops_mutex); | 573 | mutex_lock(&s->ops_mutex); |
572 | dev_dbg(&s->dev, "pcmcia_request_io: %pR , %pR", &c->io[0], &c->io[1]); | 574 | dev_dbg(&p_dev->dev, "pcmcia_request_io: %pR , %pR", |
575 | &c->io[0], &c->io[1]); | ||
573 | 576 | ||
574 | if (!(s->state & SOCKET_PRESENT)) { | 577 | if (!(s->state & SOCKET_PRESENT)) { |
575 | dev_dbg(&s->dev, "pcmcia_request_io: No card present\n"); | 578 | dev_dbg(&p_dev->dev, "pcmcia_request_io: No card present\n"); |
576 | goto out; | 579 | goto out; |
577 | } | 580 | } |
578 | 581 | ||
579 | if (c->state & CONFIG_LOCKED) { | 582 | if (c->state & CONFIG_LOCKED) { |
580 | dev_dbg(&s->dev, "Configuration is locked\n"); | 583 | dev_dbg(&p_dev->dev, "Configuration is locked\n"); |
581 | goto out; | 584 | goto out; |
582 | } | 585 | } |
583 | if (c->state & CONFIG_IO_REQ) { | 586 | if (c->state & CONFIG_IO_REQ) { |
584 | dev_dbg(&s->dev, "IO already configured\n"); | 587 | dev_dbg(&p_dev->dev, "IO already configured\n"); |
585 | goto out; | 588 | goto out; |
586 | } | 589 | } |
587 | 590 | ||
@@ -592,7 +595,13 @@ int pcmcia_request_io(struct pcmcia_device *p_dev) | |||
592 | if (c->io[1].end) { | 595 | if (c->io[1].end) { |
593 | ret = alloc_io_space(s, &c->io[1], p_dev->io_lines); | 596 | ret = alloc_io_space(s, &c->io[1], p_dev->io_lines); |
594 | if (ret) { | 597 | if (ret) { |
598 | struct resource tmp = c->io[0]; | ||
599 | /* release the previously allocated resource */ | ||
595 | release_io_space(s, &c->io[0]); | 600 | release_io_space(s, &c->io[0]); |
601 | /* but preserve the settings, for they worked... */ | ||
602 | c->io[0].end = resource_size(&tmp); | ||
603 | c->io[0].start = tmp.start; | ||
604 | c->io[0].flags = tmp.flags; | ||
596 | goto out; | 605 | goto out; |
597 | } | 606 | } |
598 | } else | 607 | } else |
@@ -601,7 +610,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev) | |||
601 | c->state |= CONFIG_IO_REQ; | 610 | c->state |= CONFIG_IO_REQ; |
602 | p_dev->_io = 1; | 611 | p_dev->_io = 1; |
603 | 612 | ||
604 | dev_dbg(&s->dev, "pcmcia_request_io succeeded: %pR , %pR", | 613 | dev_dbg(&p_dev->dev, "pcmcia_request_io succeeded: %pR , %pR", |
605 | &c->io[0], &c->io[1]); | 614 | &c->io[0], &c->io[1]); |
606 | out: | 615 | out: |
607 | mutex_unlock(&s->ops_mutex); | 616 | mutex_unlock(&s->ops_mutex); |
@@ -800,7 +809,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
800 | int w; | 809 | int w; |
801 | 810 | ||
802 | if (!(s->state & SOCKET_PRESENT)) { | 811 | if (!(s->state & SOCKET_PRESENT)) { |
803 | dev_dbg(&s->dev, "No card present\n"); | 812 | dev_dbg(&p_dev->dev, "No card present\n"); |
804 | return -ENODEV; | 813 | return -ENODEV; |
805 | } | 814 | } |
806 | 815 | ||
@@ -809,12 +818,12 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
809 | req->Size = s->map_size; | 818 | req->Size = s->map_size; |
810 | align = (s->features & SS_CAP_MEM_ALIGN) ? req->Size : s->map_size; | 819 | align = (s->features & SS_CAP_MEM_ALIGN) ? req->Size : s->map_size; |
811 | if (req->Size & (s->map_size-1)) { | 820 | if (req->Size & (s->map_size-1)) { |
812 | dev_dbg(&s->dev, "invalid map size\n"); | 821 | dev_dbg(&p_dev->dev, "invalid map size\n"); |
813 | return -EINVAL; | 822 | return -EINVAL; |
814 | } | 823 | } |
815 | if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || | 824 | if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || |
816 | (req->Base & (align-1))) { | 825 | (req->Base & (align-1))) { |
817 | dev_dbg(&s->dev, "invalid base address\n"); | 826 | dev_dbg(&p_dev->dev, "invalid base address\n"); |
818 | return -EINVAL; | 827 | return -EINVAL; |
819 | } | 828 | } |
820 | if (req->Base) | 829 | if (req->Base) |
@@ -826,7 +835,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
826 | if (!(s->state & SOCKET_WIN_REQ(w))) | 835 | if (!(s->state & SOCKET_WIN_REQ(w))) |
827 | break; | 836 | break; |
828 | if (w == MAX_WIN) { | 837 | if (w == MAX_WIN) { |
829 | dev_dbg(&s->dev, "all windows are used already\n"); | 838 | dev_dbg(&p_dev->dev, "all windows are used already\n"); |
830 | mutex_unlock(&s->ops_mutex); | 839 | mutex_unlock(&s->ops_mutex); |
831 | return -EINVAL; | 840 | return -EINVAL; |
832 | } | 841 | } |
@@ -837,7 +846,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
837 | win->res = pcmcia_find_mem_region(req->Base, req->Size, align, | 846 | win->res = pcmcia_find_mem_region(req->Base, req->Size, align, |
838 | 0, s); | 847 | 0, s); |
839 | if (!win->res) { | 848 | if (!win->res) { |
840 | dev_dbg(&s->dev, "allocating mem region failed\n"); | 849 | dev_dbg(&p_dev->dev, "allocating mem region failed\n"); |
841 | mutex_unlock(&s->ops_mutex); | 850 | mutex_unlock(&s->ops_mutex); |
842 | return -EINVAL; | 851 | return -EINVAL; |
843 | } | 852 | } |
@@ -851,7 +860,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
851 | win->card_start = 0; | 860 | win->card_start = 0; |
852 | 861 | ||
853 | if (s->ops->set_mem_map(s, win) != 0) { | 862 | if (s->ops->set_mem_map(s, win) != 0) { |
854 | dev_dbg(&s->dev, "failed to set memory mapping\n"); | 863 | dev_dbg(&p_dev->dev, "failed to set memory mapping\n"); |
855 | mutex_unlock(&s->ops_mutex); | 864 | mutex_unlock(&s->ops_mutex); |
856 | return -EIO; | 865 | return -EIO; |
857 | } | 866 | } |
@@ -874,7 +883,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha | |||
874 | if (win->res) | 883 | if (win->res) |
875 | request_resource(&iomem_resource, res); | 884 | request_resource(&iomem_resource, res); |
876 | 885 | ||
877 | dev_dbg(&s->dev, "request_window results in %pR\n", res); | 886 | dev_dbg(&p_dev->dev, "request_window results in %pR\n", res); |
878 | 887 | ||
879 | mutex_unlock(&s->ops_mutex); | 888 | mutex_unlock(&s->ops_mutex); |
880 | *wh = res; | 889 | *wh = res; |