summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2008-08-03 11:58:53 +0200
committerDominik Brodowski <linux@dominikbrodowski.net>2008-08-23 02:29:55 +0200
commit610e23749e87920136e1a221266a43cb7e3823f1 (patch)
tree5696af5b6e7be04e17a852e6c810798930a9b6c4
parent635d19bea0e91df473a81391ec8f3db2d049a218 (diff)
downloadlinux-stable-610e23749e87920136e1a221266a43cb7e3823f1.tar.gz
linux-stable-610e23749e87920136e1a221266a43cb7e3823f1.tar.bz2
linux-stable-610e23749e87920136e1a221266a43cb7e3823f1.zip
pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE
CS_BAD_TYPE was only used in cs.c and already properly annotated by error messages. CS_BAD_ATTRIBUTE and CS_BAD_PAGE mean a badly written driver, so ds_dbg() output and -EINVAL seems to be enough. (includes bugfix from and Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> ) Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r--drivers/pcmcia/cs.c6
-rw-r--r--drivers/pcmcia/ds.c9
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c16
-rw-r--r--drivers/pcmcia/pcmcia_resource.c30
-rw-r--r--include/pcmcia/cs.h6
5 files changed, 37 insertions, 30 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 1c6c8c8f57c9..48386f31e610 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -451,7 +451,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
if (status & SS_CARDBUS) {
if (!(skt->features & SS_CAP_CARDBUS)) {
cs_err(skt, "cardbus cards are not supported.\n");
- return CS_BAD_TYPE;
+ return -EINVAL;
}
skt->state |= SOCKET_CARDBUS;
}
@@ -465,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
skt->socket.Vcc = skt->socket.Vpp = 50;
else {
cs_err(skt, "unsupported voltage key.\n");
- return CS_BAD_TYPE;
+ return -EIO;
}
if (skt->power_hook)
@@ -482,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
skt->ops->get_status(skt, &status);
if (!(status & SS_POWERON)) {
cs_err(skt, "unable to apply power.\n");
- return CS_BAD_TYPE;
+ return -EIO;
}
status = socket_reset(skt);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 591d9627bb2a..4092a5976e62 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -74,22 +74,19 @@ typedef struct lookup_t {
} lookup_t;
static const lookup_t error_table[] = {
- { CS_SUCCESS, "Operation succeeded" },
- { CS_BAD_ATTRIBUTE, "Bad attribute", },
+ { 0, "Operation succeeded" },
{ CS_BAD_BASE, "Bad base address" },
{ CS_BAD_IRQ, "Bad IRQ" },
{ CS_BAD_OFFSET, "Bad offset" },
- { CS_BAD_PAGE, "Bad page number" },
{ CS_BAD_SIZE, "Bad size" },
- { CS_BAD_TYPE, "Bad type" },
{ -EIO, "Input/Output error" },
{ -ENODEV, "No card present" },
{ -EINVAL, "Bad parameter" },
{ CS_BAD_ARGS, "Bad arguments" },
{ -EACCES, "Configuration locked" },
- { CS_IN_USE, "Resource in use" },
+ { -EBUSY, "Resource in use" },
{ -ENOSPC, "No more items" },
- { CS_OUT_OF_RESOURCE, "Out of resource" },
+ { -ENOMEM, "Out of resource" },
{ CS_BAD_TUPLE, "Bad CIS tuple" }
};
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index a6289e5a75e1..e27c71ebfda2 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -964,19 +964,19 @@ static int ds_ioctl(struct inode * inode, struct file * file,
if ((err == 0) && (ret != 0)) {
ds_dbg(2, "ds_ioctl: ret = %d\n", ret);
switch (ret) {
- case CS_BAD_SOCKET: case CS_NO_CARD:
- err = -ENODEV; break;
- case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ:
+ case -ENODEV:
+ case -EINVAL:
+ case -EBUSY:
+ case -ENOSYS:
+ err = ret;
+ break;
+ case CS_BAD_ARGS: case CS_BAD_IRQ:
case CS_BAD_TUPLE:
err = -EINVAL; break;
- case CS_IN_USE:
- err = -EBUSY; break;
- case CS_OUT_OF_RESOURCE:
+ case -ENOMEM:
err = -ENOSPC; break;
case -ENOSPC:
err = -ENODATA; break;
- case -ENOSYS:
- err = -ENOSYS; break;
default:
err = -EIO; break;
}
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 8f2c805e793b..35a61577ae4e 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -251,9 +251,11 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req)
struct pcmcia_socket *s;
if ((win == NULL) || (win->magic != WINDOW_MAGIC))
return -EINVAL;
- if (req->Page != 0)
- return CS_BAD_PAGE;
s = win->sock;
+ if (req->Page != 0) {
+ ds_dbg(s, 0, "failure: requested page is zero\n");
+ return -EINVAL;
+ }
win->ctl.card_start = req->CardOffset;
if (s->ops->set_mem_map(s, &win->ctl) != 0)
return CS_BAD_OFFSET;
@@ -420,8 +422,10 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
if (c->state & CONFIG_LOCKED)
return -EACCES;
- if (c->irq.Attributes != req->Attributes)
- return CS_BAD_ATTRIBUTE;
+ if (c->irq.Attributes != req->Attributes) {
+ ds_dbg(s, 0, "IRQ attributes must match assigned ones\n");
+ return -EINVAL;
+ }
if (s->irq.AssignedIRQ != req->AssignedIRQ)
return CS_BAD_IRQ;
if (--s->irq.Config == 0) {
@@ -613,11 +617,15 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *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->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) {
+ ds_dbg(s, 0, "bad attribute setting for IO region 1\n");
+ return -EINVAL;
+ }
if ((req->NumPorts2 > 0) &&
- (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)))
- return CS_BAD_ATTRIBUTE;
+ (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) {
+ ds_dbg(s, 0, "bad attribute setting for IO region 2\n");
+ return -EINVAL;
+ }
ds_dbg(s, 1, "trying to allocate resource 1\n");
if (alloc_io_space(s, req->Attributes1, &req->BasePort1,
@@ -783,8 +791,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
- if (req->Attributes & (WIN_PAGED | WIN_SHARED))
- return CS_BAD_ATTRIBUTE;
+ if (req->Attributes & (WIN_PAGED | WIN_SHARED)) {
+ ds_dbg(s, 0, "bad attribute setting for iomem region\n");
+ return -EINVAL;
+ }
/* Window size defaults to smallest available */
if (req->Size == 0)
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index 20440defd1d0..70c32e97b492 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -290,16 +290,16 @@ typedef struct error_info_t {
/* Return codes */
#define CS_SUCCESS 0x00
#define CS_BAD_ADAPTER -ENODEV
-#define CS_BAD_ATTRIBUTE 0x02
+#define CS_BAD_ATTRIBUTE -EINVAL
#define CS_BAD_BASE 0x03
#define CS_BAD_EDC -ENODEV
#define CS_BAD_IRQ 0x06
#define CS_BAD_OFFSET 0x07
-#define CS_BAD_PAGE 0x08
+#define CS_BAD_PAGE -EINVAL
#define CS_READ_FAILURE -EIO
#define CS_BAD_SIZE 0x0a
#define CS_BAD_SOCKET -EINVAL
-#define CS_BAD_TYPE 0x0d
+#define CS_BAD_TYPE -EINVAL
#define CS_BAD_VCC -EINVAL
#define CS_BAD_VPP -EINVAL
#define CS_BAD_WINDOW -ENODEV