From patchwork Wed Mar 15 17:46:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 9626297 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 BDAC76048C for ; Wed, 15 Mar 2017 17:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B22E228660 for ; Wed, 15 Mar 2017 17:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A429D28666; Wed, 15 Mar 2017 17:47:39 +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=ham 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 07B9F28660 for ; Wed, 15 Mar 2017 17:47:39 +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=lnxaFdN84VjgDVQB0h7FMabj5Extum0lsxgxLF6j+aE=; b=etpyvCgL2ErDXWLrcayD0nE93d NBneGRzHIUr8d3006qOLxgk1ULIQgS99Pr5ezTS9jR2hNfFAm9ZDRZ++pZZ7Gf2Y+wCrob4GKct6S lNlQGfF9Nfd3BwebaeQormod0JWAqZwLyXBLUFnLAAe8BnFCSBvYQFLnZ2A3fNEolw40pUnTuL+RI 211HGASEVTlRxA7lNL55aLDGouOuB/US6BEX4NfsrLzuDwTvs7cQ52IDZF9RRyZjWQSFzgte/EGLb KnWFn1ugQW1ovF864Dqd3nu3YVipR+S33dV79+BYrVnZPCat5iNjjunLLhp1m13DXJ+Mdeggn0lh4 nqZ6i3mA==; 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 1coD1O-0002sM-HS; Wed, 15 Mar 2017 17:47:38 +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 1coD1K-0002oJ-L0; Wed, 15 Mar 2017 17:47:36 +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=3uLJDcnFkOaq5o/URJnWKSQ1Vc7pvVDwKTzZTpBcTHg=; b=Q9JNOSpBszHWYI/qB6U/mqANJjxAu+yELrhKo2jUM/nzDCLJ53tdzbe+xOhbYMEEQpEQR1nFQZQ9UtomNd2UDNbMwaIdJrVcAWwva8odwA7IPL3HLYJDZ5c1KQSMafjt6K1qqHuzz1NwIzoK+hydDMa6XAqZP8nxv6m7RyoYKh7b/t3FiNdxi6o3I9doZQHI6kfyubdKOliYl+A8bg+5ces5vdLTr7pLDJ+2uqJo8L4sfcK8Bv9dUFrGuimOfcf3jqgYX/4fUca3hlKw7dgR08JT8shTWEa2kUy+qpt/XpNwjT0ye/3b3GufpQgQvfv5Bqa7jBQwex12DwcjS6qbmw==; 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 1coD0t-00055n-5G; Wed, 15 Mar 2017 17:47:07 +0000 From: John Keeping To: Heiko Stuebner Subject: [PATCH v2 3/4] pinctrl: rockchip: split out verification of mux settings Date: Wed, 15 Mar 2017 17:46:53 +0000 Message-Id: <20170315174654.15128-4-john@metanate.com> X-Mailer: git-send-email 2.12.0.377.gf910686b23.dirty In-Reply-To: <20170315174654.15128-1-john@metanate.com> References: <20170315174654.15128-1-john@metanate.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170315_104734_919952_CB8FEBDE X-CRM114-Status: GOOD ( 11.52 ) 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: linux-gpio@vger.kernel.org, Linus Walleij , Julia Cartwright , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, John Keeping , linux-arm-kernel@lists.infradead.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 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 Tested-by: Heiko Stuebner --- v2: unchanged --- 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 8c1cae6d78d7..426f5ea57b16 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -632,6 +632,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. * @@ -655,23 +680,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);