Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp344385pxk; Thu, 1 Oct 2020 04:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3tzAW9eG3VY8vVhObqMZf4DBJYg+WllUbku0TpbHyxou8EhmTLLgSghOVwGf62pGb1Lzp X-Received: by 2002:a50:fd10:: with SMTP id i16mr7813614eds.54.1601550183819; Thu, 01 Oct 2020 04:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601550183; cv=none; d=google.com; s=arc-20160816; b=EWcePXaWSwj+8/0zb6yQKbPKOnqfEOWZSnl9sCqWltN97/w091nBOVgnwVM4hdl9Q+ srA9q5lK7InxjTxgxo1GPbXxsiDflGZNJq4kj0yNkyymICM+laUaihB9YVLIC9A8eomz DKIh0n5e23hY6Q4mVLcyA6jlmD9G0FT3qVO/X3aiXDV8Uhfsz62hOXnsXOGcT+BGvvHK eNI1fPklAPPXkdggcpHB6vPa7NBRq71e4XRsuCGHXugfCPgZTSVnjYZjlawqvt1yQFAr SGl2tWHqhkof8/QthLrvMz+w9nwbal2rOkVNy+z64EfHoRTSF1ONSBYYsr6EelzDzAgR xoDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=kI1uRHdzKBS/kaggEl5HcO7aMau8ApYTM5nNSFcp9sc=; b=OprFauo6SCThD+4hjarD4emRSzqm8Lh2hN0wLrY0NSCUu66z/tFDQ7q+sFUHI1XIW7 ON9ulVhFZm0PsQ4QQyvkD4SZftWYJ/eSOP/m8Q8oEt3z3EYOdC38OKmIIobzm3wiQoC2 8Qtorod1zbhSb7jXGZwEhLzVUFt7/9W1FQo91esuzzs+2zSIRwfQHOPClctupgV4q9T0 HAZaSHE3HNe2qyJd2l5ErOAKfZfLktop192nWY1oV5rn9DGJDySplBd3Mi+oQXC6rwhV MSje9TjdqxvMOn/oMW7+CrXAZpwVogdoeJzLZBS9G86MccAbjG+h9mNoY1JPVsvIVKzH NbEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si3243499eje.376.2020.10.01.04.02.39; Thu, 01 Oct 2020 04:03:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732230AbgJAK7a (ORCPT + 99 others); Thu, 1 Oct 2020 06:59:30 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:25502 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732020AbgJAK70 (ORCPT ); Thu, 1 Oct 2020 06:59:26 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4C299h13Mwz9vCyB; Thu, 1 Oct 2020 12:59:20 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Co65YBxgPr1k; Thu, 1 Oct 2020 12:59:20 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4C299g6XMPz9vCy8; Thu, 1 Oct 2020 12:59:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 350968B96E; Thu, 1 Oct 2020 12:59:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id PG5kqvtdEvLr; Thu, 1 Oct 2020 12:59:21 +0200 (CEST) Received: from po17688vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2BAE18B903; Thu, 1 Oct 2020 12:59:20 +0200 (CEST) Received: by po17688vm.idsi0.si.c-s.fr (Postfix, from userid 0) id EF92D65ED7; Thu, 1 Oct 2020 10:59:19 +0000 (UTC) Message-Id: <3c9a6eb0fc040868ac59be66f338d08fd017668d.1601549945.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH] powerpc/time: Remove ifdef in get_dec() and set_dec() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 1 Oct 2020 10:59:19 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move SPRN_PIT definition in reg.h. This allows to remove ifdef in get_dec() and set_dec() and makes them more readable. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/reg.h | 2 ++ arch/powerpc/include/asm/reg_booke.h | 1 - arch/powerpc/include/asm/time.h | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index d25c357a873c..788058af1d44 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -521,6 +521,8 @@ #define SPRN_TSCR 0x399 /* Thread Switch Control Register */ #define SPRN_DEC 0x016 /* Decrement Register */ +#define SPRN_PIT 0x3DB /* Programmable Interval Timer (40x/BOOKE) */ + #define SPRN_DER 0x095 /* Debug Enable Register */ #define DER_RSTE 0x40000000 /* Reset Interrupt */ #define DER_CHSTPE 0x20000000 /* Check Stop */ diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h index ff30f1076162..29a948e0c0f2 100644 --- a/arch/powerpc/include/asm/reg_booke.h +++ b/arch/powerpc/include/asm/reg_booke.h @@ -174,7 +174,6 @@ #define SPRN_L1CSR1 0x3F3 /* L1 Cache Control and Status Register 1 */ #define SPRN_MMUCSR0 0x3F4 /* MMU Control and Status Register 0 */ #define SPRN_MMUCFG 0x3F7 /* MMU Configuration Register */ -#define SPRN_PIT 0x3DB /* Programmable Interval Timer */ #define SPRN_BUCSR 0x3F5 /* Branch Unit Control and Status */ #define SPRN_L2CSR0 0x3F9 /* L2 Data Cache Control and Status Register 0 */ #define SPRN_L2CSR1 0x3FA /* L2 Data Cache Control and Status Register 1 */ diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 6c663a382a75..a80abf64c8a5 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -126,11 +126,10 @@ static inline void set_tb(unsigned int upper, unsigned int lower) */ static inline u64 get_dec(void) { -#if defined(CONFIG_40x) - return (mfspr(SPRN_PIT)); -#else - return (mfspr(SPRN_DEC)); -#endif + if (IS_ENABLED(CONFIG_40x)) + return mfspr(SPRN_PIT); + + return mfspr(SPRN_DEC); } /* @@ -140,14 +139,12 @@ static inline u64 get_dec(void) */ static inline void set_dec(u64 val) { -#if defined(CONFIG_40x) - mtspr(SPRN_PIT, (u32) val); -#else -#ifndef CONFIG_BOOKE - --val; -#endif - mtspr(SPRN_DEC, val); -#endif /* not 40x */ + if (IS_ENABLED(CONFIG_40x)) + mtspr(SPRN_PIT, (u32)val); + else if (IS_ENABLED(CONFIG_BOOKE)) + mtspr(SPRN_DEC, val); + else + mtspr(SPRN_DEC, val - 1); } static inline unsigned long tb_ticks_since(unsigned long tstamp) -- 2.25.0