From patchwork Thu Apr 28 13:04: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: 66897 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp202686qge; Thu, 28 Apr 2016 06:04:35 -0700 (PDT) X-Received: by 10.98.46.71 with SMTP id u68mr20538829pfu.136.1461848674916; Thu, 28 Apr 2016 06:04:34 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si10225852pfa.250.2016.04.28.06.04.34; Thu, 28 Apr 2016 06:04:34 -0700 (PDT) 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 S1752189AbcD1NEY (ORCPT + 4 others); Thu, 28 Apr 2016 09:04:24 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:35818 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750845AbcD1NEW (ORCPT ); Thu, 28 Apr 2016 09:04:22 -0400 Received: by mail-lf0-f45.google.com with SMTP id c126so94438132lfb.2 for ; Thu, 28 Apr 2016 06:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Iqhlv3sITEN5WptP58+40MFHetlhr9QqeO04VeDbcFI=; b=SeDSDUyMIGJ5nQOOAP818RciIExvVgh/TMa85HIezROEbZc/gynKHUPlQte6rKMUpC ixTczK7LVaIB+2XJitHPhdOjt+jD7JWCn4QP8Aq//Vdv1c9NhZ30DmyWpNjjNtb5sIuJ mEH/KgW1S1oEzVGlqSf6i6pbuf2oRxVoloOIc= 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=Iqhlv3sITEN5WptP58+40MFHetlhr9QqeO04VeDbcFI=; b=UMUHPw/tpPtrN31nb7g42zIDSBsvBgje9HMiywXG75kC7w6OexK0DkF9Jcx/U/TWwM QB5FOZQlora6XSgc/hqjs1aBVQ9dnKsDK4QMOE6BbrIMZX6knUGk41bXrbffky4ISU1+ Pi2UmSBfVa/XbufkBc1UiiKZU8eQvkjXkxAeIMkO9J/7bBomRpKX917tndG9VvLvkVOF dGnT8rxoQLlvYyZwko5T2kMIAMV3cX+nr5cEhmT81OS1LClJjJT9D3u3shKKzethmPbh 9cf9AGAFUG0TkBe6TZ6xj6QUDChhbSTxMQw6VxbnGN5AczrmuGD492iwFqTjmFPR6rlK Ul1Q== X-Gm-Message-State: AOPr4FWBtE9WhIhplRWjGuntSbndUd4cMxMs0ZMcQo8r4C0/+r2to2HiLLbkMV477wam34rV X-Received: by 10.25.26.143 with SMTP id a137mr6268684lfa.1.1461848660462; Thu, 28 Apr 2016 06:04:20 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d74sm1658122lfb.49.2016.04.28.06.04.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 06:04:19 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Patrice Chotard Subject: [PATCH] gpio: stmpe: implement .get_direction() Date: Thu, 28 Apr 2016 15:04:15 +0200 Message-Id: <1461848655-12230-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This implements the .get_direction() callback for the STMPE expander GPIO. Cc: Patrice Chotard Signed-off-by: Linus Walleij --- drivers/gpio/gpio-stmpe.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.4.11 -- 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-stmpe.c b/drivers/gpio/gpio-stmpe.c index 5197edf1acfd..5f77ea6b294d 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -69,6 +69,22 @@ static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val) stmpe_reg_write(stmpe, reg, mask); } +static int stmpe_gpio_get_direction(struct gpio_chip *chip, + unsigned offset) +{ + struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); + struct stmpe *stmpe = stmpe_gpio->stmpe; + u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); + u8 mask = 1 << (offset % 8); + int ret; + + ret = stmpe_reg_read(stmpe, reg); + if (ret < 0) + return ret; + + return !(ret & mask); +} + static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { @@ -107,6 +123,7 @@ static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) static struct gpio_chip template_chip = { .label = "stmpe", .owner = THIS_MODULE, + .get_direction = stmpe_gpio_get_direction, .direction_input = stmpe_gpio_direction_input, .get = stmpe_gpio_get, .direction_output = stmpe_gpio_direction_output,