aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2008-08-03 05:58:53 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2008-08-22 20:29:55 -0400
commit610e23749e87920136e1a221266a43cb7e3823f1 (patch)
tree5696af5b6e7be04e17a852e6c810798930a9b6c4 /drivers
parent635d19bea0e91df473a81391ec8f3db2d049a218 (diff)
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>
Diffstat (limited to 'drivers')
-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
4 files changed, 34 insertions, 27 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)
451 if (status & SS_CARDBUS) { 451 if (status & SS_CARDBUS) {
452 if (!(skt->features & SS_CAP_CARDBUS)) { 452 if (!(skt->features & SS_CAP_CARDBUS)) {
453 cs_err(skt, "cardbus cards are not supported.\n"); 453 cs_err(skt, "cardbus cards are not supported.\n");
454 return CS_BAD_TYPE; 454 return -EINVAL;
455 } 455 }
456 skt->state |= SOCKET_CARDBUS; 456 skt->state |= SOCKET_CARDBUS;
457 } 457 }
@@ -465,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
465 skt->socket.Vcc = skt->socket.Vpp = 50; 465 skt->socket.Vcc = skt->socket.Vpp = 50;
466 else { 466 else {
467 cs_err(skt, "unsupported voltage key.\n"); 467 cs_err(skt, "unsupported voltage key.\n");
468 return CS_BAD_TYPE; 468 return -EIO;
469 } 469 }
470 470
471 if (skt->power_hook) 471 if (skt->power_hook)
@@ -482,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
482 skt->ops->get_status(skt, &status); 482 skt->ops->get_status(skt, &status);
483 if (!(status & SS_POWERON)) { 483 if (!(status & SS_POWERON)) {
484 cs_err(skt, "unable to apply power.\n"); 484 cs_err(skt, "unable to apply power.\n");
485 return CS_BAD_TYPE; 485 return -EIO;
486 } 486 }
487 487
488 status = socket_reset(skt); 488 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 {
74} lookup_t; 74} lookup_t;
75 75
76static const lookup_t error_table[] = { 76static const lookup_t error_table[] = {
77 { CS_SUCCESS, "Operation succeeded" }, 77 { 0, "Operation succeeded" },
78 { CS_BAD_ATTRIBUTE, "Bad attribute", },
79 { CS_BAD_BASE, "Bad base address" }, 78 { CS_BAD_BASE, "Bad base address" },
80 { CS_BAD_IRQ, "Bad IRQ" }, 79 { CS_BAD_IRQ, "Bad IRQ" },
81 { CS_BAD_OFFSET, "Bad offset" }, 80 { CS_BAD_OFFSET, "Bad offset" },
82 { CS_BAD_PAGE, "Bad page number" },
83 { CS_BAD_SIZE, "Bad size" }, 81 { CS_BAD_SIZE, "Bad size" },
84 { CS_BAD_TYPE, "Bad type" },
85 { -EIO, "Input/Output error" }, 82 { -EIO, "Input/Output error" },
86 { -ENODEV, "No card present" }, 83 { -ENODEV, "No card present" },
87 { -EINVAL, "Bad parameter" }, 84 { -EINVAL, "Bad parameter" },
88 { CS_BAD_ARGS, "Bad arguments" }, 85 { CS_BAD_ARGS, "Bad arguments" },
89 { -EACCES, "Configuration locked" }, 86 { -EACCES, "Configuration locked" },
90 { CS_IN_USE, "Resource in use" }, 87 { -EBUSY, "Resource in use" },
91 { -ENOSPC, "No more items" }, 88 { -ENOSPC, "No more items" },
92 { CS_OUT_OF_RESOURCE, "Out of resource" }, 89 { -ENOMEM, "Out of resource" },
93 { CS_BAD_TUPLE, "Bad CIS tuple" } 90 { CS_BAD_TUPLE, "Bad CIS tuple" }
94}; 91};
95 92
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,
964 if ((err == 0) && (ret != 0)) { 964 if ((err == 0) && (ret != 0)) {
965 ds_dbg(2, "ds_ioctl: ret = %d\n", ret); 965 ds_dbg(2, "ds_ioctl: ret = %d\n", ret);
966 switch (ret) { 966 switch (ret) {
967 case CS_BAD_SOCKET: case CS_NO_CARD: 967 case -ENODEV:
968 err = -ENODEV; break; 968 case -EINVAL:
969 case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: 969 case -EBUSY:
970 case -ENOSYS:
971 err = ret;
972 break;
973 case CS_BAD_ARGS: case CS_BAD_IRQ:
970 case CS_BAD_TUPLE: 974 case CS_BAD_TUPLE:
971 err = -EINVAL; break; 975 err = -EINVAL; break;
972 case CS_IN_USE: 976 case -ENOMEM:
973 err = -EBUSY; break;
974 case CS_OUT_OF_RESOURCE:
975 err = -ENOSPC; break; 977 err = -ENOSPC; break;
976 case -ENOSPC: 978 case -ENOSPC:
977 err = -ENODATA; break; 979 err = -ENODATA; break;
978 case -ENOSYS:
979 err = -ENOSYS; break;
980 default: 980 default:
981 err = -EIO; break; 981 err = -EIO; break;
982 } 982 }
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)
251 struct pcmcia_socket *s; 251 struct pcmcia_socket *s;
252 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 252 if ((win == NULL) || (win->magic != WINDOW_MAGIC))
253 return -EINVAL; 253 return -EINVAL;
254 if (req->Page != 0)
255 return CS_BAD_PAGE;
256 s = win->sock; 254 s = win->sock;
255 if (req->Page != 0) {
256 ds_dbg(s, 0, "failure: requested page is zero\n");
257 return -EINVAL;
258 }
257 win->ctl.card_start = req->CardOffset; 259 win->ctl.card_start = req->CardOffset;
258 if (s->ops->set_mem_map(s, &win->ctl) != 0) 260 if (s->ops->set_mem_map(s, &win->ctl) != 0)
259 return CS_BAD_OFFSET; 261 return CS_BAD_OFFSET;
@@ -420,8 +422,10 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
420 422
421 if (c->state & CONFIG_LOCKED) 423 if (c->state & CONFIG_LOCKED)
422 return -EACCES; 424 return -EACCES;
423 if (c->irq.Attributes != req->Attributes) 425 if (c->irq.Attributes != req->Attributes) {
424 return CS_BAD_ATTRIBUTE; 426 ds_dbg(s, 0, "IRQ attributes must match assigned ones\n");
427 return -EINVAL;
428 }
425 if (s->irq.AssignedIRQ != req->AssignedIRQ) 429 if (s->irq.AssignedIRQ != req->AssignedIRQ)
426 return CS_BAD_IRQ; 430 return CS_BAD_IRQ;
427 if (--s->irq.Config == 0) { 431 if (--s->irq.Config == 0) {
@@ -613,11 +617,15 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
613 ds_dbg(s, 0, "IO already configured\n"); 617 ds_dbg(s, 0, "IO already configured\n");
614 return -EBUSY; 618 return -EBUSY;
615 } 619 }
616 if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) 620 if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) {
617 return CS_BAD_ATTRIBUTE; 621 ds_dbg(s, 0, "bad attribute setting for IO region 1\n");
622 return -EINVAL;
623 }
618 if ((req->NumPorts2 > 0) && 624 if ((req->NumPorts2 > 0) &&
619 (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) 625 (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) {
620 return CS_BAD_ATTRIBUTE; 626 ds_dbg(s, 0, "bad attribute setting for IO region 2\n");
627 return -EINVAL;
628 }
621 629
622 ds_dbg(s, 1, "trying to allocate resource 1\n"); 630 ds_dbg(s, 1, "trying to allocate resource 1\n");
623 if (alloc_io_space(s, req->Attributes1, &req->BasePort1, 631 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
783 791
784 if (!(s->state & SOCKET_PRESENT)) 792 if (!(s->state & SOCKET_PRESENT))
785 return -ENODEV; 793 return -ENODEV;
786 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 794 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) {
787 return CS_BAD_ATTRIBUTE; 795 ds_dbg(s, 0, "bad attribute setting for iomem region\n");
796 return -EINVAL;
797 }
788 798
789 /* Window size defaults to smallest available */ 799 /* Window size defaults to smallest available */
790 if (req->Size == 0) 800 if (req->Size == 0)