From 42bf1b9f13d9269d9a98de4bdc1a11365865ef42 Mon Sep 17 00:00:00 2001 From: Thomas Doerfler Date: Thu, 15 May 2008 15:10:38 +0000 Subject: adapted gen83xx to new board --- cpukit/libi2c/libi2c.c | 24 +++++++++++++++++------- cpukit/libi2c/libi2c.h | 13 ++++++++++++- 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'cpukit/libi2c') diff --git a/cpukit/libi2c/libi2c.c b/cpukit/libi2c/libi2c.c index 7adb793e3a..27c428064f 100644 --- a/cpukit/libi2c/libi2c.c +++ b/cpukit/libi2c/libi2c.c @@ -576,11 +576,9 @@ rtems_libi2c_ioctl (rtems_device_minor_number minor, va_list ap; int sc = 0; void *args; + boolean is_started = FALSE; DECL_CHECKED_BH (busno, bush, minor, -) - - if (not_started (busno)) - return -RTEMS_NOT_OWNER_OF_RESOURCE; - + va_start(ap, cmd); args = va_arg(ap, void *); @@ -589,7 +587,17 @@ rtems_libi2c_ioctl (rtems_device_minor_number minor, * add ioctls defined for this level here: */ + case RTEMS_LIBI2C_IOCTL_GET_DRV_T: + /* + * query driver table entry + */ + *(rtems_libi2c_drv_t **)args = (drvs[MINOR2DRV(minor)-1].drv); + break; + case RTEMS_LIBI2C_IOCTL_START_TFM_READ_WRITE: + if (not_started (busno)) + return -RTEMS_NOT_OWNER_OF_RESOURCE; + /* * address device, then set transfer mode and perform read_write transfer */ @@ -598,6 +606,7 @@ rtems_libi2c_ioctl (rtems_device_minor_number minor, */ if (sc == 0) { sc = rtems_libi2c_send_start (minor); + is_started = (sc == 0); } /* * set tfr mode @@ -617,14 +626,15 @@ rtems_libi2c_ioctl (rtems_device_minor_number minor, RTEMS_LIBI2C_IOCTL_READ_WRITE, &((rtems_libi2c_tfm_read_write_t *)args)->rd_wr); } + if ((sc < 0) && (is_started)) { + rtems_libi2c_send_stop (minor); + } break; default: sc = bush->ops->ioctl (bush, cmd, args); break; } - if (sc < 0) - rtems_libi2c_send_stop (minor); - return sc; + return sc; } static int diff --git a/cpukit/libi2c/libi2c.h b/cpukit/libi2c/libi2c.h index a3b98f8fd5..560fd53174 100644 --- a/cpukit/libi2c/libi2c.h +++ b/cpukit/libi2c/libi2c.h @@ -413,8 +413,19 @@ rtems_libi2c_ioctl (rtems_device_minor_number minor, * This call is only needed for SPI devices */ +#define RTEMS_LIBI2C_IOCTL_GET_DRV_T 4 /* - * arguemtn data structures for IOCTLs defined above + * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, + * RTEMS_LIBI2C_IOCTL_GET_DRV_T, + * const rtems_libi2c_drv_t *drv_t_ptr); + * + * This call allows the a high-level driver to query its driver table entry, + * including its private data appended to it during creation of the entry + * + */ + +/* + * argument data structures for IOCTLs defined above */ typedef struct { unsigned char *rd_buf; -- cgit v1.2.3