From patchwork Tue Jan 24 12:16:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 9535109 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 AA0E56042C for ; Tue, 24 Jan 2017 12:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A69F26E55 for ; Tue, 24 Jan 2017 12:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EFCF27D4A; Tue, 24 Jan 2017 12:22:00 +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=-1.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F50326E55 for ; Tue, 24 Jan 2017 12:22:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cW06n-0003IV-1y; Tue, 24 Jan 2017 12:21:57 +0000 Received: from mail-lf0-f68.google.com ([209.85.215.68]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cW03E-0007cg-JX; Tue, 24 Jan 2017 12:18:19 +0000 Received: by mail-lf0-f68.google.com with SMTP id x1so17099286lff.0; Tue, 24 Jan 2017 04:17:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3IfDTv/ZLPTnjLJbNbFvt9v3GahPemB2Yi0rjcSxyqc=; b=ZmDaWP4mlLvFPVUKRIghVqcRr/GpemDjG8S+TWzXHlHIpESfmlaDYEBSC+yxgL1ltG gLespQEokEr+XYi0Z43dh3U+VA5jtRMzs8UyWqRi1aTVJr6kdlBGUmjVsrOh0jpmWnA5 OegLMGB2/Oy7sEDQ3daHXWjP6XzGE6wm+cT64XUUogDXVTNGprAgin6MByUGWcBZAfCk iVcaEPuFWOgGDkNNUcpLtxOMo0sNQnnCCQ09ijyBe3VeDH0oyCo6CjjsKJKfE2Cb6K4L wTk2N890/8KrxS2iklTdhbAicZIh0566SAV3zIpCgGAe1D75BiRiNn/t3WZjhqKKSi06 /KfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3IfDTv/ZLPTnjLJbNbFvt9v3GahPemB2Yi0rjcSxyqc=; b=WcJ3IT4aUyrEUU2unqYD0jmrbiLq7DRTXhfyk0HLCmMAG+F104qPdPZWednu8BDS0l MBAWW1KiwXeRItCUUeuhuSkSjBVFHC+ZYRkoDuh+oMR4bEsg8L0nRivd1DQFILodHmCS Guowk9T5vyQodmajTOyJW7vOFWvrBF3ZIj8bOzWGv4CvvoxcZnvXBNpiq5D2AKoVJbXc NMbNcdzheE15geIns5Ie8bgElFSmkck77TVVfoCpqrUrnF/tA0auMLLiP/hFsBhMj+Ab HiiUivxDHEh19N8B27ccKNiqZm74iGYdBaLECAx2hw1mREC7tz2V9FGAw/lvQN9MAllu NiRw== X-Gm-Message-State: AIkVDXLvnrI+GNw8Nilynzac4YCMmttUUkmdAwudV93hkmgQ6rn6sI2t/vbrs+XCHNSWJg== X-Received: by 10.25.92.2 with SMTP id q2mr10878912lfb.121.1485260216184; Tue, 24 Jan 2017 04:16:56 -0800 (PST) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id e86sm7348934lji.32.2017.01.24.04.16.54 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 04:16:55 -0800 (PST) From: Alexander Kochetkov To: Daniel Lezcano , Heiko Stuebner , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH v5 5/8] clocksource/drivers/rockchip_timer: split bc_timer into rk_timer and rk_clock_event_device Date: Tue, 24 Jan 2017 15:16:40 +0300 Message-Id: <1485260203-14216-6-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1485260203-14216-1-git-send-email-al.kochet@gmail.com> References: <1485260203-14216-1-git-send-email-al.kochet@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_041816_830045_04D06E1E X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Huang Tao , Alexander Kochetkov , Russell King , Rob Herring , Thomas Gleixner , Caesar Wang 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 The patch move ce field out of struct bc_timer into struct rk_clock_event_device and rename struct bc_timer to struct rk_timer. The main idea for the commit is to exctact low level timer routines from current implementation so they could be reused in the following clocksource implementation commit. This is refactoring step without functional changes. Signed-off-by: Alexander Kochetkov Reviwed-by: Heiko Stübner --- drivers/clocksource/rockchip_timer.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c index 23e267a..6d68d4c 100644 --- a/drivers/clocksource/rockchip_timer.c +++ b/drivers/clocksource/rockchip_timer.c @@ -29,18 +29,28 @@ #define TIMER_MODE_USER_DEFINED_COUNT (1 << 1) #define TIMER_INT_UNMASK (1 << 2) -struct bc_timer { - struct clock_event_device ce; +struct rk_timer { void __iomem *base; void __iomem *ctrl; u32 freq; }; -static struct bc_timer bc_timer; +struct rk_clock_event_device { + struct clock_event_device ce; + struct rk_timer timer; +}; + +static struct rk_clock_event_device bc_timer; + +static inline struct rk_clock_event_device* +rk_clock_event_device(struct clock_event_device *ce) +{ + return container_of(ce, struct rk_clock_event_device, ce); +} -static inline struct bc_timer *rk_timer(struct clock_event_device *ce) +static inline struct rk_timer *rk_timer(struct clock_event_device *ce) { - return container_of(ce, struct bc_timer, ce); + return &rk_clock_event_device(ce)->timer; } static inline void __iomem *rk_base(struct clock_event_device *ce) @@ -116,16 +126,17 @@ static irqreturn_t rk_timer_interrupt(int irq, void *dev_id) static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg) { struct clock_event_device *ce = &bc_timer.ce; + struct rk_timer *timer = &bc_timer.timer; struct clk *timer_clk; struct clk *pclk; int ret = -EINVAL, irq; - bc_timer.base = of_iomap(np, 0); - if (!bc_timer.base) { + timer->base = of_iomap(np, 0); + if (!timer->base) { pr_err("Failed to get base address for '%s'\n", TIMER_NAME); return -ENXIO; } - bc_timer.ctrl = bc_timer.base + ctrl_reg; + timer->ctrl = timer->base + ctrl_reg; pclk = of_clk_get_by_name(np, "pclk"); if (IS_ERR(pclk)) { @@ -153,7 +164,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg) goto out_timer_clk; } - bc_timer.freq = clk_get_rate(timer_clk); + timer->freq = clk_get_rate(timer_clk); irq = irq_of_parse_and_map(np, 0); if (!irq) { @@ -181,7 +192,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg) goto out_irq; } - clockevents_config_and_register(ce, bc_timer.freq, 1, UINT_MAX); + clockevents_config_and_register(ce, timer->freq, 1, UINT_MAX); return 0; @@ -190,7 +201,7 @@ static int __init rk_timer_init(struct device_node *np, u32 ctrl_reg) out_timer_clk: clk_disable_unprepare(pclk); out_unmap: - iounmap(bc_timer.base); + iounmap(timer->base); return ret; }