From owner-svn-src-head@FreeBSD.ORG Thu Mar 1 20:58:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E3AE106564A; Thu, 1 Mar 2012 20:58:21 +0000 (UTC) (envelope-from kan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 547C58FC1A; Thu, 1 Mar 2012 20:58:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q21KwLXS096396; Thu, 1 Mar 2012 20:58:21 GMT (envelope-from kan@svn.freebsd.org) Received: (from kan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q21KwLXZ096393; Thu, 1 Mar 2012 20:58:21 GMT (envelope-from kan@svn.freebsd.org) Message-Id: <201203012058.q21KwLXZ096393@svn.freebsd.org> From: Alexander Kabaev Date: Thu, 1 Mar 2012 20:58:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232365 - head/sys/dev/iicbus X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Mar 2012 20:58:21 -0000 Author: kan Date: Thu Mar 1 20:58:20 2012 New Revision: 232365 URL: http://svn.freebsd.org/changeset/base/232365 Log: Provide pre/post transfer method callbacks for icbbb clients. These are helful when making certain drivers work on both Linux and FreeBSD without changing the code flow too much. Reviewed by: kib, wlosh MFC after: 1 month Modified: head/sys/dev/iicbus/iicbb.c head/sys/dev/iicbus/iicbb_if.m Modified: head/sys/dev/iicbus/iicbb.c ============================================================================== --- head/sys/dev/iicbus/iicbb.c Thu Mar 1 20:45:17 2012 (r232364) +++ head/sys/dev/iicbus/iicbb.c Thu Mar 1 20:58:20 2012 (r232365) @@ -76,6 +76,7 @@ static int iicbb_stop(device_t); static int iicbb_write(device_t, const char *, int, int *, int); static int iicbb_read(device_t, char *, int, int *, int, int); static int iicbb_reset(device_t, u_char, u_char, u_char *); +static int iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs); static device_method_t iicbb_methods[] = { /* device interface */ @@ -95,7 +96,7 @@ static device_method_t iicbb_methods[] = DEVMETHOD(iicbus_write, iicbb_write), DEVMETHOD(iicbus_read, iicbb_read), DEVMETHOD(iicbus_reset, iicbb_reset), - DEVMETHOD(iicbus_transfer, iicbus_transfer_gen), + DEVMETHOD(iicbus_transfer, iicbb_transfer), { 0, 0 } }; @@ -424,6 +425,21 @@ iicbb_read(device_t dev, char * buf, int return (0); } +static int +iicbb_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) +{ + int error; + + error = IICBB_PRE_XFER(device_get_parent(dev)); + if (error) + return (error); + + error = iicbus_transfer_gen(dev, msgs, nmsgs); + + IICBB_POST_XFER(device_get_parent(dev)); + return (error); +} + DRIVER_MODULE(iicbus, iicbb, iicbus_driver, iicbus_devclass, 0, 0); MODULE_DEPEND(iicbb, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); Modified: head/sys/dev/iicbus/iicbb_if.m ============================================================================== --- head/sys/dev/iicbus/iicbb_if.m Thu Mar 1 20:45:17 2012 (r232364) +++ head/sys/dev/iicbus/iicbb_if.m Thu Mar 1 20:58:20 2012 (r232365) @@ -31,13 +31,50 @@ INTERFACE iicbb; # +# Default implementation of optional methods +# +CODE { + static int + null_pre_xfer(device_t dev) + { + return 0; + } + + static void + null_post_xfer(device_t dev) + + { + } + + static int + null_callback(device_t dev, int index, caddr_t data) + { + return 0; + } +}; + +# # iicbus callback # METHOD int callback { device_t dev; int index; caddr_t data; -}; +} DEFAULT null_callback; + +# +# Prepare device for I2C transfer +# +METHOD int pre_xfer { + device_t dev; +} DEFAULT null_pre_xfer; + +# +# Cleanup device after I2C transfer +# +METHOD void post_xfer { + device_t dev; +} DEFAULT null_post_xfer; # # Set I2C bus data line