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>
This commit is contained in:
Dominik Brodowski 2008-08-03 11:58:53 +02:00
parent 635d19bea0
commit 610e23749e
5 changed files with 37 additions and 30 deletions

View file

@ -451,7 +451,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
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;
}
@ -465,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
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)
@ -482,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
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);

View file

@ -74,22 +74,19 @@ typedef struct lookup_t {
} 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" }
};

View file

@ -964,19 +964,19 @@ static int ds_ioctl(struct inode * inode, struct file * file,
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;
}

View file

@ -251,9 +251,11 @@ 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;
@ -420,8 +422,10 @@ 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 (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) {
@ -613,11 +617,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 +791,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)

View file

@ -290,16 +290,16 @@ typedef struct error_info_t {
/* 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