From patchwork Thu Mar 23 10:59:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 9640853 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 5B0AD602D6 for ; Thu, 23 Mar 2017 11:01:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AA4628516 for ; Thu, 23 Mar 2017 11:01:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F45128522; Thu, 23 Mar 2017 11:01:17 +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 C66F128516 for ; Thu, 23 Mar 2017 11:01:16 +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=cppV4AxpqceXly4FR4963wYwzlf+I0aOY4GLAo9BMdA=; b=G76zG1TX8Kjv84dc9fnLyjfrJ5 RtgwPvu7gQexXmW90Gd0LUQVv41CwdxyvssIHuJP29M08/zTNJKp18Z46f7Vl/i7wvTQ4EiQcIGy2 V9qWCaeNT0tXs1cpdlOD9LOUJLpg0MYAEbmcHs6ijGCEij81Ybp4/DKdeOl6WZP7AJi9m+x3s72Ff yObcvlQXboybXd5M1NVQkGsnIRlhMkEb7VhpXRvdYXuGXUDsvPnjoMxS7p88iJNKkxH1xzH52VDuU CBJwGpWBiX0f24d4Ql0Kpxac50wZpb6h6XDFXsE48Ep9Ti6OmFXq/EjDmJU1j/iuNAzLpHygj547R ohuk8BoA==; 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 1cr0UW-0002JO-92; Thu, 23 Mar 2017 11:01:16 +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 1cr0UF-0001zw-1O; Thu, 23 Mar 2017 11:01:01 +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=2xRxljkKT9EF/1uBrZtH/5Ptn1p51TvA1WaHJ9G5fo0=; b=gquWsd9z9JyoTRN4dF27PshEdBqllsbPQrv93ZyhcTP1Vawd8AXRaD4O868wv1DmxbI0yqvYp797r75ZNWbbzw9rNedEtB2CDlpkl15Fo2dapdfGn1hERsDTNfbdYDkt9781alJ/nMpt1AgtXafccIIOYm1HwcHTudkUeii5wUFiqjiKNPG1+eVXzrpJaaXGxjQoh0ytTHuhsdKiNg++GStaZYCZDzcBHQKdMfoBCfXE9OdmpsfQJqZmwlgq40Dc5Y5M1h42mjVryvQhTIwV7El8X9xZXUW44qkbqv0QMsmxR5SyCAHa+vQnmYVS8gecNgwTV/8uy60NtWZMvSHbTw==; Received: from static-84-9-133-23.vodafonexdsl.co.uk ([84.9.133.23] helo=localhost.localdomain) by shrek.metanate.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.83_RC2) (envelope-from ) id 1cr0TQ-0006IT-QM; Thu, 23 Mar 2017 11:00:09 +0000 From: John Keeping To: Linus Walleij Subject: [PATCH v4 3/4] pinctrl: rockchip: split out verification of mux settings Date: Thu, 23 Mar 2017 10:59:30 +0000 Message-Id: <20170323105931.10455-4-john@metanate.com> X-Mailer: git-send-email 2.12.0.377.gf910686b23.dirty In-Reply-To: <20170323105931.10455-1-john@metanate.com> References: <20170323105931.10455-1-john@metanate.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170323_040059_558950_CA8D9A90 X-CRM114-Status: GOOD ( 11.36 ) 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: Heiko Stuebner , linux-rockchip@lists.infradead.org, Julia Cartwright , 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 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 5d5a9c4c522d..9dd981ddbb17 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);