Skip to content

Commit

Permalink
rocker: fix non-portable err return codes
Browse files Browse the repository at this point in the history
The rocker device returns error codes if something goes wrong with descriptor
processing.  Originally the device used standard errno codes for different
errors, but since those errno codes aren't portable across ARCHs, the device
now returns hard-coded error codes that stay constant across diff ARCHs.  Fix
driver to use those same hard-coded values.

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Scott Feldman authored and David S. Miller committed Feb 26, 2015
1 parent 009f33e commit 7eb344f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
25 changes: 24 additions & 1 deletion drivers/net/ethernet/rocker/rocker.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,30 @@ static u32 __pos_inc(u32 pos, size_t limit)

static int rocker_desc_err(struct rocker_desc_info *desc_info)
{
return -(desc_info->desc->comp_err & ~ROCKER_DMA_DESC_COMP_ERR_GEN);
int err = desc_info->desc->comp_err & ~ROCKER_DMA_DESC_COMP_ERR_GEN;

switch (err) {
case ROCKER_OK:
return 0;
case -ROCKER_ENOENT:
return -ENOENT;
case -ROCKER_ENXIO:
return -ENXIO;
case -ROCKER_ENOMEM:
return -ENOMEM;
case -ROCKER_EEXIST:
return -EEXIST;
case -ROCKER_EINVAL:
return -EINVAL;
case -ROCKER_EMSGSIZE:
return -EMSGSIZE;
case -ROCKER_ENOTSUP:
return -EOPNOTSUPP;
case -ROCKER_ENOBUFS:
return -ENOBUFS;
}

return -EINVAL;
}

static void rocker_desc_gen_clear(struct rocker_desc_info *desc_info)
Expand Down
13 changes: 13 additions & 0 deletions drivers/net/ethernet/rocker/rocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

#include <linux/types.h>

/* Return codes */
enum {
ROCKER_OK = 0,
ROCKER_ENOENT = 2,
ROCKER_ENXIO = 6,
ROCKER_ENOMEM = 12,
ROCKER_EEXIST = 17,
ROCKER_EINVAL = 22,
ROCKER_EMSGSIZE = 90,
ROCKER_ENOTSUP = 95,
ROCKER_ENOBUFS = 105,
};

#define PCI_VENDOR_ID_REDHAT 0x1b36
#define PCI_DEVICE_ID_REDHAT_ROCKER 0x0006

Expand Down

0 comments on commit 7eb344f

Please sign in to comment.