From patchwork Thu Oct 9 09:42:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 38500 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CFEBC2032C for ; Thu, 9 Oct 2014 09:43:33 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id cc10sf643176wib.3 for ; Thu, 09 Oct 2014 02:43:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=XIrhD3thJkrVdw0nXSIeqmw8oLktsAE6Bakxm3WfuXU=; b=cqQaSnhPMOpISKR81ybV/Ns339Kkn/sSTYHfh3FjJchB0mlWiLU+L2TOvO63xw9fCt YbVdRJ1Q7NhEdN3mX2h/F9jCHMxv2sxAyHApA1Cl5jDZPsHfIa6zgMqEvk4DlNIbcBVX DJrx0uz8E6gly2ylPGClGQbQA8N8piuPTEfpYEK4b+bmfglBeFCwRuMU7xXRO8LrdjC5 8pYbVizAj0v9tS+4hADTDlrClGzw/p1gxPV2BWp88sfY55+gBNkFrVOLsajXk31SResG j3tHXJusqMZg2TEvg9ubyboZk8D01u1kWDZ+THYuLXaKTalYz4nwjd1vCorE8jRg6tHl d5bw== X-Gm-Message-State: ALoCoQkfEtm0/yLHcrWN15I4+xzXJsDGZ0wc2kQSM+UIKkdye6iwdQedt1r/6H8ymzOEasud6yjJ X-Received: by 10.181.8.226 with SMTP id dn2mr567096wid.4.1412847813044; Thu, 09 Oct 2014 02:43:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.42 with SMTP id k10ls140865lae.66.gmail; Thu, 09 Oct 2014 02:43:32 -0700 (PDT) X-Received: by 10.152.27.40 with SMTP id q8mr2187895lag.92.1412847812886; Thu, 09 Oct 2014 02:43:32 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx.google.com with ESMTPS id la7si3463372lab.91.2014.10.09.02.43.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Oct 2014 02:43:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so765401lbd.6 for ; Thu, 09 Oct 2014 02:43:32 -0700 (PDT) X-Received: by 10.152.22.42 with SMTP id a10mr3122621laf.56.1412847812761; Thu, 09 Oct 2014 02:43:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp210553lbz; Thu, 9 Oct 2014 02:43:32 -0700 (PDT) X-Received: by 10.182.27.5 with SMTP id p5mr21130201obg.42.1412847811624; Thu, 09 Oct 2014 02:43:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si2517214oek.98.2014.10.09.02.43.31 for ; Thu, 09 Oct 2014 02:43:31 -0700 (PDT) Received-SPF: none (google.com: linux-gpio-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754558AbaJIJna (ORCPT ); Thu, 9 Oct 2014 05:43:30 -0400 Received: from mail-oi0-f53.google.com ([209.85.218.53]:51484 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754506AbaJIJn3 (ORCPT ); Thu, 9 Oct 2014 05:43:29 -0400 Received: by mail-oi0-f53.google.com with SMTP id v63so1899680oia.40 for ; Thu, 09 Oct 2014 02:43:29 -0700 (PDT) X-Received: by 10.182.133.104 with SMTP id pb8mr20732618obb.37.1412847809331; Thu, 09 Oct 2014 02:43:29 -0700 (PDT) Received: from localhost.localdomain ([61.172.253.147]) by mx.google.com with ESMTPSA id mq4sm3123104obb.22.2014.10.09.02.43.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Oct 2014 02:43:28 -0700 (PDT) From: Haojian Zhuang To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linus.walleij@linaro.org Cc: Haojian Zhuang Subject: [PATCH] gpio: pl061: hook request if gpio-ranges avaiable Date: Thu, 9 Oct 2014 17:42:15 +0800 Message-Id: <1412847735-498-1-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: haojian.zhuang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , gpio-ranges property could binds gpio to pinctrl. But there may be some gpios without pinctrl operation. So check whether gpio-ranges property exists in device node first. Signed-off-by: Haojian Zhuang --- drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 84b49cf..d1813f0 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -52,28 +52,34 @@ struct pl061_gpio { void __iomem *base; struct gpio_chip gc; + int uses_pinctrl; #ifdef CONFIG_PM struct pl061_context_save_regs csave_regs; #endif }; -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset) +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset) { /* * Map back to global GPIO space and request muxing, the direction * parameter does not matter for this controller. */ - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - return pinctrl_request_gpio(gpio); + if (chip->uses_pinctrl) + return pinctrl_request_gpio(gpio); + return 0; } -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset) +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset) { - int gpio = chip->base + offset; + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); + int gpio = gc->base + offset; - pinctrl_free_gpio(gpio); + if (chip->uses_pinctrl) + pinctrl_free_gpio(gpio); } static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) spin_lock_init(&chip->lock); + /* Hook the request()/free() for pinctrl operation */ + if (of_property_read_bool(dev->of_node, "gpio-ranges")) + chip->uses_pinctrl = true; chip->gc.request = pl061_gpio_request; chip->gc.free = pl061_gpio_free; chip->gc.direction_input = pl061_direction_input;