Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935371AbcKKVjR (ORCPT ); Fri, 11 Nov 2016 16:39:17 -0500 Received: from smtprelay4.synopsys.com ([198.182.47.9]:49719 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934016AbcKKVjO (ORCPT ); Fri, 11 Nov 2016 16:39:14 -0500 From: Vineet Gupta To: Daniel Lezcano CC: Noam Camus , , , , , Vineet Gupta Subject: [PATCH v4 1/8] ARC: timer: gfrc, rtc: deuglify big endian code Date: Fri, 11 Nov 2016 13:38:45 -0800 Message-ID: <1478900332-24279-2-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478900332-24279-1-git-send-email-vgupta@synopsys.com> References: <1478900332-24279-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.12.196.111] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2113 Lines: 78 A standard "C" shift will be handled appropriately by the compiler depending on the endian for the build. 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 c10390d1ddb6..8d66bb446209 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 = { -- 2.7.4