From patchwork Tue Dec 18 09:12:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 1891011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 8A5A03FC81 for ; Tue, 18 Dec 2012 09:15:46 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TktE3-0005T5-8c; Tue, 18 Dec 2012 09:12:35 +0000 Received: from mail-wg0-f51.google.com ([74.125.82.51]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TktDz-0005SU-Fx for linux-arm-kernel@lists.infradead.org; Tue, 18 Dec 2012 09:12:32 +0000 Received: by mail-wg0-f51.google.com with SMTP id gg4so162325wgb.6 for ; Tue, 18 Dec 2012 01:12:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=bASDenzFeQtXWValwndy7VHW5kUxmtrcmXmuaSD+pxw=; b=bc/bFZxtUuyy0tsJz98rPLtzWg5s/2T+4A+1D8LT+KXbeQzUXn72SfrRNHr9XMUEyJ PqVsO/1ZbyL1aaPv7lLAriZ0QHlh9vfwddWwxT+o4RHBzmnfaIDgpAgJQfLw/D70TOrw Ona/vDFLuZCb9pUTZvEurLoHStBuvKHpfVA70M/uwctJ7oZ0zXuHULJENsBjQDTVQPEk VJvfGz0kiW2g6/gbl1fuf1uMcpmgCHo5MIRrBiSLz8nJFaBIxyjIq5liMGDOMTesvfZ2 LdIaWshsX+xzm1XxnikpcCNjLjxpEeugh4Kv/g9CqidEZITgZ3GX8/KmTtJ+r4xRWNn4 PJVw== X-Received: by 10.194.88.166 with SMTP id bh6mr2584932wjb.37.1355821948477; Tue, 18 Dec 2012 01:12:28 -0800 (PST) Received: from localhost ([2a01:2003:1:1d66:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id dw4sm1712438wib.1.2012.12.18.01.12.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 01:12:28 -0800 (PST) From: Fabio Baltieri To: Linus Walleij , Srinidhi Kasagar Subject: [PATCH 1/2] pinctrl: nomadik: return if prcm_base is NULL Date: Tue, 18 Dec 2012 10:12:11 +0100 Message-Id: <1355821932-15799-1-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.7.12.1 X-Gm-Message-State: ALoCoQn3bCxPQHG/J5pG4chQ1RUNtzas18YFHKUMvLu/dx9uTWxIE+7Y4rUMNZ4JhWRrZHQka43L X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121218_041231_693678_4C981201 X-CRM114-Status: GOOD ( 17.21 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.51 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fabio Baltieri , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds a check for npct->prcm_base to make sure that the address is not NULL before using it, as the driver was made capable of loading even without a proper memory resource in: f1671bf pinctrl/nomadik: make independent of prcmu driver Also, refuses to probe without prcm_base on anything else than nomadik. This solves the following crash, introduced during the merge window when booting on U8500 with device tree: pinctrl-nomadik pinctrl-db8500: No PRCM base, assume no ALT-Cx control is available Unable to handle kernel NULL pointer dereference at virtual address 00000138 pgd = c0004000 [00000138] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 Not tainted (3.7.0-02892-g1ebaf4f #631) PC is at nmk_pmx_enable+0x1bc/0x4d0 LR is at clk_disable+0x40/0x44 [snip] [] (nmk_pmx_enable+0x1bc/0x4d0) from [] (pinmux_enable_setting+0x12c/0x1ec) [] (pinmux_enable_setting+0x12c/0x1ec) from [] (pinctrl_select_state_locked+0xfc/0x134) [] (pinctrl_select_state_locked+0xfc/0x134) from [] (pinctrl_register+0x26c/0x43c) [] (pinctrl_register+0x26c/0x43c) from [] (nmk_pinctrl_probe+0x114/0x238) [] (nmk_pinctrl_probe+0x114/0x238) from [] (platform_drv_probe+0x28/0x2c) [] (platform_drv_probe+0x28/0x2c) from [] (driver_probe_device+0x84/0x21c) [] (driver_probe_device+0x84/0x21c) from [] (__device_attach+0x50/0x54) [] (__device_attach+0x50/0x54) from [] (bus_for_each_drv+0x54/0x9c) [] (bus_for_each_drv+0x54/0x9c) from [] (device_attach+0x84/0x9c) [] (device_attach+0x84/0x9c) from [] (bus_probe_device+0x94/0xb8) [] (bus_probe_device+0x94/0xb8) from [] (device_add+0x4f0/0x5bc) [] (device_add+0x4f0/0x5bc) from [] (of_device_add+0x40/0x48) [] (of_device_add+0x40/0x48) from [] (of_platform_device_create_pdata+0x68/0x98) [] (of_platform_device_create_pdata+0x68/0x98) from [] (of_platform_bus_create+0xe4/0x260) [] (of_platform_bus_create+0xe4/0x260) from [] (of_platform_bus_create+0x130/0x260) [] (of_platform_bus_create+0x130/0x260) from [] (of_platform_populate+0x6c/0xac) [] (of_platform_populate+0x6c/0xac) from [] (u8500_init_machine+0x78/0x140) [] (u8500_init_machine+0x78/0x140) from [] (customize_machine+0x24/0x30) [] (customize_machine+0x24/0x30) from [] (do_one_initcall+0x130/0x1b0) [] (do_one_initcall+0x130/0x1b0) from [] (kernel_init+0x138/0x2e8) [] (kernel_init+0x138/0x2e8) from [] (ret_from_fork+0x14/0x20) Code: 0a00001b e19400b2 e59a200c e0822000 (e592c000) ---[ end trace 1b75b31a2719ed1c ]--- note: swapper/0[1] exited with preempt_count 1 Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b Reviewed-by: Linus Walleij Signed-off-by: Fabio Baltieri --- drivers/pinctrl/pinctrl-nomadik.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index ef66f98..015b093 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c @@ -259,6 +259,9 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct, const struct prcm_gpiocr_altcx_pin_desc *pin_desc; const u16 *gpiocr_regs; + if (!npct->prcm_base) + return; + if (alt_num > PRCM_IDX_GPIOCR_ALTC_MAX) { dev_err(npct->dev, "PRCM GPIOCR: alternate-C%i is invalid\n", alt_num); @@ -682,6 +685,9 @@ static int nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpio) const struct prcm_gpiocr_altcx_pin_desc *pin_desc; const u16 *gpiocr_regs; + if (!npct->prcm_base) + return NMK_GPIO_ALT_C; + for (i = 0; i < npct->soc->npins_altcx; i++) { if (npct->soc->altcx_pins[i].pin == gpio) break; @@ -1887,9 +1893,12 @@ static int __devinit nmk_pinctrl_probe(struct platform_device *pdev) "failed to ioremap PRCM registers\n"); return -ENOMEM; } - } else { + } else if (version == PINCTRL_NMK_STN8815) { dev_info(&pdev->dev, "No PRCM base, assume no ALT-Cx control is available\n"); + } else { + dev_err(&pdev->dev, "missing PRCM base address\n"); + return -EINVAL; } /*