From patchwork Thu Apr 14 23:47:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 709941 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3ENlMaC025041 for ; Thu, 14 Apr 2011 23:47:42 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F12FB9F69C for ; Thu, 14 Apr 2011 16:47:21 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qw0-f49.google.com (mail-qw0-f49.google.com [209.85.216.49]) by gabe.freedesktop.org (Postfix) with ESMTP id AB0719E710 for ; Thu, 14 Apr 2011 16:47:13 -0700 (PDT) Received: by qwi2 with SMTP id 2so1447187qwi.36 for ; Thu, 14 Apr 2011 16:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=fHbtFIIx5h5p2/pxlHa11Cr2cfX9btXaj4n1kKKB6wo=; b=WhBDDsxR79ZbEF6H015X8REHwpmGMeJjEOXv0Si+jYTwTsflOyCF81lSObWRzXzpP3 FOZF/VHrgdMzFp4QDhcnABnd1HMUvJvdeZTVhkpVEAJD9RfykFevEdSvJhAqcpCxCjwH O8PvLg6s6Yc0v1hZZucqtBbopjRS+cXcdRYto= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Bqs9s8lV9WCVr5F+a5+xeoDlJ7hmil6i/AWWvpbZU911zlNeLR3CHeS9Q1o0rLXoN9 +urxxHcs33A/PEWOqUgJlMnalJ0K2umZ3uQWnluLz2u4ULYsXrDlyg7yTUzVIQro3nwk /QjeFhrKO5SaqoFQ4ds/sLFSvYL4j3tZQNrMs= Received: by 10.229.20.77 with SMTP id e13mr1040746qcb.193.1302824833047; Thu, 14 Apr 2011 16:47:13 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-7.washdc.fios.verizon.net [74.96.105.7]) by mx.google.com with ESMTPS id f5sm1549220qck.32.2011.04.14.16.47.12 (version=SSLv3 cipher=OTHER); Thu, 14 Apr 2011 16:47:12 -0700 (PDT) From: Alex Deucher To: airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-i2c@vger.kernel.org Subject: [PATCH] i2c-algo-bit: make sure to call pre/post_xfer for bit_test Date: Thu, 14 Apr 2011 19:47:06 -0400 Message-Id: <1302824827-7348-1-git-send-email-alexdeucher@gmail.com> X-Mailer: git-send-email 1.7.1.1 Cc: Jean Delvare X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 14 Apr 2011 23:47:43 +0000 (UTC) Apparently some distros set i2c-algo-bit.bit_test to 1 by default. In some cases this causes i2c_bit_add_bus to fail and prevents the i2c bus from being added. In the radeon case, we fail to add the ddc i2c buses which prevents the driver from being able to detect attached monitors. The i2c bus works fine even if bit_test fails. This is likely due to gpio switching that is required and handled in the pre/post_xfer hooks, so call the pre/post_xfer hooks in the bit test as well. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=36221 Cc: Jean Delvare Signed-off-by: Alex Deucher --- drivers/i2c/algos/i2c-algo-bit.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 38319a6..e2740e6 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -232,9 +232,16 @@ static int i2c_inb(struct i2c_adapter *i2c_adap) * Sanity check for the adapter hardware - check the reaction of * the bus lines only if it seems to be idle. */ -static int test_bus(struct i2c_algo_bit_data *adap, char *name) +static int test_bus(struct i2c_adapter *i2c_adap, char *name) { - int scl, sda; + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + int scl, sda, ret; + + if (adap->pre_xfer) { + ret = adap->pre_xfer(i2c_adap); + if (ret < 0) + return -ENODEV; + } if (adap->getscl == NULL) pr_info("%s: Testing SDA only, SCL is not readable\n", name); @@ -297,11 +304,19 @@ static int test_bus(struct i2c_algo_bit_data *adap, char *name) "while pulling SCL high!\n", name); goto bailout; } + + if (adap->post_xfer) + adap->post_xfer(i2c_adap); + pr_info("%s: Test OK\n", name); return 0; bailout: sdahi(adap); sclhi(adap); + + if (adap->post_xfer) + adap->post_xfer(i2c_adap); + return -ENODEV; } @@ -607,7 +622,7 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap, int ret; if (bit_test) { - ret = test_bus(bit_adap, adap->name); + ret = test_bus(adap, adap->name); if (ret < 0) return -ENODEV; }