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: 1367341 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C6C7B3FCAE for ; Thu, 23 Aug 2012 13:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758889Ab2HWNyV (ORCPT ); Thu, 23 Aug 2012 09:54:21 -0400 Received: from na3sys009aog104.obsmtp.com ([74.125.149.73]:52550 "EHLO na3sys009aog104.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758579Ab2HWNyU (ORCPT ); Thu, 23 Aug 2012 09:54:20 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob104.postini.com ([74.125.148.12]) with SMTP ID DSNKUDY2DMFTii8EFLiTR3VepgwTVPkVsyvj@postini.com; Thu, 23 Aug 2012 06:54:20 PDT Received: by obbuo13 with SMTP id uo13so1813110obb.33 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=l7ZSUA+9G7FexdaHYUiinVjXV9fith8i1f+QJM6gN7Q9eZfd5hJpxjD5qM0MhJlHYh XIWlTtrcUO+iPTqQCX9+U51mxW5MHGPzkl25qkcZm93JVfNPPm2clpmXqlLkbELggs/u 56rJbwzf7r9A0irliJUO6E92ocC8MGnotOnBjW1NNuIKVVOyzvSoRrUZZKv33JUs6h7B FM8LL8rTpZGuxUiUcMqIYMub5xYy8PFHfrahmaDgA8Uz2v2NBAgIwNXQW5LDGVSHmBqK Sm8HUJIGJ7F4WcPXPxW+Tk8a+5zdAkGNsAnzZ/YH0oWe7sT0blLspnMVHyIaE6p15hUu TMeg== 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 Cc: Benoit Cousson , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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: ALoCoQkEELAGmS/NjMnBjOJ2bLhTFBtrjOHa6MkVWCBwRHFm0dkAr2HzEZtGZken3RQayE96a2wn Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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);