From patchwork Tue Feb 19 20:48:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158737 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4117535jaa; Tue, 19 Feb 2019 12:50:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IbHo5/z7Nh3ZjfsNaY0O6JyVewuhlq4hMrwIn8AkK4jGDmxs3Acy+A6gjpjhfKFnbuSY+SE X-Received: by 2002:aa7:81c5:: with SMTP id c5mr32064250pfn.217.1550609457214; Tue, 19 Feb 2019 12:50:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550609457; cv=none; d=google.com; s=arc-20160816; b=uPGIR1bBKLKw5EF0rOo4fLWbsTUXaskbyMrY5oAAjJA7fmMcCT5g+2ngMQhloYj4R6 XwN2yQmVE+ZUvMq5r8Xs1VUOMv5KJGcC2lKEHsuBZlwy84t+EA6/Cjvcw7QbnosIXXFk xPV4KfHE3O/9YHuiluaBQV8arLp9c9qWpf8AFDfYVBhYSypw8EGPTverBmictyn/mjEO imrMuHchF7Uxr4WK4KvQ89WLDRjpHNy+u6oG4tdK7ZvT3ikrs8m9LCJvU7TuXL0KUNeJ vRU4V4jIBJrebbZWNVJf6bC91szSJ36SudOYBt5xfv+Fq3vWYSCYjBSkF88sJmnTMSpm Y3eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7q2voTHriIaqc49hSut/SyZh+lI8p5uZjIoGPDoCDRE=; b=m/X1W7fz6mmHiRhxSAVrir+Hg71EYL9TDc3hqJDWKIOitkkKNiZ23hMEynsSBbMAFb G0psJYwdDhHYbweFunZHCmM2JObXhhZo9JgKhPRPeAAKm6kLG2Cc2LBqb4XIbIyCXPMg MJ65Ddtiz7VmSeLRGle5Oysma7fcHWqRmHAeW2+kfs7Q4m0udf8VoVolOvUl9vWSDH/Y qS2erjTfWgUrCGTi//z8g799idkIO7pFEXC2qeNXJQySKoUbeGJcW3CsasYg6BCQa3eT A75M/7hhnbQ6l5l9w/aI1pc/4FnQe4Smi61eJWZA0Osa7INgJQVPXH6b+8C1rF9Jnryz cmmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=STDflg8o; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si16753641pgl.350.2019.02.19.12.50.56; Tue, 19 Feb 2019 12:50:57 -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=pass header.i=@linaro.org header.s=google header.b=STDflg8o; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbfBSUu4 (ORCPT + 5 others); Tue, 19 Feb 2019 15:50:56 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41128 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726289AbfBSUu4 (ORCPT ); Tue, 19 Feb 2019 15:50:56 -0500 Received: by mail-lf1-f66.google.com with SMTP id e27so15858316lfj.8 for ; Tue, 19 Feb 2019 12:50:55 -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:mime-version :content-transfer-encoding; bh=7q2voTHriIaqc49hSut/SyZh+lI8p5uZjIoGPDoCDRE=; b=STDflg8omYcN0w2BwqQDy+28gXDVvqe+6QJavln+6oDmoK7YswUe1jJvA4YFma6BIc yNxmkt1M4ASDBPykNlRC+ykr3Mo4yrdLPMldGoTMJHRtwZN20b67Us8DjXdZSk3TZFZ2 dkZ1FqJS4ivVNQ2wy7IhODKXEHP7cB4NOPsbTefAGdf5zZ7gZWUbWp8p0YbSvaV8wDgr bh0zQvcOvAukM7xkL7Jp6JxQEKT7tgfp2ABk7/KzarD7WcqIqhkfyPgLegj/rpvG33NT 5srgXBUl2VdxIm+NF3qmLKQGMuipYMbe71pItBVV29AaohOwPDEP7CEV14vJcya++MCr hMoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7q2voTHriIaqc49hSut/SyZh+lI8p5uZjIoGPDoCDRE=; b=R+R7KVi1Y6hyjTfZpOvxw/8qdJaQiBel74qJWSv2w5R584OtMZVts0186aQ0jkJFjk arfY2cmxTNgND7jKmlCBMAQNAZ53oqE5LVptQ6vnwQbbidyOMzqggafIRanaBs157Bh0 CkJumoOoBr4QAWSDSZA5xUoMKyPUMjeOtyF0P6RvvgqCAY+vaUZtBeRjajIA2Nn8DGbP ArMMTQrBB1FDOQRJN6TrQsx0rKxnLIrAkNvJeLuzWKUsOua7r8+S62HmACYmoPlvox2T yNmq2CMEPY68Pl9DsMyiCcGhhH3t8C2ZvQE04GOnWHO5Dr9C7s66+64HlakXIoY+DhEx VvJg== X-Gm-Message-State: AHQUAuaMtze83GqtN1xYMUDeBllNOq0Wvu01M0heDWu3R+WK4mfEQh5m eHc//xcKD28yx90Asev+aacqYKY9V6M= X-Received: by 2002:a19:3f09:: with SMTP id m9mr19415283lfa.16.1550609453557; Tue, 19 Feb 2019 12:50:53 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id b14sm528901lji.25.2019.02.19.12.50.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Feb 2019 12:50:49 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij , Thierry Reding , Stefan Agner , Dmitry Osipenko , Jon Hunter Subject: [PATCH] gpio: tegra: Fix offset of pinctrl calls Date: Tue, 19 Feb 2019 21:48:43 +0100 Message-Id: <20190219204843.20352-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This patch hunk is a lightly modified version of a diff found in a Tegra code dump from a product tree. It makes a lot of sense because this is what most drivers do. Cc: Thierry Reding Cc: Stefan Agner Cc: Dmitry Osipenko Cc: Jon Hunter Signed-off-by: Linus Walleij --- drivers/gpio/gpio-tegra.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) -- 2.20.1 Reviewed-by: Dmitry Osipenko @@ -141,14 +142,14 @@ static void tegra_gpio_disable(struct tegra_gpio_info *tgi, unsigned int gpio) static int tegra_gpio_request(struct gpio_chip *chip, unsigned int offset) { - return pinctrl_gpio_request(offset); + return pinctrl_gpio_request(chip->base + offset); } static void tegra_gpio_free(struct gpio_chip *chip, unsigned int offset) { struct tegra_gpio_info *tgi = gpiochip_get_data(chip); - pinctrl_gpio_free(offset); + pinctrl_gpio_free(chip->base + offset); tegra_gpio_disable(tgi, offset); } @@ -176,10 +177,18 @@ static int tegra_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { struct tegra_gpio_info *tgi = gpiochip_get_data(chip); + int ret; tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, offset), offset, 0); tegra_gpio_enable(tgi, offset); - return 0; + + ret = pinctrl_gpio_direction_input(chip->base + offset); + if (ret < 0) + dev_err(tgi->dev, + "Failed to set pinctrl input direction of GPIO %d: %d", + chip->base + offset, ret); + + return ret; } static int tegra_gpio_direction_output(struct gpio_chip *chip, @@ -187,11 +196,19 @@ static int tegra_gpio_direction_output(struct gpio_chip *chip, int value) { struct tegra_gpio_info *tgi = gpiochip_get_data(chip); + int ret; tegra_gpio_set(chip, offset, value); tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, offset), offset, 1); tegra_gpio_enable(tgi, offset); - return 0; + + ret = pinctrl_gpio_direction_output(chip->base + offset); + if (ret < 0) + dev_err(tgi->dev, + "Failed to set pinctrl output direction of GPIO %d: %d", + chip->base + offset, ret); + + return ret; } static int tegra_gpio_get_direction(struct gpio_chip *chip,