From patchwork Mon Mar 13 18:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 9621811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7DBCB604CC for ; Mon, 13 Mar 2017 18:40:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73469284EF for ; Mon, 13 Mar 2017 18:40:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6835428502; Mon, 13 Mar 2017 18:40:14 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 2C74E284EF for ; Mon, 13 Mar 2017 18:40:14 +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:References: In-Reply-To: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:List-Owner; bh=2FcaV4QT8mhONhAFaMYwhjYsTT02JwZZb6RWEnrUwkc=; b=ZL3bbt7UtFbhQCJAB0EF65uV5u Xw+V4ol1ZD4uA8wfIgp4rJQWuoeqznHMx1gc0rDU4RZGiceWrGYCQARowAOjYjIsY+jV3rVP4SgQH HGqg76bPNmqsA+wgXb1m29e9Y9U8Ipktoab+db5EFYR2gVecxrDoA2YTG+WHdSk6jRpX+uAJzXuJh lSVGoB3lSZ8xky0CzFYxFxCiFn9O8fuqvv1a4Djkbn8thJQH6D/2EhvZpVdRSmnEq2fw/F0Bt8sC9 FKgfhMebMOlceA3oqYvRxDD+nXg2sna/sqqGzlkxFiDkMBjJlKd0OvjvYFAzAxbtgac0sIkdAoboq ni/k2U3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cnUtA-0003ZS-It; Mon, 13 Mar 2017 18:40:12 +0000 Received: from dougal.metanate.com ([90.155.101.14] helo=metanate.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnUs3-0001j8-Pf; Mon, 13 Mar 2017 18:39:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=5mKDiNWEQ2h7+OrI20ebc7Pk0lXaVLp4Jr8SCMqnhfA=; b=TPi/dV8puhZES35BdhUSM3IYr8/qpmp/cBP6ZvgwlnRZlEZhENUDBGOfyH6OKIA9lC+JR4Hy14ylj+o46nqdI2+Ed0OkxTou/k1oYoM4UEQEmhrzL0cuIkfSp9glwrDK3hueX8ikUasSZKFCTL7kPtv18CLiJxtZJANIe6+utVNUGs8vN2GGHvlgywCoov1dUXEHdtPRrSEzcefpXYCvkV182RBviWasr3ZMsLDxVjj7xb+mp/oCwPCTut1qA6d+OHNWf3JbaMBjB3c1C4KpgRkizWMgx+AdcGi/hIaJuKA/2ckL+F8O+DybxYXIw7BPppvl5pshG3J6tLdyBdr7YA==; Received: from brian ([192.168.88.1] helo=leela.metanate.com) by shrek.metanate.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.83_RC2) (envelope-from ) id 1cnUrR-00060b-5p; Mon, 13 Mar 2017 18:38:25 +0000 From: John Keeping To: Heiko Stuebner Subject: [RFC PATCH 3/4] pinctrl: rockchip: split out verification of mux settings Date: Mon, 13 Mar 2017 18:38:12 +0000 Message-Id: <20170313183813.3582-4-john@metanate.com> X-Mailer: git-send-email 2.12.0.377.gf910686b23.dirty In-Reply-To: <20170313183813.3582-1-john@metanate.com> References: <20170313183813.3582-1-john@metanate.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170313_113904_092474_F686B065 X-CRM114-Status: GOOD ( 11.38 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, Linus Walleij , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Keeping , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We need to avoid calling regmap functions from irq handlers, so the next commit is going to move the call to rockchip_set_mux() into an irq_bus_sync_unlock handler. But we can't return an error from there so we still need to check the settings from rockchip_irq_set_type() and we will use this new rockchip_verify_mux() function from there. Signed-off-by: John Keeping Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 46 +++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 2f963aea64b2..52e70c4aef7c 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -629,6 +629,31 @@ static int rockchip_get_mux(struct rockchip_pin_bank *bank, int pin) return ((val >> bit) & mask); } +static int rockchip_verify_mux(struct rockchip_pin_bank *bank, + int pin, int mux) +{ + struct rockchip_pinctrl *info = bank->drvdata; + int iomux_num = (pin / 8); + + if (iomux_num > 3) + return -EINVAL; + + if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) { + dev_err(info->dev, "pin %d is unrouted\n", pin); + return -EINVAL; + } + + if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) { + if (mux != RK_FUNC_GPIO) { + dev_err(info->dev, + "pin %d only supports a gpio mux\n", pin); + return -ENOTSUPP; + } + } + + return 0; +} + /* * Set a new mux function for a pin. * @@ -652,23 +677,12 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) u8 bit; u32 data, rmask; - if (iomux_num > 3) - return -EINVAL; - - if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) { - dev_err(info->dev, "pin %d is unrouted\n", pin); - return -EINVAL; - } + ret = rockchip_verify_mux(bank, pin, mux); + if (ret < 0) + return ret; - if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) { - if (mux != RK_FUNC_GPIO) { - dev_err(info->dev, - "pin %d only supports a gpio mux\n", pin); - return -ENOTSUPP; - } else { - return 0; - } - } + if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) + return 0; dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n", bank->bank_num, pin, mux);