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: 13636 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 D429B23E2A for ; Tue, 18 Dec 2012 09:12:31 +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 2A249A19BBA for ; Tue, 18 Dec 2012 09:12:31 +0000 (UTC) Received: by mail-ia0-f170.google.com with SMTP id i1so325070iaa.1 for ; Tue, 18 Dec 2012 01:12:30 -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=Ls3xq41/fDgZqKBOfTs77h/UhgpqeWljp422WMI3VDMq+CLqLfocyvpLJjZHfiTiaz CvMKgN6PsgUcsPNjVBHmV120aS2f28bl3Asyx28ZumTSs9NsLUVLAhxjhgtcpNezOta8 Jpd/FDkQTTqLqHeHwaBp8748cAZFa2fvAKNXpyNBM7C3vP7gpg9SRAZcfwzyq7UQc4Rj 5LPV09wASe0hiI5WQeXmS/UzEKEXiMD6r9vZSZaRW4go3MpH2iscARMMUmfsVVrVPYrL 4YRQv2460sspaIyfJYOChhUJ/q0egbFdHirHCREssYp1QGL8RWl6cXV9eLJ2RstsmhuW LRxg== X-Received: by 10.50.36.164 with SMTP id r4mr1348099igj.57.1355821950551; Tue, 18 Dec 2012 01:12:30 -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 n20csp128356igt; Tue, 18 Dec 2012 01:12:29 -0800 (PST) X-Received: by 10.194.61.105 with SMTP id o9mr2711213wjr.8.1355821949222; Tue, 18 Dec 2012 01:12:29 -0800 (PST) Received: from mail-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by mx.google.com with ESMTPS id he2si12998378wib.2.2012.12.18.01.12.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 01:12:29 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.172 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=74.125.82.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.172 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-we0-f172.google.com with SMTP id r3so167528wey.3 for ; Tue, 18 Dec 2012 01:12:28 -0800 (PST) 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 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: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: ALoCoQk8PZSwZnVCssl6J28slA9WwFS9mTNyv991KnAZZzMJ/gcqNdEeH/uMRfZePNXGqTu8Pk9T 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; } /*