From patchwork Thu Oct 15 05:10:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J, KEERTHY" X-Patchwork-Id: 7401531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DBDB99F302 for ; Thu, 15 Oct 2015 05:13:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0040E209D8 for ; Thu, 15 Oct 2015 05:13:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22207209D4 for ; Thu, 15 Oct 2015 05:13:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmaoP-00064l-Ry; Thu, 15 Oct 2015 05:10:45 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmaoI-00062j-61 for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2015 05:10:39 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t9F5ADIv009442; Thu, 15 Oct 2015 00:10:13 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9F5ADLe005707; Thu, 15 Oct 2015 00:10:13 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Thu, 15 Oct 2015 00:10:13 -0500 Received: from ula0393675.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9F5A9xq017215; Thu, 15 Oct 2015 00:10:11 -0500 From: Keerthy To: Subject: [PATCH v2 1/3] ARM: OMAP2: DRA7: Modify optimize string comparisons in soc_is calls Date: Thu, 15 Oct 2015 10:40:06 +0530 Message-ID: <1444885808-6306-2-git-send-email-j-keerthy@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444885808-6306-1-git-send-email-j-keerthy@ti.com> References: <1444885808-6306-1-git-send-email-j-keerthy@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151014_221038_317201_F77FA22A X-CRM114-Status: GOOD ( 11.02 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: j-keerthy@ti.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently everytime soc_is calls are made, firstly device tree nodes are parsed and then string comparisons are made to determine the soc version. Optimizing it to be done one time and store the result. Use the stored value in all the subsequent checks for soc_is calls. Signed-off-by: Keerthy --- Changes in v2: * Rebased to latest 4.3-rc5 arch/arm/mach-omap2/id.c | 17 +++++++++++++++++ arch/arm/mach-omap2/soc.h | 15 ++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index 8a2ae82..4f497cc 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -40,6 +40,7 @@ #define OMAP_SOC_MAX_NAME_LENGTH 16 static unsigned int omap_revision; +static unsigned long soc_ids; static char soc_name[OMAP_SOC_MAX_NAME_LENGTH]; static char soc_rev[OMAP_SOC_MAX_NAME_LENGTH]; u32 omap_features; @@ -50,6 +51,21 @@ unsigned int omap_rev(void) } EXPORT_SYMBOL(omap_rev); +void init_dra_soc_id(void) +{ + if (of_machine_is_compatible("ti,dra7")) + soc_ids |= DRA7XX; + if (of_machine_is_compatible("ti,dra74")) + soc_ids |= DRA74X; + if (of_machine_is_compatible("ti,dra72")) + soc_ids |= DRA72X; +} + +int check_soc_version(unsigned long id) +{ + return soc_ids & id; +} + int omap_type(void) { static u32 val = OMAP2_DEVICETYPE_MASK; @@ -643,6 +659,7 @@ void __init dra7xxx_check_revision(void) u16 hawkeye; u8 rev; + init_dra_soc_id(); idcode = read_tap_reg(OMAP_TAP_IDCODE); hawkeye = (idcode >> 12) & 0xffff; rev = (idcode >> 28) & 0xff; diff --git a/arch/arm/mach-omap2/soc.h b/arch/arm/mach-omap2/soc.h index fbb3a16..06d8c96 100644 --- a/arch/arm/mach-omap2/soc.h +++ b/arch/arm/mach-omap2/soc.h @@ -125,6 +125,15 @@ #define OMAP2_DEVICE_TYPE_GP 3 #define OMAP2_DEVICE_TYPE_BAD 4 +/* + * SoC types + */ + +#define DRA7XX BIT(0) +#define DRA74X BIT(1) +#define DRA72X BIT(2) + +int check_soc_version(unsigned long id); int omap_type(void); /* @@ -466,9 +475,9 @@ IS_OMAP_TYPE(3430, 0x3430) #undef soc_is_dra7xx #undef soc_is_dra74x #undef soc_is_dra72x -#define soc_is_dra7xx() (of_machine_is_compatible("ti,dra7")) -#define soc_is_dra74x() (of_machine_is_compatible("ti,dra74")) -#define soc_is_dra72x() (of_machine_is_compatible("ti,dra72")) +#define soc_is_dra7xx() check_soc_version(DRA7XX) +#define soc_is_dra74x() check_soc_version(DRA74X) +#define soc_is_dra72x() check_soc_version(DRA72X) #endif /* Various silicon revisions for omap2 */