From patchwork Tue Mar 17 12:04:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 450956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 655C4140077 for ; Tue, 17 Mar 2015 23:05:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753053AbbCQMFS (ORCPT ); Tue, 17 Mar 2015 08:05:18 -0400 Received: from [185.25.241.215] ([185.25.241.215]:46734 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752947AbbCQMFR (ORCPT ); Tue, 17 Mar 2015 08:05:17 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 3591646090F; Tue, 17 Mar 2015 12:04:40 +0000 (GMT) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d4wMGeRp--mn; Tue, 17 Mar 2015 12:04:35 +0000 (GMT) Received: from rainbowdash.ducie.codethink.co.uk (rainbowdash.dyn.ducie.codethink.co.uk [10.24.2.99]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id DEB95460351; Tue, 17 Mar 2015 12:04:34 +0000 (GMT) Received: from ben by rainbowdash.ducie.codethink.co.uk with local (Exim 4.84) (envelope-from ) id 1YXqEc-0002HI-J8; Tue, 17 Mar 2015 12:04:34 +0000 From: Ben Dooks To: linux-i2c@vger.kernel.org Cc: linux-kernel@codethink.co.uk, Ben Dooks , Haavard Skinnemoen , Wolfram Sang Subject: [PATCH] i2c: i2c-gpio: fix some of gpio sleep issues Date: Tue, 17 Mar 2015 12:04:29 +0000 Message-Id: <1426593869-8724-1-git-send-email-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.1.4 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The i2c-gpio driver can be used in systems where the GPIO itself is provided by a GPIO driver that may be sleeping (for example, SPI or USB). In this case, it is preferable to use the _cansleep() variants of the GPIO code. We can only fix this up for the case where the i2c-gpio implementation provides open-drain outputs as there are no gpio_direction_xxx_cansleep() provided. This removes the issues on the customer system with the console constantly showing the following warning: WARNING: CPU: 0 PID: 1 at drivers/gpio/gpiolib.c:2389 gpiod_set_raw_value Signed-off-by: Ben Dooks --- CC: Haavard Skinnemoen CC: Wolfram Sang CC: linux-i2c@vger.kernel.org --- drivers/i2c/busses/i2c-gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index d1050bd..9d4d59c 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -44,7 +44,7 @@ static void i2c_gpio_setsda_val(void *data, int state) { struct i2c_gpio_platform_data *pdata = data; - gpio_set_value(pdata->sda_pin, state); + gpio_set_value_cansleep(pdata->sda_pin, state); } /* Toggle SCL by changing the direction of the pin. */ @@ -68,21 +68,21 @@ static void i2c_gpio_setscl_val(void *data, int state) { struct i2c_gpio_platform_data *pdata = data; - gpio_set_value(pdata->scl_pin, state); + gpio_set_value_cansleep(pdata->scl_pin, state); } static int i2c_gpio_getsda(void *data) { struct i2c_gpio_platform_data *pdata = data; - return gpio_get_value(pdata->sda_pin); + return gpio_get_value_cansleep(pdata->sda_pin); } static int i2c_gpio_getscl(void *data) { struct i2c_gpio_platform_data *pdata = data; - return gpio_get_value(pdata->scl_pin); + return gpio_get_value_cansleep(pdata->scl_pin); } static int of_i2c_gpio_get_pins(struct device_node *np,