Date: Thu, 22 Oct 2015 00:54:59 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289726 - head/sys/dev/iicbus Message-ID: <201510220054.t9M0sxD0076490@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Thu Oct 22 00:54:59 2015 New Revision: 289726 URL: https://svnweb.freebsd.org/changeset/base/289726 Log: Add iicbus_transfer_excl(), a helper routine to do an i2c bus transaction while holding exclusive ownership of the bus. This is the routine most slave drivers should use unless they have a need to acquire and hold the bus across a series of related operations that involves multiple transfers. Modified: head/sys/dev/iicbus/iiconf.c head/sys/dev/iicbus/iiconf.h Modified: head/sys/dev/iicbus/iiconf.c ============================================================================== --- head/sys/dev/iicbus/iiconf.c Thu Oct 22 00:07:48 2015 (r289725) +++ head/sys/dev/iicbus/iiconf.c Thu Oct 22 00:54:59 2015 (r289726) @@ -395,6 +395,21 @@ iicbus_transfer(device_t bus, struct iic return (IICBUS_TRANSFER(device_get_parent(bus), msgs, nmsgs)); } +int +iicbus_transfer_excl(device_t dev, struct iic_msg *msgs, uint32_t nmsgs, + int how) +{ + device_t bus; + int error; + + bus = device_get_parent(dev); + error = iicbus_request_bus(bus, dev, how); + if (error == 0) + error = IICBUS_TRANSFER(bus, msgs, nmsgs); + iicbus_release_bus(bus, dev); + return (error); +} + /* * Generic version of iicbus_transfer that calls the appropriate * routines to accomplish this. See note above about acceptable Modified: head/sys/dev/iicbus/iiconf.h ============================================================================== --- head/sys/dev/iicbus/iiconf.h Thu Oct 22 00:07:48 2015 (r289725) +++ head/sys/dev/iicbus/iiconf.h Thu Oct 22 00:54:59 2015 (r289726) @@ -129,6 +129,8 @@ extern int iicbus_block_read(device_t, u /* vectors of iic operations to pass to bridge */ int iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs); +int iicbus_transfer_excl(device_t bus, struct iic_msg *msgs, uint32_t nmsgs, + int how); int iicbus_transfer_gen(device_t bus, struct iic_msg *msgs, uint32_t nmsgs); #define IICBUS_MODVER 1
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510220054.t9M0sxD0076490>