iiconf.c (214999) | iiconf.c (228257) |
---|---|
1/*- 2 * Copyright (c) 1998 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iiconf.c 214999 2010-11-08 19:53:16Z nwhitehorn $"); | 28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iiconf.c 228257 2011-12-04 11:55:33Z adrian $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/lock.h> 33#include <sys/malloc.h> 34#include <sys/module.h> 35#include <sys/mutex.h> 36#include <sys/bus.h> --- 201 unchanged lines hidden (view full) --- 238 * Write a block of data to the slave previously started by 239 * iicbus_start() call 240 */ 241int 242iicbus_write(device_t bus, const char *buf, int len, int *sent, int timeout) 243{ 244 struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); 245 | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/lock.h> 33#include <sys/malloc.h> 34#include <sys/module.h> 35#include <sys/mutex.h> 36#include <sys/bus.h> --- 201 unchanged lines hidden (view full) --- 238 * Write a block of data to the slave previously started by 239 * iicbus_start() call 240 */ 241int 242iicbus_write(device_t bus, const char *buf, int len, int *sent, int timeout) 243{ 244 struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); 245 |
246 /* a slave must have been started with the appropriate address */ 247 if (!sc->started || (sc->started & LSB)) | 246 /* a slave must have been started for writing */ 247 if (sc->started == 0 || (sc->strict != 0 && (sc->started & LSB) != 0)) |
248 return (EINVAL); 249 250 return (IICBUS_WRITE(device_get_parent(bus), buf, len, sent, timeout)); 251} 252 253/* 254 * iicbus_read() 255 * 256 * Read a block of data from the slave previously started by 257 * iicbus_read() call 258 */ 259int 260iicbus_read(device_t bus, char *buf, int len, int *read, int last, int delay) 261{ 262 struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); 263 | 248 return (EINVAL); 249 250 return (IICBUS_WRITE(device_get_parent(bus), buf, len, sent, timeout)); 251} 252 253/* 254 * iicbus_read() 255 * 256 * Read a block of data from the slave previously started by 257 * iicbus_read() call 258 */ 259int 260iicbus_read(device_t bus, char *buf, int len, int *read, int last, int delay) 261{ 262 struct iicbus_softc *sc = (struct iicbus_softc *)device_get_softc(bus); 263 |
264 /* a slave must have been started with the appropriate address */ 265 if (!sc->started || !(sc->started & LSB)) | 264 /* a slave must have been started for reading */ 265 if (sc->started == 0 || (sc->strict != 0 && (sc->started & LSB) == 0)) |
266 return (EINVAL); 267 268 return (IICBUS_READ(device_get_parent(bus), buf, len, read, last, delay)); 269} 270 271/* 272 * iicbus_write_byte() 273 * --- 137 unchanged lines hidden --- | 266 return (EINVAL); 267 268 return (IICBUS_READ(device_get_parent(bus), buf, len, read, last, delay)); 269} 270 271/* 272 * iicbus_write_byte() 273 * --- 137 unchanged lines hidden --- |