From patchwork Mon Sep 19 08:10:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 76512 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp836818qgf; Mon, 19 Sep 2016 01:10:32 -0700 (PDT) X-Received: by 10.98.100.1 with SMTP id y1mr30583694pfb.169.1474272631989; Mon, 19 Sep 2016 01:10:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cz4si27749248pad.270.2016.09.19.01.10.31; Mon, 19 Sep 2016 01:10:31 -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 S1752756AbcISIKa (ORCPT + 4 others); Mon, 19 Sep 2016 04:10:30 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:36463 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760546AbcISIKT (ORCPT ); Mon, 19 Sep 2016 04:10:19 -0400 Received: by mail-lf0-f45.google.com with SMTP id g62so100081427lfe.3 for ; Mon, 19 Sep 2016 01:10:18 -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=ZtP/qs71p3VGBR+2z2uAWf97wp47TqAKbCOV89Q0oV0=; b=OKkbKwXrhEmKT/et+rJs9YgQmfHVKpI2XeNAMkQWRuohKWf338ubAeHNSnp+2xaBLO QVxMQsLgYL/O4ELfeQZh8khYwYDADLpxMGqMAd6NiFiXYSArZPJwa1WyH0FmztXvcZbp IFqIHQH4nWBmNlArxztLlAVhF3rChakAop+W0= 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=ZtP/qs71p3VGBR+2z2uAWf97wp47TqAKbCOV89Q0oV0=; b=cbRVs8K1f3uUdQtg1EnzqRxPIT50a3fa9sWgtm5Ml2UMuyolsjkDcN4na9eOvcYD6q 71oo74ldAIjSmHqC0dktlzoDTjIqTEPjGx8t6NN3dXQkBN6nZ1dLRFyCvDdGsm6Sqlso soc7LJGxzesrBv/8acwMOr9WQcslCziS/9o8TaToGSIpmSysIyTw+QfmXxtzhK9h+YvG 0cYigHQmHpcnju96IZuTkJICLQYXXqfeYmb6Ihg/HBX07175vfWkwuReNOGa8RBnBMQK /qnbaB/USLQBoJ9yxoS0RIzGBh5iZU9KlcrrTqTVc+/ApwqzuNiaDtCDi4pRC1GTUKgB qQlw== X-Gm-Message-State: AE9vXwNcYmwH1mXkvkNYxuD45ix8omlvMk7QtprMXnDy+BqFY0cg1PvPCkpGDx4F95gmuPpk X-Received: by 10.25.41.142 with SMTP id p136mr9442910lfp.32.1474272617323; Mon, 19 Sep 2016 01:10:17 -0700 (PDT) Received: from linuslaptop.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u131sm4471343lja.23.2016.09.19.01.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Sep 2016 01:10:15 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH] gpio: tc3589x: add .get_direction() and small cleanup Date: Mon, 19 Sep 2016 10:10:12 +0200 Message-Id: <1474272612-11987-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 adds a .get_direction() callback to the TC3589x and renames the function for setting single-ended mode to be more to the point. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tc3589x.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) -- 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-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 5baa45768ec5..537a4335ddec 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -84,9 +84,25 @@ static int tc3589x_gpio_direction_input(struct gpio_chip *chip, return tc3589x_set_bits(tc3589x, reg, BIT(pos), 0); } -static int tc3589x_gpio_single_ended(struct gpio_chip *chip, - unsigned offset, - enum single_ended_mode mode) +static int tc3589x_gpio_get_direction(struct gpio_chip *chip, + unsigned offset) +{ + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); + struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; + u8 reg = TC3589x_GPIODIR0 + offset / 8; + unsigned pos = offset % 8; + int ret; + + ret = tc3589x_reg_read(tc3589x, reg); + if (ret < 0) + return ret; + + return !!(ret & BIT(pos)); +} + +static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip, + unsigned offset, + enum single_ended_mode mode) { struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; @@ -127,11 +143,12 @@ static int tc3589x_gpio_single_ended(struct gpio_chip *chip, static const struct gpio_chip template_chip = { .label = "tc3589x", .owner = THIS_MODULE, - .direction_input = tc3589x_gpio_direction_input, .get = tc3589x_gpio_get, - .direction_output = tc3589x_gpio_direction_output, .set = tc3589x_gpio_set, - .set_single_ended = tc3589x_gpio_single_ended, + .direction_output = tc3589x_gpio_direction_output, + .direction_input = tc3589x_gpio_direction_input, + .get_direction = tc3589x_gpio_get_direction, + .set_single_ended = tc3589x_gpio_set_single_ended, .can_sleep = true, };