From patchwork Fri Mar 17 18:24:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 9631191 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 5803E60249 for ; Fri, 17 Mar 2017 18:32:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47F3C26E4F for ; Fri, 17 Mar 2017 18:32:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A6B328236; Fri, 17 Mar 2017 18:32:06 +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 C104326E4F for ; Fri, 17 Mar 2017 18:32:05 +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=T4nuHn/FRBBRRmW7AgqwFk74lSL3ShpYYazu0nZ6QYA=; b=kkKY+dbPm8e1LCvJdBZLSCYxdS rWTPohWJtBuw72gjz3+A1TNoNgwKgsPr8E6oc5PGanHURcxrpDQ6PMpqJvLWELz7rcFOyDWMiliH1 NSEQUJr9mMYbbCEuV3Qv67nDsGMbulLHHqF3kOa6DJR/LCztN3ULjKs2cfhRizPH1OAGIyC0Ng+q9 h15XNH90jg6kMIdTGrxXgFXVwNZg4rMViyWS54rn9FtIajE3Hoigaupp4G388Mq+XYqsmM/GMfUqa G5W27PNXt87mB0LaCKBuzFJUB6zaWiYBx5iAIZVVtuv66IDft3IaG/du9qdyCNEgN1WP+pn/nqmaU GbREtzZQ==; 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 1cowfV-0004jc-HH; Fri, 17 Mar 2017 18:32:05 +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 1cowZ9-0000zW-Fo; Fri, 17 Mar 2017 18:25:35 +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=gHqRkRD9fWqnjfFtmEGjdlwg3t0/z+YccMwNBDLPN1M=; b=QQpuXF/H4JRb0AE7gEDrvD4SY3I684/buShBoXm7t5necw6A60CmDBToAV2mJzlPGswI8lOkV/iSNwgQjhZyg4tuFKwaCDvv15+0qUjUb1cHN441muv3Q+hoRqb+60v0jbCpUfXszgJMMhyfVafQRPpT7zx37kw9xfdf/pzgqYqsYmTq59aiNcGN2TOVBpOJBFEV9gN0IX1vY9zZ5AVaVSrIQ76oDvO8sPAeQf486XDfBfrSMyhISg552RYUf5eL10xZCEeEPKaA+pOaDFlemCU/fZ9OLHDopF/30/z25ZkZufip31YrGG0+/Cmpl75nM7luht0oFM8nYyYUHpmyHw==; 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 1cowYS-00042f-SA; Fri, 17 Mar 2017 18:24:48 +0000 From: John Keeping To: Heiko Stuebner Subject: [PATCH v3 3/4] pinctrl: rockchip: split out verification of mux settings Date: Fri, 17 Mar 2017 18:24:29 +0000 Message-Id: <20170317182430.27400-4-john@metanate.com> X-Mailer: git-send-email 2.12.0.377.gf910686b23.dirty In-Reply-To: <20170317182430.27400-1-john@metanate.com> References: <20170317182430.27400-1-john@metanate.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170317_112531_888856_83C7BE1D X-CRM114-Status: GOOD ( 11.41 ) 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-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-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 Tested-by: Heiko Stuebner --- v3: unchanged 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 63c868ebb94b..4cbe942ff205 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);