From patchwork Thu Oct 20 20:11:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9387517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5CEB0607F0 for ; Thu, 20 Oct 2016 20:16:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B54629A79 for ; Thu, 20 Oct 2016 20:16:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4001829BE0; Thu, 20 Oct 2016 20:16:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id D1AE829A79 for ; Thu, 20 Oct 2016 20:16:19 +0000 (UTC) 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 1bxJjr-0004Y2-0x; Thu, 20 Oct 2016 20:14:55 +0000 Received: from galois.linutronix.de ([2a01:7a0:2:106d:700::1]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxJjj-0004Ww-J8 for linux-arm-kernel@lists.infradead.org; Thu, 20 Oct 2016 20:14:52 +0000 Received: from localhost ([127.0.0.1]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1bxJiA-0006VX-La; Thu, 20 Oct 2016 22:13:11 +0200 Date: Thu, 20 Oct 2016 22:11:52 +0200 (CEST) From: Thomas Gleixner To: Chen-Yu Tsai Subject: Re: [PATCH] Revert "clocksource/drivers/timer_sun5i: Replace code by clocksource_mmio_init" In-Reply-To: <20161018054918.26855-1-wens@csie.org> Message-ID: References: <20161018054918.26855-1-wens@csie.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161020_131447_903426_5C9C685B X-CRM114-Status: GOOD ( 14.79 ) 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: linux-sunxi@googlegroups.com, Daniel Lezcano , linux-kernel@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-Virus-Scanned: ClamAV using ClamSMTP On Tue, 18 Oct 2016, Chen-Yu Tsai wrote: > Revert the commit for now. clocksource_mmio_init can be made to pass back > a pointer, but the code churn and usage of an inner struct might not be > worth it. You can avoid the churn by making clocksurce_mmio_init() a wrapper around a new function, which takes a pointer to a struct clocksource_mmio as argument so you can hand in the structure you need: Something like the patch below should do the trick. Thanks, tglx 8<-------------------------------- --- a/drivers/clocksource/mmio.c +++ b/drivers/clocksource/mmio.c @@ -10,11 +10,6 @@ #include #include -struct clocksource_mmio { - void __iomem *reg; - struct clocksource clksrc; -}; - static inline struct clocksource_mmio *to_mmio_clksrc(struct clocksource *c) { return container_of(c, struct clocksource_mmio, clksrc); @@ -41,6 +36,27 @@ cycle_t clocksource_mmio_readw_down(stru } /** + * FIXME: Add doc + */ +int __init clocksource_mmio_setup(struct clocksource_mmio *cs, + void __iomem *base , const char *name, + unsigned long hz , int rating, unsigned bits, + cycle_t (*read)(struct clocksource *)) +{ + if (bits > 64 || bits < 16) + return -EINVAL; + + cs->reg = base; + cs->clksrc.name = name; + cs->clksrc.rating = rating; + cs->clksrc.read = read; + cs->clksrc.mask = CLOCKSOURCE_MASK(bits); + cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS; + + return clocksource_register_hz(&cs->clksrc, hz); +} + +/** * clocksource_mmio_init - Initialize a simple mmio based clocksource * @base: Virtual address of the clock readout register * @name: Name of the clocksource @@ -62,12 +78,5 @@ int __init clocksource_mmio_init(void __ if (!cs) return -ENOMEM; - cs->reg = base; - cs->clksrc.name = name; - cs->clksrc.rating = rating; - cs->clksrc.read = read; - cs->clksrc.mask = CLOCKSOURCE_MASK(bits); - cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS; - - return clocksource_register_hz(&cs->clksrc, hz); + return clocksource_mmio_setup(cs, base, name, hz, rating, bits, read); } --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -119,6 +119,14 @@ struct clocksource { /* simplify initialization of mask field */ #define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) +/** + * FIXME: Add doc + */ +struct clocksource_mmio { + void __iomem *reg; + struct clocksource clksrc; +}; + static inline u32 clocksource_freq2mult(u32 freq, u32 shift_constant, u64 from) { /* freq = cyc/from @@ -241,6 +249,11 @@ extern cycle_t clocksource_mmio_readw_do extern int clocksource_mmio_init(void __iomem *, const char *, unsigned long, int, unsigned, cycle_t (*)(struct clocksource *)); +extern int clocksource_mmio_setup(struct clocksource_mmio *, + void __iomem *, const char *, + unsigned long, int, unsigned, + cycle_t (*)(struct clocksource *)); + extern int clocksource_i8253_init(void); #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \