From patchwork Thu Aug 23 13:54:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1367361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 6E16DDF2AB for ; Thu, 23 Aug 2012 13:57:28 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T4Xre-0003yb-9h; Thu, 23 Aug 2012 13:54:26 +0000 Received: from na3sys009aog134.obsmtp.com ([74.125.149.83]) by merlin.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1T4Xra-0003y4-LN for linux-arm-kernel@lists.infradead.org; Thu, 23 Aug 2012 13:54:23 +0000 Received: from mail-ob0-f170.google.com ([209.85.214.170]) (using TLSv1) by na3sys009aob134.postini.com ([74.125.148.12]) with SMTP ID DSNKUDY2DMFTii8EFLiTR3VepgwTVPkVsyvj@postini.com; Thu, 23 Aug 2012 06:54:22 PDT Received: by obbwc18 with SMTP id wc18so1781615obb.29 for ; Thu, 23 Aug 2012 06:54:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=vsu3atd2DrifrqI4u/tWynaXqGKVICVjwoXxOzd/q9o=; b=bf2oJyGWwTClU4ped/0jqB5wuxpcEf2RNf4CRnrkB0odO63ZUOqUtjVzdkL/5lKr1U s4IeZR9OwzyavTNd+fLchqdAYVUAKwsAhz/WJkjbugbg4Q7nEojfYMfkPFzUtaki5Bv9 sXzbhjuC00xzzJPeiU7FG6V/GQx1/TsdyPN0S7AiMyGfWds3hVjZaVkdB+yNJNQYox4C PEzAghLI1viPMJPYexzcztXx00vKoYPfmMFRT1flTDETCssQqZW5VaNOYCjQRMP+9tsG Iwlh9HadFORnyw9buJO7a5vC7BnwKPrqI/ZPVIiHDg3QWJ7DlhTB1Pp80IDhSnw+nPK2 Iq6A== Received: by 10.60.13.9 with SMTP id d9mr1145484oec.84.1345730059752; Thu, 23 Aug 2012 06:54:19 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id x10sm4890379oeb.8.2012.08.23.06.54.16 (version=SSLv3 cipher=OTHER); Thu, 23 Aug 2012 06:54:18 -0700 (PDT) From: Peter Ujfalusi To: Tony Lindgren , Paul Walmsley , Kevin Hilman Subject: [PATCH] ARM: omap_hwmod: Fix up resource names when booted with devicetree Date: Thu, 23 Aug 2012 16:54:09 +0300 Message-Id: <1345730049-12675-1-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.8.6 X-Gm-Message-State: ALoCoQlj03BkeMfkAV1udFXSF/TEBx7F6t5bkZzztvFqR1HT1eJEq7eLnMjaXGkQat+kH2c+V+af X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.3 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.83 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 2.9 FILL_THIS_FORM_SHORT Fill in a short form with personal information Cc: linux-omap@vger.kernel.org, Benoit Cousson , 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 When booted with some resource will have their name set to NULL. This can cause later kernel crash since this is not expected by the platform code. When we boot without DT the devices are created with platform_device_add() which itself fixes up the missing resource names: if (r->name == NULL) r->name = dev_name(&pdev->dev); The of core also fixes up the resource names when taking the information from DT data - in __of_address_to_resource(): r->name = name ? name : dev->full_name; When we boot OMAP with devicetree: of will create the devices based on the DT data so the resource names are guarantied to be not NULL. Since we have the 'ti,hwmod' tag, we remove the of created resources from the device and re-create them based on hwmod data. If the hwmod data does not specify a name for a resource it will be NULL. This can cause kernel crash if the driver uses platform_get_resource_byname() to get any resource. Signed-off-by: Peter Ujfalusi --- arch/arm/plat-omap/omap_device.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index c490240..ff57b5a 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -370,6 +370,14 @@ static int omap_device_build_from_dt(struct platform_device *pdev) goto odbfd_exit1; } + /* Fix up missing resource names */ + for (i = 0; i < pdev->num_resources; i++) { + struct resource *r = &pdev->resource[i]; + + if (r->name == NULL) + r->name = dev_name(&pdev->dev); + } + if (of_get_property(node, "ti,no_idle_on_suspend", NULL)) omap_device_disable_idle_on_suspend(pdev);