From patchwork Thu Oct 10 08:39:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ionut Nicu X-Patchwork-Id: 282172 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 86C952C032F for ; Thu, 10 Oct 2013 19:39:45 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752327Ab3JJIjo (ORCPT ); Thu, 10 Oct 2013 04:39:44 -0400 Received: from demumfd002.nsn-inter.net ([93.183.12.31]:14397 "EHLO demumfd002.nsn-inter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751746Ab3JJIjm (ORCPT ); Thu, 10 Oct 2013 04:39:42 -0400 Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd002.nsn-inter.net (8.12.11.20060308/8.12.11) with ESMTP id r9A8dZtr018755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 10 Oct 2013 10:39:35 +0200 Received: from [10.151.38.113] ([10.151.38.113]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id r9A8dWPH004897; Thu, 10 Oct 2013 10:39:32 +0200 Message-ID: <525667C4.3080309@nsn.com> Date: Thu, 10 Oct 2013 10:39:32 +0200 From: Ionut Nicu User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Peter Korsgaard CC: Wolfram Sang , Alexander Sverdlin , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] i2c-mux-gpio: test if the gpio can sleep X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 1106 X-purgate-ID: 151667::1381394376-00005753-9BD42B1A/0-0/0-0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Some gpio chips may have get/set operations that can sleep. For this type of chips we must use the _cansleep() version of gpio_set_value. Signed-off-by: Ionut Nicu --- drivers/i2c/muxes/i2c-mux-gpio.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index a764da7..b5f17ef 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -27,11 +27,16 @@ struct gpiomux { static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) { + unsigned gpio; int i; - for (i = 0; i < mux->data.n_gpios; i++) - gpio_set_value(mux->gpio_base + mux->data.gpios[i], - val & (1 << i)); + for (i = 0; i < mux->data.n_gpios; i++) { + gpio = mux->gpio_base + mux->data.gpios[i]; + if (gpio_cansleep(gpio)) + gpio_set_value_cansleep(gpio, val & (1 << i)); + else + gpio_set_value(gpio, val & (1 << i)); + } } static int i2c_mux_gpio_select(struct i2c_adapter *adap, void *data, u32 chan)