From patchwork Mon Dec 31 09:52:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 1019529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ingics.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ingics-com.20150623.gappssmtp.com header.i=@ingics-com.20150623.gappssmtp.com header.b="H43tLD3a"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43St0n480hz9s3l for ; Mon, 31 Dec 2018 20:53:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbeLaJxM (ORCPT ); Mon, 31 Dec 2018 04:53:12 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39631 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbeLaJxM (ORCPT ); Mon, 31 Dec 2018 04:53:12 -0500 Received: by mail-pl1-f194.google.com with SMTP id 101so12514819pld.6 for ; Mon, 31 Dec 2018 01:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=E4lMnMnBIfY3HmldaF9LT8SpHhqJ0ZTWep215r5bty4=; b=H43tLD3akUnMDiPIHdM/8yyCoN9RKIx9cUJBa2QiQmgY1FJR42vF1I4Qlvvh/CBUp/ SOUYt892KMRLythfw0sRsB4Tk/xnAV7jMCWVZ7AFYrU4bkuDKQ++c/rF36kKpRfbDhWK bhPplg2uMSMSM1WDktW0tl1y2JLMmyHenM/p0yB7HJ0XdPNsaFOQkW8Bo5DlHiyAoqGZ aLtu4reXIqCWYaICNXeBpxMqy/ZJ6I9nUaEjqyG0BsRP7nDhIilqwkG6pUkz90sb3RfF 5nt3r6qgbCcEvaD8J8PCRMN/McGTk8MgExpMNylp0/FZ2aOb4KC/jEUHr4yoUSTIiiF3 jJhA== 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; bh=E4lMnMnBIfY3HmldaF9LT8SpHhqJ0ZTWep215r5bty4=; b=Trnc+PPt0PZrRFARtZK1KvzDe4iEkiMb0AVt3Ki0i044/sRKYro5AYs5xqlVW/irVG KzDdBDMUB0j39VpI7k3KEiArYMXkRbq8VNgOfrRG4/m+WeJt3e4BvyvtN3Y8oLb/5kKz 1GDsMgYwnMhrJUs+MdmW1qxKLFQkSWU1fdWC+Zoj4eHVils+49vYlTLtgQC5FlD7rViJ UhSeofkb8UkUj/z36RMlt5/4ukUIp+UTRX51S84+QCXa353nH0QrGkYOfCBYFxT7mCRS KrKtzwbUHZm2VxZSCWUykjORbr62fRzGV6cs5yCASBvRJsr+KPipEUin3fY8D/dZW8Qg +3fA== X-Gm-Message-State: AJcUukd1ZsP5wf+A8U21CiVDS/MZeAGI5eQ20AywJ788+Ks6E5IIFAi/ hIaW5Rgmvin9mEiskkXBqeq4fw== X-Google-Smtp-Source: ALg8bN6P/DjEj8Le5ivKPp6RXe+SNBnWn5+R6UvMt/536XOMog4kfu6YeOIRZI/bkhT1USi7ODKIRw== X-Received: by 2002:a17:902:e002:: with SMTP id ca2mr37180135plb.103.1546249991522; Mon, 31 Dec 2018 01:53:11 -0800 (PST) Received: from localhost.localdomain (36-239-205-119.dynamic-ip.hinet.net. [36.239.205.119]) by smtp.gmail.com with ESMTPSA id h74sm92060141pfd.35.2018.12.31.01.53.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 01:53:10 -0800 (PST) From: Axel Lin To: Linus Walleij Cc: Andrei Stefanescu , Bartosz Golaszewski , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Axel Lin Subject: [RFT][PATCH] gpio: sama5d2-piobu: Set proper output level for direction_output Date: Mon, 31 Dec 2018 17:52:56 +0800 Message-Id: <20181231095256.14814-1-axel.lin@ingics.com> X-Mailer: git-send-email 2.17.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Set proper output level base on the argument of direction_output. Also remove sama5d2_piobu_set_direction() as there is only one caller now. Signed-off-by: Axel Lin --- Hi Andrei, I don't have this h/w, so please test if this patch works. BTW, I think this change is better than just adding sama5d2_piobu_set(chip, pin, value); call in sama5d2_piobu_direction_output becasue only write register once for setting direction_output. Thanks, Axel drivers/gpio/gpio-sama5d2-piobu.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c index 03a000659fa1..7d718557092e 100644 --- a/drivers/gpio/gpio-sama5d2-piobu.c +++ b/drivers/gpio/gpio-sama5d2-piobu.c @@ -108,16 +108,6 @@ static int sama5d2_piobu_read_value(struct gpio_chip *chip, unsigned int pin, return val & mask; } -/** - * sama5d2_piobu_set_direction() - mark pin as input or output - */ -static int sama5d2_piobu_set_direction(struct gpio_chip *chip, - unsigned int direction, - unsigned int pin) -{ - return sama5d2_piobu_write_value(chip, pin, PIOBU_DIRECTION, direction); -} - /** * sama5d2_piobu_get_direction() - gpiochip get_direction */ @@ -138,7 +128,7 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip, static int sama5d2_piobu_direction_input(struct gpio_chip *chip, unsigned int pin) { - return sama5d2_piobu_set_direction(chip, PIOBU_IN, pin); + return sama5d2_piobu_write_value(chip, pin, PIOBU_DIRECTION, PIOBU_IN); } /** @@ -147,7 +137,13 @@ static int sama5d2_piobu_direction_input(struct gpio_chip *chip, static int sama5d2_piobu_direction_output(struct gpio_chip *chip, unsigned int pin, int value) { - return sama5d2_piobu_set_direction(chip, PIOBU_OUT, pin); + unsigned int val = PIOBU_OUT; + + if (value) + val |= PIOBU_HIGH; + + return sama5d2_piobu_write_value(chip, pin, PIOBU_DIRECTION | PIOBU_SOD, + val); } /**