[PATCH 34/39] pcmcia: deprecate CS_BAD_ARGS

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


CS_BAD_ARGS mean a badly written driver or invalid userspace ioctl access,
so translate that to -EINVAL.

Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
---
 drivers/pcmcia/ds.c              |    1 -
 drivers/pcmcia/pcmcia_ioctl.c    |    8 ++++----
 drivers/pcmcia/pcmcia_resource.c |   10 ++++++----
 include/pcmcia/cs.h              |    4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 98ba8c0..47c039b 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -78,7 +78,6 @@ static const lookup_t error_table[] = {
     { -EIO,			"Input/Output error" },
     { -ENODEV,			"No card present" },
     { -EINVAL,			"Bad parameter" },
-    { CS_BAD_ARGS,		"Bad arguments" },
     { -EACCES,			"Configuration locked" },
     { -EBUSY,			"Resource in use" },
     { -ENOSPC,			"No more items" },
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index dce6ce0..af245ec 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -835,7 +835,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
     case DS_GET_CONFIGURATION_INFO:
 	if (buf->config.Function &&
 	   (buf->config.Function >= s->functions))
-	    ret = CS_BAD_ARGS;
+	    ret = -EINVAL;
 	else {
 	    struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function);
 	    ret = pccard_get_configuration_info(s, p_dev, &buf->config);
@@ -866,7 +866,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
     case DS_GET_STATUS:
 	    if (buf->status.Function &&
 		(buf->status.Function >= s->functions))
-		    ret = CS_BAD_ARGS;
+		    ret = -EINVAL;
 	    else {
 		    struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function);
 		    ret = pccard_get_status(s, p_dev, &buf->status);
@@ -897,7 +897,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
 	    goto free_out;
 	}
 
-	ret = CS_BAD_ARGS;
+	ret = -EINVAL;
 
 	if (!(buf->conf_reg.Function &&
 	     (buf->conf_reg.Function >= s->functions))) {
@@ -969,7 +969,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
 	case -ENOSYS:
 	    err = ret;
 	    break;
-	case CS_BAD_ARGS: case CS_BAD_TUPLE:
+	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 4f96e5c..717a466 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -189,7 +189,7 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
 		pcmcia_write_cis_mem(s, 1, addr, 1, &val);
 		break;
 	default:
-		return CS_BAD_ARGS;
+		return -EINVAL;
 		break;
 	}
 	return 0;
@@ -401,7 +401,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
 	    (c->io.NumPorts1 != req->NumPorts1) ||
 	    (c->io.BasePort2 != req->BasePort2) ||
 	    (c->io.NumPorts2 != req->NumPorts2))
-		return CS_BAD_ARGS;
+		return -EINVAL;
 
 	c->state &= ~CONFIG_IO_REQ;
 
@@ -851,8 +851,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
 	if (req->Attributes & WIN_USE_WAIT)
 		win->ctl.flags |= MAP_USE_WAIT;
 	win->ctl.card_start = 0;
-	if (s->ops->set_mem_map(s, &win->ctl) != 0)
-		return CS_BAD_ARGS;
+	if (s->ops->set_mem_map(s, &win->ctl) != 0) {
+		ds_dbg(s, 0, "failed to set memory mapping\n");
+		return -EIO;
+	}
 	s->state |= SOCKET_WIN_REQ(w);
 
 	/* Return window handle */
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index 4951eb9..56f94e2 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -294,7 +294,7 @@ typedef struct error_info_t {
 #define CS_BAD_BASE		-EINVAL
 #define CS_BAD_EDC		-ENODEV
 #define CS_BAD_IRQ		-EINVAL
-#define CS_BAD_OFFSET		-EIO
+#define CS_BAD_OFFSET		-EINVAL
 #define CS_BAD_PAGE		-EINVAL
 #define CS_READ_FAILURE		-EIO
 #define CS_BAD_SIZE		-EINVAL
@@ -312,7 +312,7 @@ typedef struct error_info_t {
 #define CS_GENERAL_FAILURE	-ETIMEDOUT
 #define CS_WRITE_PROTECTED	-EPERM
 #define CS_BAD_ARG_LENGTH	-ENODEV
-#define CS_BAD_ARGS		0x1c
+#define CS_BAD_ARGS		-EINVAL
 #define CS_CONFIGURATION_LOCKED	-EACCES
 #define CS_IN_USE		-EBUSY
 #define CS_NO_MORE_ITEMS	-ENOSPC
-- 
1.5.4.3




More information about the linux-pcmcia mailing list