[PATCH 33/39] pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE

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


These four error values mostly 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/ds.c              |    4 ----
 drivers/pcmcia/pcmcia_ioctl.c    |    5 ++---
 drivers/pcmcia/pcmcia_resource.c |   24 ++++++++++++++++--------
 include/pcmcia/cs.h              |    8 ++++----
 4 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 89bab19..98ba8c0 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -75,10 +75,6 @@ typedef struct lookup_t {
 
 static const lookup_t error_table[] = {
     { 0,			"Operation succeeded" },
-    { CS_BAD_BASE,		"Bad base address" },
-    { CS_BAD_IRQ,		"Bad IRQ" },
-    { CS_BAD_OFFSET,		"Bad offset" },
-    { CS_BAD_SIZE,		"Bad size" },
     { -EIO,			"Input/Output error" },
     { -ENODEV,			"No card present" },
     { -EINVAL,			"Bad parameter" },
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 5f74e96..dce6ce0 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -149,7 +149,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
 
 	irq = adj->resource.irq.IRQ;
 	if ((irq < 0) || (irq > 15))
-		return CS_BAD_IRQ;
+		return -EINVAL;
 
 	if (adj->Action != REMOVE_MANAGED_RESOURCE)
 		return 0;
@@ -969,8 +969,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
 	case -ENOSYS:
 	    err = ret;
 	    break;
-	case CS_BAD_ARGS: case CS_BAD_IRQ:
-	case CS_BAD_TUPLE:
+	case CS_BAD_ARGS: case CS_BAD_TUPLE:
 	    err = -EINVAL; break;
 	case -ENOMEM:
 	    err = -ENOSPC; break;
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 6ae2d6a..4f96e5c 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -257,8 +257,10 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req)
 	}
 	s = win->sock;
 	win->ctl.card_start = req->CardOffset;
-	if (s->ops->set_mem_map(s, &win->ctl) != 0)
-		return CS_BAD_OFFSET;
+	if (s->ops->set_mem_map(s, &win->ctl) != 0) {
+		ds_dbg(s, 0, "failed to set_mem_map\n");
+		return -EIO;
+	}
 	return 0;
 } /* pcmcia_map_mem_page */
 EXPORT_SYMBOL(pcmcia_map_mem_page);
@@ -426,8 +428,10 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
 		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.AssignedIRQ != req->AssignedIRQ) {
+		ds_dbg(s, 0, "IRQ must match assigned one\n");
+		return -EINVAL;
+	}
 	if (--s->irq.Config == 0) {
 		c->state &= ~CONFIG_IRQ_REQ;
 		s->irq.AssignedIRQ = 0;
@@ -798,11 +802,15 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
 	align = (((s->features & SS_CAP_MEM_ALIGN) ||
 		  (req->Attributes & WIN_STRICT_ALIGN)) ?
 		 req->Size : s->map_size);
-	if (req->Size & (s->map_size-1))
-		return CS_BAD_SIZE;
+	if (req->Size & (s->map_size-1)) {
+		ds_dbg(s, 0, "invalid map size\n");
+		return -EINVAL;
+	}
 	if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) ||
-	    (req->Base & (align-1)))
-		return CS_BAD_BASE;
+	    (req->Base & (align-1))) {
+		ds_dbg(s, 0, "invalid base address\n");
+		return -EINVAL;
+	}
 	if (req->Base)
 		align = 0;
 
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index 70c32e9..4951eb9 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -291,13 +291,13 @@ typedef struct error_info_t {
 #define CS_SUCCESS		0x00
 #define CS_BAD_ADAPTER		-ENODEV
 #define CS_BAD_ATTRIBUTE	-EINVAL
-#define CS_BAD_BASE		0x03
+#define CS_BAD_BASE		-EINVAL
 #define CS_BAD_EDC		-ENODEV
-#define CS_BAD_IRQ		0x06
-#define CS_BAD_OFFSET		0x07
+#define CS_BAD_IRQ		-EINVAL
+#define CS_BAD_OFFSET		-EIO
 #define CS_BAD_PAGE		-EINVAL
 #define CS_READ_FAILURE		-EIO
-#define CS_BAD_SIZE		0x0a
+#define CS_BAD_SIZE		-EINVAL
 #define CS_BAD_SOCKET		-EINVAL
 #define CS_BAD_TYPE		-EINVAL
 #define CS_BAD_VCC		-EINVAL
-- 
1.5.4.3




More information about the linux-pcmcia mailing list