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;
}
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)
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);
} 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" }
};
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;
}
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 (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) {
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,
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)
/* 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