From patchwork Thu Nov 3 21:31:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 691034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t8yrx24ZTz9tkH for ; Fri, 4 Nov 2016 08:33:53 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2Pdv-0001lE-Ny; Thu, 03 Nov 2016 21:33:51 +0000 Received: from smtprelay4.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2Pds-0001gp-Ju for linux-snps-arc@lists.infradead.org; Thu, 03 Nov 2016 21:33:49 +0000 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 778BD24E1F35; Thu, 3 Nov 2016 14:33:28 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 59207D27; Thu, 3 Nov 2016 14:33:28 -0700 (PDT) Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 42767D23; Thu, 3 Nov 2016 14:33:28 -0700 (PDT) Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 3 Nov 2016 14:31:59 -0700 Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.105) by IN01WEHTCA.internal.synopsys.com (10.144.199.103) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 4 Nov 2016 03:01:58 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.44) by IN01WEHTCB.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 4 Nov 2016 03:01:57 +0530 From: Vineet Gupta To: Daniel Lezcano Subject: [PATCH v2 02/10] ARC: timer: gfrc, rtc: deuglify big endian code Date: Thu, 3 Nov 2016 14:31:33 -0700 Message-ID: <1478208701-30923-3-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478208701-30923-1-git-send-email-vgupta@synopsys.com> References: <1478208701-30923-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 X-Originating-IP: [10.10.161.44] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161103_143348_814232_A384F8C8 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.3 (---) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-3.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.47.9 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Noam Camus , Vineet Gupta , Alexey.Brodkin@synopsys.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, linux-snps-arc@lists.infradead.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org A standard "C" shift will be handled appropriately by the compiler dependin gon the endian used fo rbuild. So we don't need the explicit distinction in code Signed-off-by: Vineet Gupta --- arch/arc/kernel/time.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/arch/arc/kernel/time.c b/arch/arc/kernel/time.c index 1a117b999c0c..71bcdc1f9bd0 100644 --- a/arch/arc/kernel/time.c +++ b/arch/arc/kernel/time.c @@ -86,26 +86,19 @@ static int noinline arc_get_timer_clk(struct device_node *node) static cycle_t arc_read_gfrc(struct clocksource *cs) { unsigned long flags; - union { -#ifdef CONFIG_CPU_BIG_ENDIAN - struct { u32 h, l; }; -#else - struct { u32 l, h; }; -#endif - cycle_t full; - } stamp; + u32 l, h; local_irq_save(flags); __mcip_cmd(CMD_GFRC_READ_LO, 0); - stamp.l = read_aux_reg(ARC_REG_MCIP_READBACK); + l = read_aux_reg(ARC_REG_MCIP_READBACK); __mcip_cmd(CMD_GFRC_READ_HI, 0); - stamp.h = read_aux_reg(ARC_REG_MCIP_READBACK); + h = read_aux_reg(ARC_REG_MCIP_READBACK); local_irq_restore(flags); - return stamp.full; + return (((cycle_t)h) << 32) | l; } static struct clocksource arc_counter_gfrc = { @@ -143,14 +136,7 @@ CLOCKSOURCE_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc); static cycle_t arc_read_rtc(struct clocksource *cs) { unsigned long status; - union { -#ifdef CONFIG_CPU_BIG_ENDIAN - struct { u32 high, low; }; -#else - struct { u32 low, high; }; -#endif - cycle_t full; - } stamp; + u32 l, h; /* * hardware has an internal state machine which tracks readout of @@ -159,12 +145,12 @@ static cycle_t arc_read_rtc(struct clocksource *cs) * - high increments after low has been read */ do { - stamp.low = read_aux_reg(AUX_RTC_LOW); - stamp.high = read_aux_reg(AUX_RTC_HIGH); + l = read_aux_reg(AUX_RTC_LOW); + h = read_aux_reg(AUX_RTC_HIGH); status = read_aux_reg(AUX_RTC_CTRL); } while (!(status & _BITUL(31))); - return stamp.full; + return (((cycle_t)h) << 32) | l; } static struct clocksource arc_counter_rtc = {