From patchwork Tue Dec 18 09:02: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: 13634 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6EB8623E2A for ; Tue, 18 Dec 2012 09:02:22 +0000 (UTC) Received: from mail-ia0-f170.google.com (mail-ia0-f170.google.com [209.85.210.170]) by fiordland.canonical.com (Postfix) with ESMTP id E4D3BA183F3 for ; Tue, 18 Dec 2012 09:02:21 +0000 (UTC) Received: by mail-ia0-f170.google.com with SMTP id i1so316585iaa.15 for ; Tue, 18 Dec 2012 01:02:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=bASDenzFeQtXWValwndy7VHW5kUxmtrcmXmuaSD+pxw=; b=RLQPW6Afh88PsLEOlgU79J7KIZjTnZPgwjyfwn8JLYUe1xuJQzvAaCPSRjTFa6uYek M4tQwNYMyJdkqwXmobBUoIn1XL9+ZbeR1iRo/9/9jUiWA90rKNSQepJNRTw2fYFAGSLr czG/CmjkyerxvcHb4QWYfb+5m48wzgnQIGURCX37/49edeY/zu8iHDum34ggxmVYMApA B83V1uSWHxuXvhKdq/BQRdIhhARebX0Qz4c8PBn8PiMU55HkXvWLECMYjApbnDe+BbCX +iv8aLcvL0OcpEQmFYevNjikqcmtuJOiIjwu+HD93trRk2bh1jY5dQz02tx1BmDt1oNx 8Rqg== X-Received: by 10.42.48.147 with SMTP id s19mr1232652icf.18.1355821341211; Tue, 18 Dec 2012 01:02:21 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp127934igt; Tue, 18 Dec 2012 01:02:20 -0800 (PST) X-Received: by 10.180.93.40 with SMTP id cr8mr2940857wib.15.1355821339505; Tue, 18 Dec 2012 01:02:19 -0800 (PST) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by mx.google.com with ESMTPS id d8si1308820wie.19.2012.12.18.01.02.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 01:02:19 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.177 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=209.85.212.177; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.177 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) smtp.mail=fabio.baltieri@linaro.org Received: by mail-wi0-f177.google.com with SMTP id hm2so187681wib.4 for ; Tue, 18 Dec 2012 01:02:18 -0800 (PST) X-Received: by 10.180.19.136 with SMTP id f8mr2563522wie.0.1355821338417; Tue, 18 Dec 2012 01:02:18 -0800 (PST) Received: from localhost ([2a01:2003:1:1d66:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id ew4sm1644435wid.11.2012.12.18.01.02.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 01:02:17 -0800 (PST) From: Fabio Baltieri To: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Fabio Baltieri Subject: [PATCH 1/2] pinctrl: nomadik: return if prcm_base is NULL Date: Tue, 18 Dec 2012 10:02:11 +0100 Message-Id: <1355821332-13900-1-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.7.12.1 X-Gm-Message-State: ALoCoQle1mdQFm9koxB3jYNiVVl5zkJ1R8b77VFO+3nbr+2bIFgQkhDq/S6JDV2xRi9IhGOBQroq 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; } /*