Changeset 5e4831f in rtems for cpukit/libi2c


Ignore:
Timestamp:
Jul 10, 2008, 6:03:15 AM (11 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 4.9, master
Children:
7c007cf
Parents:
5396467
Message:

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.

Location:
cpukit/libi2c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libi2c/libi2c.c

    r5396467 r5e4831f  
    6969#include <rtems/libi2c.h>
    7070
    71 #define DRVNM "libi2c:"
     71#define DRVNM "libi2c: "
    7272
    7373#define MAX_NO_BUSSES   8       /* Also limited by the macro building minor numbers */
     
    9898#define DISPATCH(rval, entry, dflt)     \
    9999        do {                            \
    100                 rtems_driver_address_table *ops = drvs[--drv].drv->ops; \
     100                const rtems_driver_address_table *ops = drvs[--drv].drv->ops;   \
    101101                rval = ops->entry ? ops->entry(major,minor,arg) : dflt; \
    102102        } while (0)
     
    159159      (sc = rtems_semaphore_create (nm, 1, MUTEX_ATTS, 0, pm))) {
    160160        if ( _System_state_Is_up( _System_state_Get() ) )
    161         rtems_error (sc, DRVNM " unable to create mutex\n");
     161        rtems_error (sc, DRVNM "Unable to create mutex\n");
    162162        else
    163                 printk (DRVNM " unable to crate mutex (status code %i)\n", sc);
     163                printk (DRVNM "Unable to create mutex (status code %i)\n", sc);
    164164  }
    165165  return sc;
     
    186186    if ( RTEMS_SUCCESSFUL != sc ) {
    187187      LIBUNLOCK ();
    188       rtems_panic (DRVNM " unable to create bus lock");
     188      rtems_panic (DRVNM "Unable to create bus lock");
    189189    } else {
    190190          bus->mutex = m;
     
    339339
    340340/* Our ops just dispatch to the registered drivers */
    341 rtems_driver_address_table rtems_libi2c_io_ops = {
     341const rtems_driver_address_table rtems_libi2c_io_ops = {
    342342  initialization_entry:  rtems_i2c_init,
    343343  open_entry:            rtems_i2c_open,
     
    369369  if (RTEMS_SUCCESSFUL != sc) {
    370370    safe_printf(
    371              DRVNM " Claiming driver slot failed (rtems status code %i)\n",
     371             DRVNM "Claiming driver slot failed (rtems status code %i)\n",
    372372             sc);
    373373        if ( libmutex )
     
    382382
    383383int
    384 rtems_libi2c_register_bus (char *name, rtems_libi2c_bus_t * bus)
     384rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus)
    385385{
    386386  int i;
     
    395395  /* check */
    396396  if ('/' != *nmcpy) {
    397     safe_printf ( DRVNM "Bad name; must be an absolute path starting with '/'\n");
     397    safe_printf ( DRVNM "Bad name: must be an absolute path starting with '/'\n");
    398398    return -RTEMS_INVALID_NAME;
    399399  }
    400400  /* file must not exist */
    401401  if (!stat (nmcpy, &sbuf)) {
    402     safe_printf ( DRVNM "Bad name; file exists already\n");
     402    safe_printf ( DRVNM "Bad name: file exists already\n");
    403403    return -RTEMS_INVALID_NAME;
    404404  }
     
    419419
    420420  if (!libmutex) {
    421     safe_printf ( DRVNM " library not initialized\n");
     421    safe_printf ( DRVNM "Library not initialized\n");
    422422    return -RTEMS_NOT_DEFINED;
    423423  }
    424424
    425   if (bus->size < sizeof (*bus)) {
    426     safe_printf ( DRVNM " bus-ops size too small -- misconfiguration?\n");
     425  if (bus == NULL || bus->size < sizeof (*bus)) {
     426    safe_printf ( DRVNM "No bus-ops or size too small -- misconfiguration?\n");
    427427    return -RTEMS_NOT_CONFIGURED;
    428428  }
     
    577577  int sc = 0;
    578578  void *args;
    579   boolean is_started = FALSE;
     579  rtems_boolean is_started = FALSE;
    580580  DECL_CHECKED_BH (busno, bush, minor, -)
    581581   
     
    686686
    687687int
    688 rtems_libi2c_register_drv (char *name, rtems_libi2c_drv_t * drvtbl,
     688rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,
    689689                           unsigned busno, unsigned i2caddr)
    690690{
     
    694694
    695695  if (!libmutex) {
    696     safe_printf ( DRVNM " library not initialized\n");
     696    safe_printf ( DRVNM "Library not initialized\n");
    697697    return -RTEMS_NOT_DEFINED;
    698698  }
     
    708708  }
    709709
    710   if (drvtbl->size < sizeof (*drvtbl)) {
    711     safe_printf ( DRVNM " drv-ops size too small -- misconfiguration?\n");
     710  if (drvtbl == NULL || drvtbl->size < sizeof (*drvtbl)) {
     711    safe_printf ( DRVNM "No driver table or size too small -- misconfiguration?\n");
    712712    return -RTEMS_NOT_CONFIGURED;
    713713  }
  • cpukit/libi2c/libi2c.h

    r5396467 r5e4831f  
    101101    void *arg);
    102102
    103 extern rtems_driver_address_table rtems_libi2c_io_ops;
     103extern const rtems_driver_address_table rtems_libi2c_io_ops;
    104104
    105105/* Unfortunately, if you want to add this driver to
     
    145145typedef struct rtems_libi2c_bus_t_
    146146{
    147   struct rtems_libi2c_bus_ops_ *ops;
     147  const struct rtems_libi2c_bus_ops_ *ops;
    148148  int size;                     /* size of whole structure */
    149149} rtems_libi2c_bus_t;
     
    197197 */
    198198
    199 int rtems_libi2c_register_bus (char *name, rtems_libi2c_bus_t * bus);
     199int rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus);
    200200
    201201extern rtems_device_major_number rtems_libi2c_major;
     
    280280typedef struct rtems_libi2c_drv_t_
    281281{
    282   rtems_driver_address_table *ops;      /* the driver ops */
     282  const rtems_driver_address_table *ops;      /* the driver ops */
    283283  int size;                     /* size of whole structure (including appended private data) */
    284284} rtems_libi2c_drv_t;
     
    298298 */
    299299int
    300 rtems_libi2c_register_drv (char *name, rtems_libi2c_drv_t * drvtbl,
     300rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,
    301301                           unsigned bus, unsigned i2caddr);
    302302
     
    441441  boolean  clock_inv;      /* TRUE: inverted clock (high active)    */
    442442  boolean  clock_phs;      /* TRUE: clock starts toggling at start of data tfr */
     443  uint32_t  idle_char;      /* This character will be continuously transmitted in read only functions */
    443444} rtems_libi2c_tfr_mode_t;
    444445
Note: See TracChangeset for help on using the changeset viewer.