summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2010-06-08 08:30:04 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2010-06-08 08:30:04 +0000
commit78f4d6d72ef51e9bdd33e2ed258fb6af5701153e (patch)
tree78eb811bad5ea57d3ba3036a9acd020153f758dd
parent2010-06-07 Bharath Suri <bharath.s.jois@gmail.com> (diff)
downloadrtems-78f4d6d72ef51e9bdd33e2ed258fb6af5701153e.tar.bz2
2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libfs/src/devfs/devclose.c, libfs/src/devfs/devopen.c, libfs/src/imfs/deviceerrno.c, libfs/src/imfs/deviceio.c, libfs/src/rfs/rtems-rfs-rtems-dev.c: Changed rtems_deviceio_errno() to cope with a status code of RTEMS_SUCCESSFUL. Removed dependency on association framework.
-rw-r--r--cpukit/ChangeLog8
-rw-r--r--cpukit/libfs/src/devfs/devclose.c6
-rw-r--r--cpukit/libfs/src/devfs/devopen.c4
-rw-r--r--cpukit/libfs/src/imfs/deviceerrno.c67
-rw-r--r--cpukit/libfs/src/imfs/deviceio.c18
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c8
6 files changed, 57 insertions, 54 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 123d93ffad..54b7c57594 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * libfs/src/devfs/devclose.c, libfs/src/devfs/devopen.c,
+ libfs/src/imfs/deviceerrno.c, libfs/src/imfs/deviceio.c,
+ libfs/src/rfs/rtems-rfs-rtems-dev.c: Changed rtems_deviceio_errno() to
+ cope with a status code of RTEMS_SUCCESSFUL. Removed dependency on
+ association framework.
+
2010-06-07 Ralf Corsépius <ralf.corsepius@rtems.org>
* aclocal/version.m4: Bump RTEMS_API to 4.11.
diff --git a/cpukit/libfs/src/devfs/devclose.c b/cpukit/libfs/src/devfs/devclose.c
index 66a89b98e7..eaaf164c84 100644
--- a/cpukit/libfs/src/devfs/devclose.c
+++ b/cpukit/libfs/src/devfs/devclose.c
@@ -34,10 +34,8 @@ int devFS_close(
np->minor,
(void *) &args
);
- if ( status ) {
- return rtems_deviceio_errno(status);
- }
- return 0;
+
+ return rtems_deviceio_errno(status);
}
diff --git a/cpukit/libfs/src/devfs/devopen.c b/cpukit/libfs/src/devfs/devopen.c
index e1dcf64957..f06aa8939b 100644
--- a/cpukit/libfs/src/devfs/devopen.c
+++ b/cpukit/libfs/src/devfs/devopen.c
@@ -37,8 +37,6 @@ int devFS_open(
np->minor,
(void *) &args
);
- if ( status )
- return rtems_deviceio_errno(status);
- return 0;
+ return rtems_deviceio_errno(status);
}
diff --git a/cpukit/libfs/src/imfs/deviceerrno.c b/cpukit/libfs/src/imfs/deviceerrno.c
index 9a3251f7c5..b0daf4d8f8 100644
--- a/cpukit/libfs/src/imfs/deviceerrno.c
+++ b/cpukit/libfs/src/imfs/deviceerrno.c
@@ -18,40 +18,53 @@
#include "config.h"
#endif
-#include <rtems.h>
-#include <rtems/libio.h>
-#include <rtems/assoc.h> /* assoc.h not included by rtems.h */
#include <errno.h>
-/*
- * Convert RTEMS status to a UNIX errno
- */
+#include <rtems.h>
+#include <rtems/libio.h>
-const rtems_assoc_t errno_assoc[] = {
- { "OK", RTEMS_SUCCESSFUL, 0 },
- { "BUSY", RTEMS_RESOURCE_IN_USE, EBUSY },
- { "INVALID NAME", RTEMS_INVALID_NAME, EINVAL },
- { "NOT IMPLEMENTED", RTEMS_NOT_IMPLEMENTED, ENOSYS },
- { "TIMEOUT", RTEMS_TIMEOUT, ETIMEDOUT },
- { "NO MEMORY", RTEMS_NO_MEMORY, ENOMEM },
- { "NO DEVICE", RTEMS_UNSATISFIED, ENODEV },
- { "INVALID NUMBER", RTEMS_INVALID_NUMBER, EBADF},
- { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE, EPERM},
- { "IO ERROR", RTEMS_IO_ERROR, EIO},
- { 0, 0, 0 },
+static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = {
+ [RTEMS_SUCCESSFUL] = 0,
+ [RTEMS_TASK_EXITTED] = EIO,
+ [RTEMS_MP_NOT_CONFIGURED] = EIO,
+ [RTEMS_INVALID_NAME] = EINVAL,
+ [RTEMS_INVALID_ID] = EIO,
+ [RTEMS_TOO_MANY] = EIO,
+ [RTEMS_TIMEOUT] = ETIMEDOUT,
+ [RTEMS_OBJECT_WAS_DELETED] = EIO,
+ [RTEMS_INVALID_SIZE] = EIO,
+ [RTEMS_INVALID_ADDRESS] = EIO,
+ [RTEMS_INVALID_NUMBER] = EBADF,
+ [RTEMS_NOT_DEFINED] = EIO,
+ [RTEMS_RESOURCE_IN_USE] = EBUSY,
+ [RTEMS_UNSATISFIED] = ENODEV,
+ [RTEMS_INCORRECT_STATE] = EIO,
+ [RTEMS_ALREADY_SUSPENDED] = EIO,
+ [RTEMS_ILLEGAL_ON_SELF] = EIO,
+ [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO,
+ [RTEMS_CALLED_FROM_ISR] = EIO,
+ [RTEMS_INVALID_PRIORITY] = EIO,
+ [RTEMS_NOT_OWNER_OF_RESOURCE] = EPERM,
+ [RTEMS_NOT_IMPLEMENTED] = ENOSYS,
+ [RTEMS_INTERNAL_ERROR] = EIO,
+ [RTEMS_NO_MEMORY] = ENOMEM,
+ [RTEMS_IO_ERROR] = EIO,
+ [RTEMS_PROXY_BLOCKING] = EIO
};
-int
-rtems_deviceio_errno(rtems_status_code code)
+int rtems_deviceio_errno(rtems_status_code sc)
{
- int rc;
+ if (sc == RTEMS_SUCCESSFUL) {
+ return 0;
+ } else {
+ int eno = EINVAL;
- if ((rc = rtems_assoc_remote_by_local(errno_assoc, (uint32_t ) code)))
- {
- errno = rc;
- return -1;
+ if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) {
+ eno = status_code_to_errno [sc];
}
- return -1;
-}
+ errno = eno;
+ return -1;
+ }
+}
diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c
index 70cb936425..61d138ae59 100644
--- a/cpukit/libfs/src/imfs/deviceio.c
+++ b/cpukit/libfs/src/imfs/deviceio.c
@@ -20,17 +20,11 @@
#include <rtems.h>
#include <rtems/libio.h>
-#include <rtems/assoc.h> /* assoc.h not included by rtems.h */
-#include <errno.h>
+#include <rtems/devfs.h>
#include "imfs.h"
/*
- * Convert RTEMS status to a UNIX errno
- */
-extern int rtems_deviceio_errno(rtems_status_code code);
-
-/*
* device_open
*
* This handler maps an open() operation onto rtems_io_open().
@@ -58,10 +52,8 @@ int device_open(
the_jnode->info.device.minor,
(void *) &args
);
- if ( status )
- return rtems_deviceio_errno(status);
- return 0;
+ return rtems_deviceio_errno( status );
}
/*
@@ -89,10 +81,8 @@ int device_close(
the_jnode->info.device.minor,
(void *) &args
);
- if ( status ) {
- return rtems_deviceio_errno(status);
- }
- return 0;
+
+ return rtems_deviceio_errno( status );
}
/*
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c
index 862e442a3b..7e4ee60a7f 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c
@@ -83,10 +83,8 @@ rtems_rfs_rtems_device_open ( rtems_libio_t *iop,
args.mode = mode;
status = rtems_io_open (major, minor, (void *) &args);
- if (status)
- return rtems_deviceio_errno(status);
- return 0;
+ return rtems_deviceio_errno (status);
}
/**
@@ -112,10 +110,8 @@ rtems_rfs_rtems_device_close (rtems_libio_t* iop)
args.mode = 0;
status = rtems_io_close (major, minor, (void *) &args);
- if (status)
- return rtems_deviceio_errno (status);
- return 0;
+ return rtems_deviceio_errno (status);
}
/**