Deleted Added
full compact
iiconf.c (119418) iiconf.c (160372)
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 119418 2003-08-24 17:55:58Z obrien $");
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iiconf.c 160372 2006-07-14 23:15:06Z imp $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34
35#include <dev/iicbus/iiconf.h>
36#include <dev/iicbus/iicbus.h>

--- 289 unchanged lines hidden (view full) ---

326 return (error);
327
328 error = iicbus_read(bus, buf, len, read, IIC_LAST_READ, 0);
329
330 iicbus_stop(bus);
331
332 return (error);
333}
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34
35#include <dev/iicbus/iiconf.h>
36#include <dev/iicbus/iicbus.h>

--- 289 unchanged lines hidden (view full) ---

326 return (error);
327
328 error = iicbus_read(bus, buf, len, read, IIC_LAST_READ, 0);
329
330 iicbus_stop(bus);
331
332 return (error);
333}
334
335/*
336 * iicbus_trasnfer()
337 *
338 * Do an aribtrary number of transfers on the iicbus. We pass these
339 * raw requests to the bridge driver. If the bridge driver supports
340 * them directly, then it manages all the details. If not, it can use
341 * the helper function iicbus_transfer_gen() which will do the
342 * transfers at a low level.
343 *
344 * Pointers passed in as part of iic_msg must be kernel pointers.
345 * Callers that have user addresses to manage must do so on their own.
346 */
347int
348iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
349{
350 return (IICBUS_TRANSFER(device_get_parent(bus), msgs, nmsgs));
351}
352
353/*
354 * Generic version of iicbus_transfer that calls the appropriate
355 * routines to accomplish this. See note above about acceptable
356 * buffer addresses.
357 */
358int
359iicbus_transfer_gen(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
360{
361 int i, error, max, lenread, lenwrote;
362
363 for (i = 0, max = 0; i < nmsgs; i++)
364 if (max < msgs[i].len)
365 max = msgs[i].len;
366 for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
367 if (msgs[i].flags & IIC_M_RD)
368 error = iicbus_block_read(bus, msgs[i].slave,
369 msgs[i].buf, msgs[i].len, &lenread);
370 else
371 error = iicbus_block_write(bus, msgs[i].slave,
372 msgs[i].buf, msgs[i].len, &lenwrote);
373 }
374 return (error);
375}