[PATCH 32/39] pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE

Dominik Brodowski linux at dominikbrodowski.net
Mon Aug 18 14:53:23 EDT 2008


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.

Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
---
 drivers/pcmcia/cs.c              |    6 +++---
 drivers/pcmcia/ds.c              |    9 +++------
 drivers/pcmcia/pcmcia_ioctl.c    |   16 ++++++++--------
 drivers/pcmcia/pcmcia_resource.c |   30 ++++++++++++++++++++----------
 include/pcmcia/cs.h              |    6 +++---
 5 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 940c9aa..fcc6145 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 edbd85b..89bab19 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 5367634..5f74e96 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -963,19 +963,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 0c99536..6ae2d6a 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -251,8 +251,10 @@ 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;
+	if (req->Page != 0) {
+		ds_dbg(s, 0, "failure: requested page is zero\n");
+		return -EINVAL;
+	}
 	s = win->sock;
 	win->ctl.card_start = req->CardOffset;
 	if (s->ops->set_mem_map(s, &win->ctl) != 0)
@@ -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,
@@ -779,8 +787,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 20440de..70c32e9 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
-- 
1.5.4.3




More information about the linux-pcmcia mailing list