[PATCH 33/39] pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE

Larry Finger Larry.Finger at lwfinger.net
Tue Aug 19 23:59:30 EDT 2008


Dominik Brodowski wrote:
> These four error values mostly mean a badly written driver, so ds_dbg()
> output and -EINVAL seems to be enough.
> 
> Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
> ---
>  drivers/pcmcia/ds.c              |    4 ----
>  drivers/pcmcia/pcmcia_ioctl.c    |    5 ++---
>  drivers/pcmcia/pcmcia_resource.c |   24 ++++++++++++++++--------
>  include/pcmcia/cs.h              |    8 ++++----
>  4 files changed, 22 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
> index 89bab19..98ba8c0 100644
> --- a/drivers/pcmcia/ds.c
> +++ b/drivers/pcmcia/ds.c
> @@ -75,10 +75,6 @@ typedef struct lookup_t {
>  
>  static const lookup_t error_table[] = {
>      { 0,			"Operation succeeded" },
> -    { CS_BAD_BASE,		"Bad base address" },
> -    { CS_BAD_IRQ,		"Bad IRQ" },
> -    { CS_BAD_OFFSET,		"Bad offset" },
> -    { CS_BAD_SIZE,		"Bad size" },
>      { -EIO,			"Input/Output error" },
>      { -ENODEV,			"No card present" },
>      { -EINVAL,			"Bad parameter" },
> diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
> index 5f74e96..dce6ce0 100644
> --- a/drivers/pcmcia/pcmcia_ioctl.c
> +++ b/drivers/pcmcia/pcmcia_ioctl.c
> @@ -149,7 +149,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
>  
>  	irq = adj->resource.irq.IRQ;
>  	if ((irq < 0) || (irq > 15))
> -		return CS_BAD_IRQ;
> +		return -EINVAL;
>  
>  	if (adj->Action != REMOVE_MANAGED_RESOURCE)
>  		return 0;
> @@ -969,8 +969,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
>  	case -ENOSYS:
>  	    err = ret;
>  	    break;
> -	case CS_BAD_ARGS: case CS_BAD_IRQ:
> -	case CS_BAD_TUPLE:
> +	case CS_BAD_ARGS: 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 6ae2d6a..4f96e5c 100644
> --- a/drivers/pcmcia/pcmcia_resource.c
> +++ b/drivers/pcmcia/pcmcia_resource.c
> @@ -257,8 +257,10 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req)
>  	}
>  	s = win->sock;
>  	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);

This routine generates a warning thar "s" is used uninitialized. 
Routine pcmcia_map_mem_page should be

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;
         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) {
                 ds_dbg(s, 0, "failed to set_mem_map\n");
                 return -EIO;
         }
         return 0;
} /* pcmcia_map_mem_page */
EXPORT_SYMBOL(pcmcia_map_mem_page);

The fix is to put the line "s = win->sock" ahead of the "if (req->Page 
!= 0)" statement.

Larry



More information about the linux-pcmcia mailing list