]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pcmcia/pcmcia_resource.c
Staging: SLICOSS: remove duplicated #include's
[linux-2.6-omap-h63xx.git] / drivers / pcmcia / pcmcia_resource.c
index 8f2c805e793b3acc7b9c4901362100b32d77200d..afea2b2558b5d63d3af6fe04f230011a66fdd415 100644 (file)
@@ -29,7 +29,6 @@
 #include <pcmcia/ds.h>
 
 #include "cs_internal.h"
-#include "ds_internal.h"
 
 
 /* Access speed for IO windows */
@@ -189,7 +188,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;
@@ -251,12 +250,16 @@ 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;
+       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);
@@ -397,7 +400,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;
 
@@ -420,10 +423,14 @@ 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 (s->irq.AssignedIRQ != req->AssignedIRQ)
-               return CS_BAD_IRQ;
+       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) {
+               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;
@@ -613,11 +620,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 +794,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)
@@ -792,11 +805,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;
 
@@ -837,8 +854,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 */
@@ -918,7 +937,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev,
                if (pcmcia_get_tuple_data(p_dev, tuple))
                        goto next_entry;
 
-               if (pcmcia_parse_tuple(p_dev, tuple, &cfg_mem->parse))
+               if (pcmcia_parse_tuple(tuple, &cfg_mem->parse))
                        goto next_entry;
 
                /* default values */