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: 10745387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 314056C5 for ; Mon, 31 Dec 2018 09:53:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B62728524 for ; Mon, 31 Dec 2018 09:53:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFA5228899; Mon, 31 Dec 2018 09:53:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 61DC028524 for ; Mon, 31 Dec 2018 09:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=NeekCVSPPj1qe5OhR97Yb/ZLykslFklVS9dwVNkgSAs=; b=OU8 IBa8aJPmQv0YKvn/wJrFfzaXBQox25TCNxNLjl2zMcpaNj/xJp7asva7cJSWiqa1AXhOf4KLZzaIc Y0ZKokPQt61x9rSL6pmDPmfFBuxhVq/OarD37TrNGK2wBoet9waHYYh2PSZGwkPbXUUs1JntL/kHg pSFXS66oP1oK9W17Owgxn8a1ZBUBO1hS6KWlEGtuT6z1tbansRWRD4TAOUgegtorYOA+9OhIvjc37 6X3zLGtSCgrT9er56IlkSajAQVTteZ1kgOXuuZs1wTOJz8g80VOOGUFwvot2JxTscWzZeLkeEmoVv Qnvbat4g50WBfSKXBQX+JaKvSyP49QA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gduG4-0001Df-3A; Mon, 31 Dec 2018 09:53:16 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gduG1-0001DL-0y for linux-arm-kernel@lists.infradead.org; Mon, 31 Dec 2018 09:53:14 +0000 Received: by mail-pl1-x643.google.com with SMTP id p8so12525012plo.2 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=nCZkSI98EJjf2VwIDLUGZDloz3T7LkywO7buwxo8qa41G3nrALvWxXeY/5AemnzynY vqagrxrJgOI3qxdJ+OzIyueo+4xOjlAJhgNyutrOmkfEyw7NYa3so+1OyVXPToEaOVGS o+klAj6FjFMGXBDDJewhWD3AC50250WJHjRP4ZfTM+R1Wq1STVoqL9jENP89roxA6doE QX5X+KBdb3Z+mhJILtXTDfjqdaxT8wjwhP9dvzL76mM5esLCu3hCOCeOps+wJ6IKYZL6 Ks+JrDfx5jtdcAthixaB3hagbF5FVbVYHUQGfOxQVf87ozpAF9JcGBP0M/0JYbpKN6so 20kw== X-Gm-Message-State: AJcUukddipnHp8tuEmJIsBb0O5XknyT5fUqtz6VUO2ndf1MclKPjAn9S yI2FaTex20z0agWE3Iozb34cKw== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181231_015313_134152_594A1499 X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , Axel Lin , Andrei Stefanescu , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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); } /**