From patchwork Wed Nov 30 09:09:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84978 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp143350qgi; Wed, 30 Nov 2016 01:09:44 -0800 (PST) X-Received: by 10.84.218.3 with SMTP id q3mr70965940pli.80.1480496984617; Wed, 30 Nov 2016 01:09:44 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si34863026pli.232.2016.11.30.01.09.44; Wed, 30 Nov 2016 01:09:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757386AbcK3JJm (ORCPT + 4 others); Wed, 30 Nov 2016 04:09:42 -0500 Received: from mail-lf0-f44.google.com ([209.85.215.44]:34755 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757523AbcK3JJW (ORCPT ); Wed, 30 Nov 2016 04:09:22 -0500 Received: by mail-lf0-f44.google.com with SMTP id o141so141525604lff.1 for ; Wed, 30 Nov 2016 01:09:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=FfMlQjuhwaAwq4JL+ZbC+7C5FH1a/1Zx7TqIQ+Tvg3o=; b=SkE/rcNnkWmm7tpIKPjp6ljorUaXiNDLumuJ++cl/1f6cRSucyVX80CKhjTHwFIEN2 B35SyNPM4Sc5sQiv37ahRim3ONZ/+gm5aDCJ1i6YyrkG6OWqzh9IH54zg5ZiCQMvhTAK XHwCkOgHTY72ztCP62n4ihpNV4k5Sar6pKG/s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FfMlQjuhwaAwq4JL+ZbC+7C5FH1a/1Zx7TqIQ+Tvg3o=; b=N2v31/btf4vWxXoOCT0MGQ0NuBxhIyj1ISL4VXUSqQvXcVMU8Y7hj3HbO8n0xCrbLP MV3iWDhI4Meq/OfuYGhVz8M5uUYZTC0i4u8jXY+AVgSqm/saBqSNH083ocyUHle6uTpk H7RlbKdKEH+rQgsztL97db67VzmcADrrKoIUu2BL2ruNykBp44dT4YDfByRdMOnMSQXb oTvG0TH616/5NvD4wf2FbWdXpO6bOw1Y7EG5FWk3p//n/FmrYBhNYCbQryrseVhlj70f H4aGA6GALFkkoU/rd+42+ZOyD2/HOddHgc6NPZ47Yqban15lWEsji15eovaZ+WOpJhel eH8A== X-Gm-Message-State: AKaTC00FcS+1PXaKS/kkpI+O6JdiI2eF/fN/VaOhWxfiVqxDy1XTdIwpbnw1GOYX87A528bF X-Received: by 10.25.131.144 with SMTP id f138mr9241659lfd.127.1480496959734; Wed, 30 Nov 2016 01:09:19 -0800 (PST) Received: from linuslaptop.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u12sm14128309lja.4.2016.11.30.01.09.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2016 01:09:19 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH 1/2] gpio: htc-egpio: add .get_direction() support Date: Wed, 30 Nov 2016 10:09:15 +0100 Message-Id: <1480496955-5727-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This makes is possible to read out the current direction of a GPIO line on the HTC CPLD GPIO expander. Suggested-by: Russell King Signed-off-by: Linus Walleij --- drivers/gpio/gpio-htc-egpio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c index 5ab895b41819..27af52850927 100644 --- a/drivers/gpio/gpio-htc-egpio.c +++ b/drivers/gpio/gpio-htc-egpio.c @@ -225,6 +225,15 @@ static int egpio_direction_output(struct gpio_chip *chip, } } +static int egpio_get_direction(struct gpio_chip *chip, unsigned offset) +{ + struct egpio_chip *egpio; + + egpio = gpiochip_get_data(chip); + + return !test_bit(offset, &egpio->is_out); +} + static void egpio_write_cache(struct egpio_info *ei) { int i; @@ -327,6 +336,7 @@ static int __init egpio_probe(struct platform_device *pdev) chip->set = egpio_set; chip->direction_input = egpio_direction_input; chip->direction_output = egpio_direction_output; + chip->get_direction = egpio_get_direction; chip->base = pdata->chip[i].gpio_base; chip->ngpio = pdata->chip[i].num_gpios;