diff options
| author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-03 11:40:19 +0200 | 
|---|---|---|
| committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-23 02:29:48 +0200 | 
| commit | f958095ef4fc96e978c6eddcaca29100e5276c7f (patch) | |
| tree | 16afbb0172e7d7851350d37784bbf1fb0493c90d /drivers/pcmcia | |
| parent | 943f70f1b5182c5220641ccb7bb905005162e227 (diff) | |
| download | linux-f958095ef4fc96e978c6eddcaca29100e5276c7f.tar.bz2 | |
pcmcia: deprecate CS_IN_USE
If a resource is already in use, mark it with -EBUSY. Same for cards already
asleep.
(includes a fix for a bug found by Larry Finger -- thanks!)
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
| -rw-r--r-- | drivers/pcmcia/cs.c | 6 | ||||
| -rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 43 | 
2 files changed, 32 insertions, 17 deletions
| diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index f9424801b9c8..1c6c8c8f57c9 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -534,7 +534,7 @@ static int socket_insert(struct pcmcia_socket *skt)  static int socket_suspend(struct pcmcia_socket *skt)  {  	if (skt->state & SOCKET_SUSPEND) -		return CS_IN_USE; +		return -EBUSY;  	send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW);  	skt->socket = dead_socket; @@ -556,7 +556,7 @@ static int socket_resume(struct pcmcia_socket *skt)  	int ret;  	if (!(skt->state & SOCKET_SUSPEND)) -		return CS_IN_USE; +		return -EBUSY;  	skt->socket = dead_socket;  	skt->ops->init(skt); @@ -765,7 +765,7 @@ int pccard_reset_card(struct pcmcia_socket *skt)  			break;  		}  		if (skt->state & SOCKET_SUSPEND) { -			ret = CS_IN_USE; +			ret = -EBUSY;  			break;  		}  		if (skt->state & SOCKET_CARDBUS) { diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 0ac3ea92a1c5..670465d4aac2 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -609,23 +609,30 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)  	c = p_dev->function_config;  	if (c->state & CONFIG_LOCKED)  		return -EACCES; -	if (c->state & CONFIG_IO_REQ) -		return CS_IN_USE; +	if (c->state & CONFIG_IO_REQ) { +		ds_dbg(s, 0, "IO already configured\n"); +		return -EBUSY; +	}  	if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))  		return CS_BAD_ATTRIBUTE;  	if ((req->NumPorts2 > 0) &&  	    (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)))  		return CS_BAD_ATTRIBUTE; +	ds_dbg(s, 1, "trying to allocate resource 1\n");  	if (alloc_io_space(s, req->Attributes1, &req->BasePort1, -			   req->NumPorts1, req->IOAddrLines)) -		return CS_IN_USE; +			   req->NumPorts1, req->IOAddrLines)) { +		ds_dbg(s, 0, "allocation of resource 1 failed\n"); +		return -EBUSY; +	}  	if (req->NumPorts2) { +		ds_dbg(s, 1, "trying to allocate resource 2\n");  		if (alloc_io_space(s, req->Attributes2, &req->BasePort2,  				   req->NumPorts2, req->IOAddrLines)) { +			ds_dbg(s, 0, "allocation of resource 2 failed\n");  			release_io_space(s, req->BasePort1, req->NumPorts1); -			return CS_IN_USE; +			return -EBUSY;  		}  	} @@ -658,7 +665,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)  {  	struct pcmcia_socket *s = p_dev->socket;  	config_t *c; -	int ret = CS_IN_USE, irq = 0; +	int ret = -EINVAL, irq = 0;  	int type;  	if (!(s->state & SOCKET_PRESENT)) @@ -666,8 +673,10 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)  	c = p_dev->function_config;  	if (c->state & CONFIG_LOCKED)  		return -EACCES; -	if (c->state & CONFIG_IRQ_REQ) -		return CS_IN_USE; +	if (c->state & CONFIG_IRQ_REQ) { +		ds_dbg(s, 0, "IRQ already configured\n"); +		return -EBUSY; +	}  	/* Decide what type of interrupt we are registering */  	type = 0; @@ -730,8 +739,10 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)  	}  	if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { -		if (request_irq(irq, req->Handler, type,  p_dev->devname, req->Instance)) -			return CS_IN_USE; +		ret = request_irq(irq, req->Handler, type, +				  p_dev->devname, req->Instance); +		if (ret) +			return ret;  	}  	/* Make sure the fact the request type was overridden is passed back */ @@ -792,8 +803,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h  	/* Allocate system memory window */  	for (w = 0; w < MAX_WIN; w++)  		if (!(s->state & SOCKET_WIN_REQ(w))) break; -	if (w == MAX_WIN) -		return CS_IN_USE; +	if (w == MAX_WIN) { +		ds_dbg(s, 0, "all windows are used already\n"); +		return -EINVAL; +	}  	win = &s->win[w];  	win->magic = WINDOW_MAGIC; @@ -804,8 +817,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h  	if (!(s->features & SS_CAP_STATIC_MAP)) {  		win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align,  						      (req->Attributes & WIN_MAP_BELOW_1MB), s); -		if (!win->ctl.res) -			return CS_IN_USE; +		if (!win->ctl.res) { +			ds_dbg(s, 0, "allocating mem region failed\n"); +			return -EINVAL; +		}  	}  	(*p_dev)->_win |= CLIENT_WIN_REQ(w); |