From owner-svn-src-stable-10@freebsd.org Sun Jan 24 18:54:13 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91413A318D0; Sun, 24 Jan 2016 18:54:13 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 43F3610B; Sun, 24 Jan 2016 18:54:13 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0OIsCMd069978; Sun, 24 Jan 2016 18:54:12 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0OIsCRs069976; Sun, 24 Jan 2016 18:54:12 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201601241854.u0OIsCRs069976@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 24 Jan 2016 18:54:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r294673 - stable/10/sys/dev/iicbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2016 18:54:13 -0000 Author: ian Date: Sun Jan 24 18:54:11 2016 New Revision: 294673 URL: https://svnweb.freebsd.org/changeset/base/294673 Log: MFC r289726: 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: stable/10/sys/dev/iicbus/iiconf.c stable/10/sys/dev/iicbus/iiconf.h Modified: stable/10/sys/dev/iicbus/iiconf.c ============================================================================== --- stable/10/sys/dev/iicbus/iiconf.c Sun Jan 24 18:50:37 2016 (r294672) +++ stable/10/sys/dev/iicbus/iiconf.c Sun Jan 24 18:54:11 2016 (r294673) @@ -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: stable/10/sys/dev/iicbus/iiconf.h ============================================================================== --- stable/10/sys/dev/iicbus/iiconf.h Sun Jan 24 18:50:37 2016 (r294672) +++ stable/10/sys/dev/iicbus/iiconf.h Sun Jan 24 18:54:11 2016 (r294673) @@ -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