summaryrefslogtreecommitdiffstats
path: root/cpukit/libi2c
diff options
context:
space:
mode:
authorThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2008-07-10 06:03:15 +0000
committerThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2008-07-10 06:03:15 +0000
commit5e4831f1d2bde2053afbb045baaeb0aa75234073 (patch)
tree1e27f15dfcd3e4042e554b029977fbe4b7167d58 /cpukit/libi2c
parent2008-07-09 Chris Johns <chrisj@rtems.org> (diff)
downloadrtems-5e4831f1d2bde2053afbb045baaeb0aa75234073.tar.bz2
Modified error messages. Driver operations table is now constant. New
entry in the rtems_libi2c_tfr_mode_t structure: idle_char. This character will be continuously transmitted in read only functions.
Diffstat (limited to 'cpukit/libi2c')
-rw-r--r--cpukit/libi2c/libi2c.c36
-rw-r--r--cpukit/libi2c/libi2c.h11
2 files changed, 24 insertions, 23 deletions
diff --git a/cpukit/libi2c/libi2c.c b/cpukit/libi2c/libi2c.c
index 27c428064f..7cd4e99ac5 100644
--- a/cpukit/libi2c/libi2c.c
+++ b/cpukit/libi2c/libi2c.c
@@ -68,7 +68,7 @@
#include <rtems/libi2c.h>
-#define DRVNM "libi2c:"
+#define DRVNM "libi2c: "
#define MAX_NO_BUSSES 8 /* Also limited by the macro building minor numbers */
#define MAX_NO_DRIVERS 16 /* Number of high level drivers we support */
@@ -97,7 +97,7 @@
#define DISPATCH(rval, entry, dflt) \
do { \
- rtems_driver_address_table *ops = drvs[--drv].drv->ops; \
+ const rtems_driver_address_table *ops = drvs[--drv].drv->ops; \
rval = ops->entry ? ops->entry(major,minor,arg) : dflt; \
} while (0)
@@ -158,9 +158,9 @@ mutexCreate (rtems_name nm, rtems_id *pm)
if (RTEMS_SUCCESSFUL !=
(sc = rtems_semaphore_create (nm, 1, MUTEX_ATTS, 0, pm))) {
if ( _System_state_Is_up( _System_state_Get() ) )
- rtems_error (sc, DRVNM " unable to create mutex\n");
+ rtems_error (sc, DRVNM "Unable to create mutex\n");
else
- printk (DRVNM " unable to crate mutex (status code %i)\n", sc);
+ printk (DRVNM "Unable to create mutex (status code %i)\n", sc);
}
return sc;
}
@@ -185,7 +185,7 @@ struct i2cbus *bus = &busses[busno];
sc = mutexCreate (rtems_build_name ('i', '2', 'c', '0' + busno), &m);
if ( RTEMS_SUCCESSFUL != sc ) {
LIBUNLOCK ();
- rtems_panic (DRVNM " unable to create bus lock");
+ rtems_panic (DRVNM "Unable to create bus lock");
} else {
bus->mutex = m;
}
@@ -338,7 +338,7 @@ rtems_i2c_ioctl (rtems_device_major_number major, rtems_device_minor_number mino
/* Our ops just dispatch to the registered drivers */
-rtems_driver_address_table rtems_libi2c_io_ops = {
+const rtems_driver_address_table rtems_libi2c_io_ops = {
initialization_entry: rtems_i2c_init,
open_entry: rtems_i2c_open,
close_entry: rtems_i2c_close,
@@ -368,7 +368,7 @@ rtems_libi2c_initialize ()
sc = rtems_io_register_driver (0, &rtems_libi2c_io_ops, &rtems_libi2c_major);
if (RTEMS_SUCCESSFUL != sc) {
safe_printf(
- DRVNM " Claiming driver slot failed (rtems status code %i)\n",
+ DRVNM "Claiming driver slot failed (rtems status code %i)\n",
sc);
if ( libmutex )
rtems_semaphore_delete (libmutex);
@@ -381,7 +381,7 @@ rtems_libi2c_initialize ()
}
int
-rtems_libi2c_register_bus (char *name, rtems_libi2c_bus_t * bus)
+rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus)
{
int i;
rtems_status_code err;
@@ -394,12 +394,12 @@ rtems_libi2c_register_bus (char *name, rtems_libi2c_bus_t * bus)
/* check */
if ('/' != *nmcpy) {
- safe_printf ( DRVNM "Bad name; must be an absolute path starting with '/'\n");
+ safe_printf ( DRVNM "Bad name: must be an absolute path starting with '/'\n");
return -RTEMS_INVALID_NAME;
}
/* file must not exist */
if (!stat (nmcpy, &sbuf)) {
- safe_printf ( DRVNM "Bad name; file exists already\n");
+ safe_printf ( DRVNM "Bad name: file exists already\n");
return -RTEMS_INVALID_NAME;
}
@@ -418,12 +418,12 @@ rtems_libi2c_register_bus (char *name, rtems_libi2c_bus_t * bus)
if (!libmutex) {
- safe_printf ( DRVNM " library not initialized\n");
+ safe_printf ( DRVNM "Library not initialized\n");
return -RTEMS_NOT_DEFINED;
}
- if (bus->size < sizeof (*bus)) {
- safe_printf ( DRVNM " bus-ops size too small -- misconfiguration?\n");
+ if (bus == NULL || bus->size < sizeof (*bus)) {
+ safe_printf ( DRVNM "No bus-ops or size too small -- misconfiguration?\n");
return -RTEMS_NOT_CONFIGURED;
}
@@ -576,7 +576,7 @@ rtems_libi2c_ioctl (rtems_device_minor_number minor,
va_list ap;
int sc = 0;
void *args;
- boolean is_started = FALSE;
+ rtems_boolean is_started = FALSE;
DECL_CHECKED_BH (busno, bush, minor, -)
va_start(ap, cmd);
@@ -685,7 +685,7 @@ rtems_libi2c_start_write_bytes (rtems_device_minor_number minor,
}
int
-rtems_libi2c_register_drv (char *name, rtems_libi2c_drv_t * drvtbl,
+rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,
unsigned busno, unsigned i2caddr)
{
int i;
@@ -693,7 +693,7 @@ rtems_libi2c_register_drv (char *name, rtems_libi2c_drv_t * drvtbl,
rtems_device_minor_number minor;
if (!libmutex) {
- safe_printf ( DRVNM " library not initialized\n");
+ safe_printf ( DRVNM "Library not initialized\n");
return -RTEMS_NOT_DEFINED;
}
@@ -707,8 +707,8 @@ rtems_libi2c_register_drv (char *name, rtems_libi2c_drv_t * drvtbl,
return -RTEMS_INVALID_NUMBER;
}
- if (drvtbl->size < sizeof (*drvtbl)) {
- safe_printf ( DRVNM " drv-ops size too small -- misconfiguration?\n");
+ if (drvtbl == NULL || drvtbl->size < sizeof (*drvtbl)) {
+ safe_printf ( DRVNM "No driver table or size too small -- misconfiguration?\n");
return -RTEMS_NOT_CONFIGURED;
}
diff --git a/cpukit/libi2c/libi2c.h b/cpukit/libi2c/libi2c.h
index 560fd53174..20c4311d3a 100644
--- a/cpukit/libi2c/libi2c.h
+++ b/cpukit/libi2c/libi2c.h
@@ -100,7 +100,7 @@ rtems_i2c_ioctl (
rtems_device_minor_number minor,
void *arg);
-extern rtems_driver_address_table rtems_libi2c_io_ops;
+extern const rtems_driver_address_table rtems_libi2c_io_ops;
/* Unfortunately, if you want to add this driver to
* a RTEMS configuration table then you need all the
@@ -144,7 +144,7 @@ extern rtems_driver_address_table rtems_libi2c_io_ops;
*/
typedef struct rtems_libi2c_bus_t_
{
- struct rtems_libi2c_bus_ops_ *ops;
+ const struct rtems_libi2c_bus_ops_ *ops;
int size; /* size of whole structure */
} rtems_libi2c_bus_t;
@@ -196,7 +196,7 @@ typedef struct rtems_libi2c_bus_ops_
* RETURNS: bus # (>=0) or -1 on error (errno set).
*/
-int rtems_libi2c_register_bus (char *name, rtems_libi2c_bus_t * bus);
+int rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus);
extern rtems_device_major_number rtems_libi2c_major;
@@ -279,7 +279,7 @@ extern rtems_device_major_number rtems_libi2c_major;
typedef struct rtems_libi2c_drv_t_
{
- rtems_driver_address_table *ops; /* the driver ops */
+ const rtems_driver_address_table *ops; /* the driver ops */
int size; /* size of whole structure (including appended private data) */
} rtems_libi2c_drv_t;
@@ -297,7 +297,7 @@ typedef struct rtems_libi2c_drv_t_
* RETURNS minor number (FYI) or -1 on failure
*/
int
-rtems_libi2c_register_drv (char *name, rtems_libi2c_drv_t * drvtbl,
+rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,
unsigned bus, unsigned i2caddr);
/* Operations available to high level drivers */
@@ -440,6 +440,7 @@ typedef struct {
boolean lsb_first; /* TRUE: send LSB first */
boolean clock_inv; /* TRUE: inverted clock (high active) */
boolean clock_phs; /* TRUE: clock starts toggling at start of data tfr */
+ uint32_t idle_char; /* This character will be continuously transmitted in read only functions */
} rtems_libi2c_tfr_mode_t;
typedef struct {