From patchwork Tue Jun 27 09:26:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 106407 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp996145qge; Tue, 27 Jun 2017 02:28:48 -0700 (PDT) X-Received: by 10.98.213.131 with SMTP id d125mr4234225pfg.79.1498555728254; Tue, 27 Jun 2017 02:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498555728; cv=none; d=google.com; s=arc-20160816; b=otMf91yIq4K1wbt/CIzs+kqCZgI9/riR6L+MdLW04hxpufO1Krdg2Ny5obtkm1GHvp SURICTe72S5Mt0gO80iP/osiIlbUtsDLzafOUdMLxjS7O0s3xnVyLUjaPMucUeWzbQAr mR6W3zigEEJhXAkORovDdjmsKakvPIaRYAdjgSHfaclxais6joRJ6X9J7XrL9iZ3fZxQ K7DtAJ6FUiVoFA7ZTDooRwXL48yTjeaV2z+UViOiLHfYMP8lLDlPjmQPM1Jxx7ubfNY0 OP0niwOk8cuzr70zyd0yImxHfJaTPchvwATk9D4e/2CH/+i3ClyYkpZakFDM6KCO/bE1 6WfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=t5lolMpwJuVYvklJf57sXrTc5KoJkbHux/Gddyzv3sc=; b=j73tEPSH1pPoNLONMdemGf8ZU7pWmpd83YQiAUIFfSCVLgW5pFbzLXBmgUW+EKNRyM Y1GaFYBWpUDTOQ1PD2Vq6Jw40CXH12E7RcFjWrmtC4LSKmhaT+5xWtq6h8EcHq449sZZ Mm8qHU1F3psMG4iyJu0X/FjZjB6TI2/gpUv0PZIc0NOkiji4/T+J0wKVX8CMaTi7e/vR qVhZmR/MbXX+1ox+2Df6UkrCnBJuHlnmTvfMfVQQ48zBHH/c9IGuL5KyzD8Woz9ctZ+R p8buWHBdvkvtGEMWZKsvW4EVqTtrUjra8QHWnCwmuKIAEJYJ25O50JqLmgsUBBYmuXvL s66A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=KihvZEkM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si1614652pge.249.2017.06.27.02.28.47; Tue, 27 Jun 2017 02:28:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=KihvZEkM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752445AbdF0J2f (ORCPT + 25 others); Tue, 27 Jun 2017 05:28:35 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36602 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbdF0J21 (ORCPT ); Tue, 27 Jun 2017 05:28:27 -0400 Received: by mail-wm0-f45.google.com with SMTP id 62so19021695wmw.1 for ; Tue, 27 Jun 2017 02:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t5lolMpwJuVYvklJf57sXrTc5KoJkbHux/Gddyzv3sc=; b=KihvZEkMmXXZqpFuMzGNodDXq2ZLzCAGS6+TiDEnZ0I7BvwZky5ReAbZUzDA4Vy8c0 KUmvcJ0Q+08Akm2AhJ6MkdXsRjCmZLP8ZQEMHOPB3TTk02FDLnClV4aWAzyZviQ72T3t Q6ArMy8fuzj1wXXG9jspyqhA3+33+isYomHs8= 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; bh=t5lolMpwJuVYvklJf57sXrTc5KoJkbHux/Gddyzv3sc=; b=dUQrYJNhKA68O3lq7SwWctpx2zk1hOy/RhXuyDbA8/WwWw5z7Pob+HH4Ul2J1WIqsm gD+pvor7y/cHxaup/cYjAmyMcc4d+qI6JOO88tsnCdhsCeRRU9bTeu2VICFIQAEZCt17 ojJR81awuPBO1Hp/dOM6fDQ3pPJe8/MgkUqWYgOXyVjncEiEJgrTiPS/cn7KzTUWIGJv RvCPos0psdxnJzDBUp+iTwLcc9RfhwsHoZPFnKJtSEP9yHHblMaQIN3hAtvbUbIE8Eid Fssr9Gc3UJ0xgKuHdePIvO6rv2i8KnayZPn3KNfbhwqCadMYt+kj6f30ZR9Q7T9/PvV/ ucuA== X-Gm-Message-State: AKS2vOwjgkqF+MPWZL8jxsgKVTTIbVuQ9q6XVLi8y8+GdxA++bwZYMDp Kpu2Elt+87T5Npzp X-Received: by 10.28.21.80 with SMTP id 77mr2454648wmv.79.1498555705984; Tue, 27 Jun 2017 02:28:25 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:110f:661:6b72:192e]) by smtp.gmail.com with ESMTPSA id g2sm16159798wrg.69.2017.06.27.02.28.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 02:28:25 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/5] clocksource/drivers/timer-of: Fix invalid iomap check Date: Tue, 27 Jun 2017 11:26:56 +0200 Message-Id: <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170627092239.GE2479@mai> References: <20170627092239.GE2479@mai> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A typo in the code checks the return value of iomap against !NULL and, thus, fails everytime the mapping succeed. Fix this by inverting the condition in the check. Signed-off-by: Daniel Lezcano --- drivers/clocksource/timer-of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c index 64b1c20..f6e7491 100644 --- a/drivers/clocksource/timer-of.c +++ b/drivers/clocksource/timer-of.c @@ -120,7 +120,7 @@ static __init int timer_base_init(struct device_node *np, const char *name = of_base->name ? of_base->name : np->full_name; of_base->base = of_io_request_and_map(np, of_base->index, name); - if (of_base->base) { + if (!of_base->base) { pr_err("Failed to iomap (%s)\n", name); return -ENXIO; } From patchwork Tue Jun 27 09:26:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 106409 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp996425qge; Tue, 27 Jun 2017 02:29:11 -0700 (PDT) X-Received: by 10.99.104.136 with SMTP id d130mr4277525pgc.236.1498555751196; Tue, 27 Jun 2017 02:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498555751; cv=none; d=google.com; s=arc-20160816; b=vakqxrRh8X7hLjnaOXoV9wQ4PQg8Gd88Z1z1zB+Lq5mKjMmGiy/IoW+eyAVziHJVlq rnXDUsV9+MlfQIy95UweW/WH8TPbeI/z1+ZjDksVhQiUu0vGm8C3xlYtOKMTStAn1BKb u9BRrQW88TAAohidvrNBOVzonrPckjTAe9IXzXS3c2X7ov0juj88lW+KVjbADV2LHeWz 4LYZpSWDXfaXhhVWY9dPvcH6fJXqEnNzm/dzSOCajsp+tdWAvlqf9FShKJmEiGjOqT2z mBg841If793anKMRG46KJfVGMAFjV6EstDFpZEc29xCNHdOf6MWGDg1qWL20Q0HVv7oS vtdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CN7wT6RioUrAnJhuXVZD2sc+zkeEGpcf/azsksMslsU=; b=Djul+b6kVadPjlEKqEuUoMAjfvkPdPeVAYucG47mrqWjQYkjx0eQomyX01U32zzub5 rkx270OhQ5wrPEx8YTdJQg4DsL8O6+anVMeMFph5a4p5Q+4Wy+trb6OFLngb5ecFPOn6 ujPMY2g05hZ/bI0ykGpBl8C0OOg9Dl1njYokOVusi24YYh1kLVuidI4Z7RzGMMl0qmgq MQko3aUVopWnPKDm5hBUp1HPXb7y4b2lIVOlMp418GhL7Kb6WzDNEZh2YF1jupzV/UDa CvnPWnM88wrLaQGOw1/BImf26pJJ2bBk2rLpxF9KolEWsnqmiZdsWRdy5M02ZGGpgdD1 SthA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=dqknLrQY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s80si1603828pfs.171.2017.06.27.02.29.10; Tue, 27 Jun 2017 02:29:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=dqknLrQY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752603AbdF0J2u (ORCPT + 25 others); Tue, 27 Jun 2017 05:28:50 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:34671 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752142AbdF0J23 (ORCPT ); Tue, 27 Jun 2017 05:28:29 -0400 Received: by mail-wr0-f180.google.com with SMTP id 77so156188750wrb.1 for ; Tue, 27 Jun 2017 02:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CN7wT6RioUrAnJhuXVZD2sc+zkeEGpcf/azsksMslsU=; b=dqknLrQYZxkoytXhY13HyRt88aVcG4InXT3zXdthOjnjLgLPDUBGUCZGOoz781tYDY t9E/x28UalQI/KvvvA/OjqEuTtjRuvd+j1Etp79MuhLJ3IqsYAin38HBhKo1EmXmJhjr wxtCYqocxyGVNnqvBo/WJX3xBIQqFgXH7/vPI= 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; bh=CN7wT6RioUrAnJhuXVZD2sc+zkeEGpcf/azsksMslsU=; b=NFb6InLKcDoRo+16uN/vc9HBY6jia//dQ12f5eG5h3sh3PmDTy6rkUy8L5ed/DMTlI TiULs8vLmyzUJghUYCFJiNkZXSM5X+cEYya99e2b5pWW0WApEqWVyYeIcmtdxZNV74+p eQr2nXh26JWkdy203cUB7hBeHFiCpH4gLmcj4PnFDwACdQ9Fsy7/e4TBNrV5D5wj3uxN o20aXNVETJo0/A7SUUxQDi3+l/C6Ie/Hp2FH/zXPGUesA8ot+Y/V4LMVR4pgne+Hsz1k YshUGr5LYQ8VoK4/zduvyN275kk7IOtsCYEekhXexXFvm6/yO9gPa8Y80d4H8Tu4GVDD 7dwQ== X-Gm-Message-State: AKS2vOxjABX+JSULw1EFyMIzDRfSL0gBQ+3Q0LQ83PyGfKO5AEOglfbx PtIz1XyZ9QAA/5Yh X-Received: by 10.223.162.150 with SMTP id s22mr10888446wra.181.1498555707561; Tue, 27 Jun 2017 02:28:27 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:110f:661:6b72:192e]) by smtp.gmail.com with ESMTPSA id g2sm16159798wrg.69.2017.06.27.02.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 02:28:27 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Chen-Yu Tsai , Maxime Ripard , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sunXi SoC support) Subject: [PATCH 2/5] clocksource/drivers/sun4i: Switch to the timer-of common init Date: Tue, 27 Jun 2017 11:26:57 +0200 Message-Id: <1498555620-25094-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> References: <20170627092239.GE2479@mai> <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously a framework to factor out the drivers init function has been merged. Use this common framework in this driver, we get: Before: text data bss dec hex filename 1787 384 12 2183 887 drivers/clocksource/sun4i_timer.o After: text data bss dec hex filename 1407 512 0 1919 77f drivers/clocksource/sun4i_timer.o Signed-off-by: Daniel Lezcano Tested-by: Chen-Yu Tsai --- drivers/clocksource/Kconfig | 1 + drivers/clocksource/sun4i_timer.c | 171 +++++++++++++++++--------------------- 2 files changed, 78 insertions(+), 94 deletions(-) -- 2.7.4 diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 4be163b..88818a4 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -108,6 +108,7 @@ config SUN4I_TIMER depends on GENERIC_CLOCKEVENTS depends on HAS_IOMEM select CLKSRC_MMIO + select TIMER_OF help Enables support for the Sun4i timer. diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c index 3e4bc64..6e0180a 100644 --- a/drivers/clocksource/sun4i_timer.c +++ b/drivers/clocksource/sun4i_timer.c @@ -24,6 +24,8 @@ #include #include +#include "timer-of.h" + #define TIMER_IRQ_EN_REG 0x00 #define TIMER_IRQ_EN(val) BIT(val) #define TIMER_IRQ_ST_REG 0x04 @@ -39,38 +41,37 @@ #define TIMER_SYNC_TICKS 3 -static void __iomem *timer_base; -static u32 ticks_per_jiffy; - /* * When we disable a timer, we need to wait at least for 2 cycles of * the timer source clock. We will use for that the clocksource timer * that is already setup and runs at the same frequency than the other * timers, and we never will be disabled. */ -static void sun4i_clkevt_sync(void) +static void sun4i_clkevt_sync(void __iomem *base) { - u32 old = readl(timer_base + TIMER_CNTVAL_REG(1)); + u32 old = readl(base + TIMER_CNTVAL_REG(1)); - while ((old - readl(timer_base + TIMER_CNTVAL_REG(1))) < TIMER_SYNC_TICKS) + while ((old - readl(base + TIMER_CNTVAL_REG(1))) < TIMER_SYNC_TICKS) cpu_relax(); } -static void sun4i_clkevt_time_stop(u8 timer) +static void sun4i_clkevt_time_stop(void __iomem *base, u8 timer) { - u32 val = readl(timer_base + TIMER_CTL_REG(timer)); - writel(val & ~TIMER_CTL_ENABLE, timer_base + TIMER_CTL_REG(timer)); - sun4i_clkevt_sync(); + u32 val = readl(base + TIMER_CTL_REG(timer)); + writel(val & ~TIMER_CTL_ENABLE, base + TIMER_CTL_REG(timer)); + sun4i_clkevt_sync(base); } -static void sun4i_clkevt_time_setup(u8 timer, unsigned long delay) +static void sun4i_clkevt_time_setup(void __iomem *base, u8 timer, + unsigned long delay) { - writel(delay, timer_base + TIMER_INTVAL_REG(timer)); + writel(delay, base + TIMER_INTVAL_REG(timer)); } -static void sun4i_clkevt_time_start(u8 timer, bool periodic) +static void sun4i_clkevt_time_start(void __iomem *base, u8 timer, + bool periodic) { - u32 val = readl(timer_base + TIMER_CTL_REG(timer)); + u32 val = readl(base + TIMER_CTL_REG(timer)); if (periodic) val &= ~TIMER_CTL_ONESHOT; @@ -78,115 +79,106 @@ static void sun4i_clkevt_time_start(u8 timer, bool periodic) val |= TIMER_CTL_ONESHOT; writel(val | TIMER_CTL_ENABLE | TIMER_CTL_RELOAD, - timer_base + TIMER_CTL_REG(timer)); + base + TIMER_CTL_REG(timer)); } static int sun4i_clkevt_shutdown(struct clock_event_device *evt) { - sun4i_clkevt_time_stop(0); + struct timer_of *to = to_timer_of(evt); + + sun4i_clkevt_time_stop(timer_of_base(to), 0); + return 0; } static int sun4i_clkevt_set_oneshot(struct clock_event_device *evt) { - sun4i_clkevt_time_stop(0); - sun4i_clkevt_time_start(0, false); + struct timer_of *to = to_timer_of(evt); + + sun4i_clkevt_time_stop(timer_of_base(to), 0); + sun4i_clkevt_time_start(timer_of_base(to), 0, false); + return 0; } static int sun4i_clkevt_set_periodic(struct clock_event_device *evt) { - sun4i_clkevt_time_stop(0); - sun4i_clkevt_time_setup(0, ticks_per_jiffy); - sun4i_clkevt_time_start(0, true); + struct timer_of *to = to_timer_of(evt); + + sun4i_clkevt_time_stop(timer_of_base(to), 0); + sun4i_clkevt_time_setup(timer_of_base(to), 0, timer_of_period(to)); + sun4i_clkevt_time_start(timer_of_base(to), 0, true); + return 0; } static int sun4i_clkevt_next_event(unsigned long evt, - struct clock_event_device *unused) + struct clock_event_device *clkevt) { - sun4i_clkevt_time_stop(0); - sun4i_clkevt_time_setup(0, evt - TIMER_SYNC_TICKS); - sun4i_clkevt_time_start(0, false); + struct timer_of *to = to_timer_of(clkevt); + + sun4i_clkevt_time_stop(timer_of_base(to), 0); + sun4i_clkevt_time_setup(timer_of_base(to), 0, evt - TIMER_SYNC_TICKS); + sun4i_clkevt_time_start(timer_of_base(to), 0, false); return 0; } -static struct clock_event_device sun4i_clockevent = { - .name = "sun4i_tick", - .rating = 350, - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, - .set_state_shutdown = sun4i_clkevt_shutdown, - .set_state_periodic = sun4i_clkevt_set_periodic, - .set_state_oneshot = sun4i_clkevt_set_oneshot, - .tick_resume = sun4i_clkevt_shutdown, - .set_next_event = sun4i_clkevt_next_event, -}; - -static void sun4i_timer_clear_interrupt(void) +static void sun4i_timer_clear_interrupt(void __iomem *base) { - writel(TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_ST_REG); + writel(TIMER_IRQ_EN(0), base + TIMER_IRQ_ST_REG); } static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = (struct clock_event_device *)dev_id; + struct timer_of *to = to_timer_of(evt); - sun4i_timer_clear_interrupt(); + sun4i_timer_clear_interrupt(timer_of_base(to)); evt->event_handler(evt); return IRQ_HANDLED; } -static struct irqaction sun4i_timer_irq = { - .name = "sun4i_timer0", - .flags = IRQF_TIMER | IRQF_IRQPOLL, - .handler = sun4i_timer_interrupt, - .dev_id = &sun4i_clockevent, +static struct timer_of to = { + .flags = TIMER_OF_IRQ | TIMER_OF_CLOCK | TIMER_OF_BASE, + + .clkevt = { + .name = "sun4i_tick", + .rating = 350, + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, + .set_state_shutdown = sun4i_clkevt_shutdown, + .set_state_periodic = sun4i_clkevt_set_periodic, + .set_state_oneshot = sun4i_clkevt_set_oneshot, + .tick_resume = sun4i_clkevt_shutdown, + .set_next_event = sun4i_clkevt_next_event, + .cpumask = cpu_possible_mask, + }, + + .of_irq = { + .handler = sun4i_timer_interrupt, + .flags = IRQF_TIMER | IRQF_IRQPOLL, + }, }; static u64 notrace sun4i_timer_sched_read(void) { - return ~readl(timer_base + TIMER_CNTVAL_REG(1)); + return ~readl(timer_of_base(&to) + TIMER_CNTVAL_REG(1)); } static int __init sun4i_timer_init(struct device_node *node) { - unsigned long rate = 0; - struct clk *clk; - int ret, irq; + int ret; u32 val; - timer_base = of_iomap(node, 0); - if (!timer_base) { - pr_crit("Can't map registers\n"); - return -ENXIO; - } - - irq = irq_of_parse_and_map(node, 0); - if (irq <= 0) { - pr_crit("Can't parse IRQ\n"); - return -EINVAL; - } - - clk = of_clk_get(node, 0); - if (IS_ERR(clk)) { - pr_crit("Can't get timer clock\n"); - return PTR_ERR(clk); - } - - ret = clk_prepare_enable(clk); - if (ret) { - pr_err("Failed to prepare clock\n"); + ret = timer_of_init(node, &to); + if (ret) return ret; - } - - rate = clk_get_rate(clk); - writel(~0, timer_base + TIMER_INTVAL_REG(1)); + writel(~0, timer_of_base(&to) + TIMER_INTVAL_REG(1)); writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD | TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M), - timer_base + TIMER_CTL_REG(1)); + timer_of_base(&to) + TIMER_CTL_REG(1)); /* * sched_clock_register does not have priorities, and on sun6i and @@ -195,41 +187,32 @@ static int __init sun4i_timer_init(struct device_node *node) if (of_machine_is_compatible("allwinner,sun4i-a10") || of_machine_is_compatible("allwinner,sun5i-a13") || of_machine_is_compatible("allwinner,sun5i-a10s")) - sched_clock_register(sun4i_timer_sched_read, 32, rate); + sched_clock_register(sun4i_timer_sched_read, 32, + timer_of_rate(&to)); - ret = clocksource_mmio_init(timer_base + TIMER_CNTVAL_REG(1), node->name, - rate, 350, 32, clocksource_mmio_readl_down); + ret = clocksource_mmio_init(timer_of_base(&to) + TIMER_CNTVAL_REG(1), + node->name, timer_of_rate(&to), 350, 32, + clocksource_mmio_readl_down); if (ret) { pr_err("Failed to register clocksource\n"); return ret; } - ticks_per_jiffy = DIV_ROUND_UP(rate, HZ); - writel(TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M), - timer_base + TIMER_CTL_REG(0)); + timer_of_base(&to) + TIMER_CTL_REG(0)); /* Make sure timer is stopped before playing with interrupts */ - sun4i_clkevt_time_stop(0); + sun4i_clkevt_time_stop(timer_of_base(&to), 0); /* clear timer0 interrupt */ - sun4i_timer_clear_interrupt(); - - sun4i_clockevent.cpumask = cpu_possible_mask; - sun4i_clockevent.irq = irq; + sun4i_timer_clear_interrupt(timer_of_base(&to)); - clockevents_config_and_register(&sun4i_clockevent, rate, + clockevents_config_and_register(&to.clkevt, timer_of_rate(&to), TIMER_SYNC_TICKS, 0xffffffff); - ret = setup_irq(irq, &sun4i_timer_irq); - if (ret) { - pr_err("failed to setup irq %d\n", irq); - return ret; - } - /* Enable timer0 interrupt */ - val = readl(timer_base + TIMER_IRQ_EN_REG); - writel(val | TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_EN_REG); + val = readl(timer_of_base(&to) + TIMER_IRQ_EN_REG); + writel(val | TIMER_IRQ_EN(0), timer_of_base(&to) + TIMER_IRQ_EN_REG); return ret; } From patchwork Tue Jun 27 09:26:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 106408 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp996421qge; Tue, 27 Jun 2017 02:29:10 -0700 (PDT) X-Received: by 10.84.141.3 with SMTP id 3mr2121656plu.227.1498555750790; Tue, 27 Jun 2017 02:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498555750; cv=none; d=google.com; s=arc-20160816; b=l8w58xu5kMFKPnV5nJxahOdbjCdc3KnGTfPrT5V/2aJV0c1VymgwILnkRKUgcHVQF4 ntU6PUg06VfFf0hiD6Jwr0giB/sfjTFgXDrVot1zUgowojXE+tuZ/fkl3gV1Y6tORFAU 2APBxZDgS09E7W9Z7CySmiOwQ0mPZ4N5zHRN/MPT7xI0jAfiQWykwbqLFh7LafJKlXW7 dlfPnRrlzYzp8xb8mCu5p7Za1KgYxP3qKUeaJQOpGHHhyTOoq6IhGPFfFzGf7RhhhXdg ZDBdBiXe0U7Am4c6bLqLuy+e1cfbG12Idyjxxk0kZ/Bi5h2UPEck8xcPdoaLyuIP2UfO USRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=jdNJWMDZf1Dv0K90xhnKgz0LnXdjEGF6e/vqTY2riWU=; b=GjkbijgegdmmfyznkSn/s9zgdHAex35Uqf1QHnwhfj3+dkEAX+fobr2UZs0dbZBd6z fwK3QLoUscFS/yAm1NWp02EPXSy7wQ7EgQOtr/rhrbgouEu5RCPlZOPs2kIl56izc0iQ coI7OmQ4BF/a7fi/R4+TFaQVb4co4+gpIM4Jdm0DtPXnZx6vNHMUETwt9l+svV5ckqVL C31GBz1CElSKfzs/UNMDwnSDXF4JPmoLepFQCT7CJ670tFIVV3zM5jJIwfp1xtKxrT/R hVZtxW7j4HAE3Fy7IW6cYghHKvnUhHSf3a+6i6cyhPc3Hb8jHpNFRdrFb6Q9v0m1Q4c2 nRLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=eJGoHzsx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s80si1603828pfs.171.2017.06.27.02.29.10; Tue, 27 Jun 2017 02:29:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=eJGoHzsx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752530AbdF0J2r (ORCPT + 25 others); Tue, 27 Jun 2017 05:28:47 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37914 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752271AbdF0J2a (ORCPT ); Tue, 27 Jun 2017 05:28:30 -0400 Received: by mail-wm0-f53.google.com with SMTP id b184so20403146wme.1 for ; Tue, 27 Jun 2017 02:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jdNJWMDZf1Dv0K90xhnKgz0LnXdjEGF6e/vqTY2riWU=; b=eJGoHzsxd1a/GFL+/8jaju5urEP5nUdHaSHX76TMKYkV/H+TXtm6tmLjzQF3WQlHTa YjVYPg/6e1PyT+VjzZz1eUpZyoAGkNJJlfgkt+AYejEYVlYzjPj2QPfs1WUqXhnfFQaw a1zczB40UoxGcMxUPvJSBugdkN8467OckAA8I= 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; bh=jdNJWMDZf1Dv0K90xhnKgz0LnXdjEGF6e/vqTY2riWU=; b=DocbW/UMZ8lXwruRNs8hFgrbyuGi01axbQFm9Eu7c8MxBMerlIAXixfC7FlmnknsXC ufd39qaranu5RltNNGEYEhDPQv8g8W2Ak1Bh1f1q1Aa6qIr2w2eOAqtmT06HJC/SfMKB 5spAzVFIzJJwZIw+gQLwvREq/+cbqEmKtRSM9c3M623tJXG2zcbkmPZaoBgyXZBWMCjb L48DTS28QUmbwRVfL0hFUoC2L2rywvKak/q3IH20PtBJwybTzhrn2FcDRkgftv6UdKQN GXJ/PX8fFaZdcPv79/lCoAUd729QpCctzGtrrQdE/4R0KHc3SAXISVNW+g8cNjHg/ywN S77Q== X-Gm-Message-State: AKS2vOzxZnBchKHQ6n9tzp6bvwSH7JVc/t2pwHlvYd6FauiJRmc65zW8 8DBw4ZHFtfhvAk5k X-Received: by 10.28.105.85 with SMTP id e82mr2638731wmc.122.1498555708986; Tue, 27 Jun 2017 02:28:28 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:110f:661:6b72:192e]) by smtp.gmail.com with ESMTPSA id g2sm16159798wrg.69.2017.06.27.02.28.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 02:28:28 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Alexandre Belloni , Nicolas Ferre , linux-arm-kernel@lists.infradead.org (moderated list:ATMEL Timer Counter (TC) AND CLOCKSOURCE DRIVERS) Subject: [PATCH 3/5] clocksource/drivers/tcb_clksrc: Make IO endian agnostic Date: Tue, 27 Jun 2017 11:26:58 +0200 Message-Id: <1498555620-25094-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> References: <20170627092239.GE2479@mai> <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Belloni Now that AVR32 is gone, we can use the proper IO accessors that are correctly handling endianness. Signed-off-by: Alexandre Belloni Acked-by: Nicolas Ferre Signed-off-by: Daniel Lezcano --- drivers/clocksource/tcb_clksrc.c | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) -- 2.7.4 diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c index 828729c..59e8aee 100644 --- a/drivers/clocksource/tcb_clksrc.c +++ b/drivers/clocksource/tcb_clksrc.c @@ -57,9 +57,9 @@ static u64 tc_get_cycles(struct clocksource *cs) raw_local_irq_save(flags); do { - upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)); - lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV)); - } while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV))); + upper = readl_relaxed(tcaddr + ATMEL_TC_REG(1, CV)); + lower = readl_relaxed(tcaddr + ATMEL_TC_REG(0, CV)); + } while (upper != readl_relaxed(tcaddr + ATMEL_TC_REG(1, CV))); raw_local_irq_restore(flags); return (upper << 16) | lower; @@ -67,7 +67,7 @@ static u64 tc_get_cycles(struct clocksource *cs) static u64 tc_get_cycles32(struct clocksource *cs) { - return __raw_readl(tcaddr + ATMEL_TC_REG(0, CV)); + return readl_relaxed(tcaddr + ATMEL_TC_REG(0, CV)); } void tc_clksrc_suspend(struct clocksource *cs) @@ -147,8 +147,8 @@ static int tc_shutdown(struct clock_event_device *d) struct tc_clkevt_device *tcd = to_tc_clkevt(d); void __iomem *regs = tcd->regs; - __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR)); - __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR)); + writel(0xff, regs + ATMEL_TC_REG(2, IDR)); + writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR)); if (!clockevent_state_detached(d)) clk_disable(tcd->clk); @@ -166,9 +166,9 @@ static int tc_set_oneshot(struct clock_event_device *d) clk_enable(tcd->clk); /* slow clock, count up to RC, then irq and stop */ - __raw_writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE | + writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO, regs + ATMEL_TC_REG(2, CMR)); - __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER)); + writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER)); /* set_next_event() configures and starts the timer */ return 0; @@ -188,25 +188,25 @@ static int tc_set_periodic(struct clock_event_device *d) clk_enable(tcd->clk); /* slow clock, count up to RC, then irq and restart */ - __raw_writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO, + writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO, regs + ATMEL_TC_REG(2, CMR)); - __raw_writel((32768 + HZ / 2) / HZ, tcaddr + ATMEL_TC_REG(2, RC)); + writel((32768 + HZ / 2) / HZ, tcaddr + ATMEL_TC_REG(2, RC)); /* Enable clock and interrupts on RC compare */ - __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER)); + writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER)); /* go go gadget! */ - __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, regs + + writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, regs + ATMEL_TC_REG(2, CCR)); return 0; } static int tc_next_event(unsigned long delta, struct clock_event_device *d) { - __raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC)); + writel_relaxed(delta, tcaddr + ATMEL_TC_REG(2, RC)); /* go go gadget! */ - __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, + writel_relaxed(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, tcaddr + ATMEL_TC_REG(2, CCR)); return 0; } @@ -230,7 +230,7 @@ static irqreturn_t ch2_irq(int irq, void *handle) struct tc_clkevt_device *dev = handle; unsigned int sr; - sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR)); + sr = readl_relaxed(dev->regs + ATMEL_TC_REG(2, SR)); if (sr & ATMEL_TC_CPCS) { dev->clkevt.event_handler(&dev->clkevt); return IRQ_HANDLED; @@ -290,43 +290,43 @@ static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx) static void __init tcb_setup_dual_chan(struct atmel_tc *tc, int mck_divisor_idx) { /* channel 0: waveform mode, input mclk/8, clock TIOA0 on overflow */ - __raw_writel(mck_divisor_idx /* likely divide-by-8 */ + writel(mck_divisor_idx /* likely divide-by-8 */ | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP /* free-run */ | ATMEL_TC_ACPA_SET /* TIOA0 rises at 0 */ | ATMEL_TC_ACPC_CLEAR, /* (duty cycle 50%) */ tcaddr + ATMEL_TC_REG(0, CMR)); - __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA)); - __raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC)); - __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */ - __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR)); + writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA)); + writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC)); + writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */ + writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR)); /* channel 1: waveform mode, input TIOA0 */ - __raw_writel(ATMEL_TC_XC1 /* input: TIOA0 */ + writel(ATMEL_TC_XC1 /* input: TIOA0 */ | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP, /* free-run */ tcaddr + ATMEL_TC_REG(1, CMR)); - __raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */ - __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR)); + writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR)); /* no irqs */ + writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR)); /* chain channel 0 to channel 1*/ - __raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR); + writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR); /* then reset all the timers */ - __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); + writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); } static void __init tcb_setup_single_chan(struct atmel_tc *tc, int mck_divisor_idx) { /* channel 0: waveform mode, input mclk/8 */ - __raw_writel(mck_divisor_idx /* likely divide-by-8 */ + writel(mck_divisor_idx /* likely divide-by-8 */ | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP, /* free-run */ tcaddr + ATMEL_TC_REG(0, CMR)); - __raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */ - __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR)); + writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR)); /* no irqs */ + writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR)); /* then reset all the timers */ - __raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); + writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); } static int __init tcb_clksrc_init(void) From patchwork Tue Jun 27 09:26:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 106410 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp996432qge; Tue, 27 Jun 2017 02:29:11 -0700 (PDT) X-Received: by 10.84.224.133 with SMTP id s5mr4682816plj.93.1498555751696; Tue, 27 Jun 2017 02:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498555751; cv=none; d=google.com; s=arc-20160816; b=hXsQLheijGkOfvyQwMrO8dN9LytZTX1qeibvLeZmBKlizlMaBx7tErB3HDL1XkHzGj 0rPxrswNpwQ6Nxa9omDyJCfw1IlLgrL80UCeZ7Tst6T/5mb9MPuHHvoSHBl7EjpWOe/+ qooVBgqjvFkyBWUKAuTSvPRW2hotiR3h7CJeQGBuEFW6OdvJxFv4powBOE7Ww/Ta40EE EXy8lm1uktcL2VmWayvbcr2mIg4N3EJbz+l2viH8pZy274WRd6BjAmmbwWZfWrtzUmnP nuVj/4wxAMPsyGkTcJHzGE4rH7fAqFbmJ8w46qjQq6R5JmHALcfLdXdt7S9K8DD/aI3l 2Ljg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=L2CkwzNMsfr5/Gr6FnB4UNp9MBeBrA+xvmfwvMxCa04=; b=lOKtmtgIJ48507yVuVTcE1DMKfUAGf3ra4VumPJ4uhc6BOQTciII0PKiZnpyMbrWRj BIvzJ3zve/+doPnqQBZ2NWKUyJwMjxG/mjdVVi3Joq/mkmsUJvLvq/LQivT0Y2nzG2UO yZLwdtZ1HgxgTjxB2y6w5/TeZPSLDL9WrxJ7RfnRqz2ngj8tTap5kMMKYwiuYN0ablIl E6qrvhGxfUbVTVprMFRQIVoXndtOFNYb/Awz9YhhPH6K0wV2+8zdaI4YLLLqIh0HCoch wDDWkShrMiSRSGzjHoOSYXuhDU8ZB8VYgnj+nOqzPnpMSBzqdA0UisDGMRUe3dnCDOUm XfYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=CjrZHge9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s80si1603828pfs.171.2017.06.27.02.29.11; Tue, 27 Jun 2017 02:29:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=CjrZHge9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbdF0J3A (ORCPT + 25 others); Tue, 27 Jun 2017 05:29:00 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36640 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752340AbdF0J2b (ORCPT ); Tue, 27 Jun 2017 05:28:31 -0400 Received: by mail-wm0-f41.google.com with SMTP id 62so19023254wmw.1 for ; Tue, 27 Jun 2017 02:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L2CkwzNMsfr5/Gr6FnB4UNp9MBeBrA+xvmfwvMxCa04=; b=CjrZHge9+MiOWRwoHx1+9yAmhXWlMX1bHvlXtefbZbxyYIY4xSeCKUXtjrdPDVqFD0 ihNTLpgfNY84yUamwM29hOAQKrUSVBgWVbB1/3jYYTDr16eI5AfSLnzJo/Hb0ZKPuUwg D1QXipiJh9XB5lhJYesStwGiN5a7zF8OckWSM= 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; bh=L2CkwzNMsfr5/Gr6FnB4UNp9MBeBrA+xvmfwvMxCa04=; b=TC/brAZTNPZwJsC8JaTIYboOZMbnHUgS03XLxaikwJWCLnUBphVqUGAsERNYGAX2LX CIbMTjaLLwToCZQnHxZPLO/ZLf8ZGvkney4GvBK3O1sNunRzIFUNewI6XlaNml4JvH7m iUt4YtbAb1zdqzltKqIiGOo+BIfNhx1F/mHh1DkZzsUMfGRQfTdzhET8UfYBE8XEtGB5 y40VMFkfwsCmIuRUBsW0QbOtcowLZmKZl+Xa90/bEvp9hNwlT4SDYJLb1f/6khhWyG56 kC6F7I+z5LgcDvNOAk4GS4IBQoBTMMWHQbALntJjlPu5cdUa7j7AFdUHNyyX0vUSIq4r oJrA== X-Gm-Message-State: AKS2vOwW7yV+JTSAO5bA9VPZT1eIL4dDhNBnlPwX2W5o0kNe1wvYJ9bS 6VHmuNXDtSMWmN0kGFjXXQ== X-Received: by 10.28.180.66 with SMTP id d63mr2687172wmf.78.1498555710205; Tue, 27 Jun 2017 02:28:30 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:110f:661:6b72:192e]) by smtp.gmail.com with ESMTPSA id g2sm16159798wrg.69.2017.06.27.02.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 02:28:29 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Arvind Yadav Subject: [PATCH 4/5] clocksource/drivers/fsl_ftm_timer: Unmap region obtained by of_iomap Date: Tue, 27 Jun 2017 11:26:59 +0200 Message-Id: <1498555620-25094-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> References: <20170627092239.GE2479@mai> <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arvind Yadav In case of error at init time, rollback iomapping. Signed-off-by: Arvind Yadav Signed-off-by: Daniel Lezcano --- drivers/clocksource/fsl_ftm_timer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c index 3121e2d..3ee7e6f 100644 --- a/drivers/clocksource/fsl_ftm_timer.c +++ b/drivers/clocksource/fsl_ftm_timer.c @@ -329,13 +329,13 @@ static int __init ftm_timer_init(struct device_node *np) priv->clkevt_base = of_iomap(np, 0); if (!priv->clkevt_base) { pr_err("ftm: unable to map event timer registers\n"); - goto err; + goto err_clkevt; } priv->clksrc_base = of_iomap(np, 1); if (!priv->clksrc_base) { pr_err("ftm: unable to map source timer registers\n"); - goto err; + goto err_clksrc; } ret = -EINVAL; @@ -366,6 +366,10 @@ static int __init ftm_timer_init(struct device_node *np) return 0; err: + iounmap(priv->clksrc_base); +err_clksrc: + iounmap(priv->clkevt_base); +err_clkevt: kfree(priv); return ret; } From patchwork Tue Jun 27 09:27:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 106411 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp996434qge; Tue, 27 Jun 2017 02:29:12 -0700 (PDT) X-Received: by 10.98.43.7 with SMTP id r7mr4264455pfr.202.1498555752308; Tue, 27 Jun 2017 02:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498555752; cv=none; d=google.com; s=arc-20160816; b=poUudeq8N6mdSxQz1CzcY3loHjw2yrXpbXnuIni9w9raYgpTGuu0cgLBbgndU0ua21 i1MicbVKIi6B0K+jRtbrya7HHHStnTqRhlrGaNr2kGPeCN4afFAgQ6j+yIiSAvCZTPth lnqH7oNl2qqNmh8+DW7dYuQn6QOaRJ9t3x6TQslhFri0kBqklp197X/szxlFk7dD8Pxc tXGGlbYE63AYkng/qAoSSWtQe4U79Uxw07xo1zmQKMTTOoffFNFxZjklkuiaWelsIQpS /CpVcC+HMwJfViD7Nwg//9BHQdYp/DvlaTBd9fSSpj++C8LiNfqsU51USbo5uWfQgzqu 04sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8orf4WOYqXGvcg504GNypjI8e3BqmZ+VxoGuYxwyolE=; b=WFP0LpcMebW8v4YliAfuFWOEMXeEwWgygIqa8qk2stGFkKXb3k3LRblzvXYHkXgiFe RmYFUwTuJa+sZuZbZ1iyjKjUa0Z6wpkd9I1yeS33RWfKC404/+Xsg53HoQqK72HNrWYn 6HmuRjm9AIRNHgCtYIp4u94ii+T0ZwqPV6Y/GEWQBowCArI6qf6joMpDFBoDmEt8/Z8v NLw153j/CZB9JOZNYvWY2vic140B7AeY70wz0L3kNBB39vt9GIXBzZlBI0tE8GQmHkKB rjY63Rr8IjzHtXvn36MKuMITFtbkc5fbo1L3eGbKG14Ymj4qd+ARm5IQvO0udYfZSwRZ iUPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=R7GnIvZA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s80si1603828pfs.171.2017.06.27.02.29.11; Tue, 27 Jun 2017 02:29:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=R7GnIvZA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684AbdF0J3K (ORCPT + 25 others); Tue, 27 Jun 2017 05:29:10 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36649 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbdF0J2d (ORCPT ); Tue, 27 Jun 2017 05:28:33 -0400 Received: by mail-wm0-f47.google.com with SMTP id 62so19023643wmw.1 for ; Tue, 27 Jun 2017 02:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8orf4WOYqXGvcg504GNypjI8e3BqmZ+VxoGuYxwyolE=; b=R7GnIvZAfMUZ8ugbrKWLOlOi6ysdRyG2aiaCZ71AXkDJXjmKhUn6kje2VuFzkNE7Zq 9exowuNeOHHQAwgApvQ9d6qbqJ0KIh5hXioqG7xhtiqR6635J3c3Qk59PYDYxNGU3oLv LqTY921Etelzdv0mDDYcABnbejUlNIX8IoEq4= 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; bh=8orf4WOYqXGvcg504GNypjI8e3BqmZ+VxoGuYxwyolE=; b=JJi08ggg2qDU9g1wmqRGqzVWKgjQQIaixKLakAHhBVFSsPxg5N7xS744E9fQaq+h6y z9fzyM9INO81UIrZ5l9NEndDT9o/b+YDCtisjms5eFvfTbYaZIgEde5fHR6LnGuo9I9A nkn6PdE78KkI14MXOu40SfvM7tCtQKjkSmagjd1noIiIS9nb5e22YRS750wUMMMFC8+8 xF4TzdCbANk9e5xWluAFgaEd4dtVCyGt1uuguwarx0ecj2fSVbZyddAFAIIWiFuB0Lte UqG2vf2Veay+llWXlhQBx8EfN/uukJ75Nu+vVOasW/XhbKK4TDwhF2KH4D8b77gWP2/3 yI/Q== X-Gm-Message-State: AKS2vOwfL3/pDCHzkmqHZiHfewFNBxnFpV9D2yXqO33ptOMOHDOvtSC7 V4qP+XPGY4UzPCXZ X-Received: by 10.28.136.129 with SMTP id k123mr2437256wmd.14.1498555711355; Tue, 27 Jun 2017 02:28:31 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:110f:661:6b72:192e]) by smtp.gmail.com with ESMTPSA id g2sm16159798wrg.69.2017.06.27.02.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 02:28:30 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Christophe Jaillet Subject: [PATCH 5/5] clocksource/drivers/mips-gic-timer: Fix an error code in 'gic_clocksource_of_init()' Date: Tue, 27 Jun 2017 11:27:00 +0200 Message-Id: <1498555620-25094-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> References: <20170627092239.GE2479@mai> <1498555620-25094-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Jaillet 'clk' is a valid pointer at this point. So calling PTR_ERR on it is pointess. Return the error code from 'clk_prepare_enable()' if it fails instead. Signed-off-by: Christophe JAILLET Signed-off-by: Daniel Lezcano --- drivers/clocksource/mips-gic-timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c index e31e083..17b861e 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c @@ -167,10 +167,11 @@ static int __init gic_clocksource_of_init(struct device_node *node) clk = of_clk_get(node, 0); if (!IS_ERR(clk)) { - if (clk_prepare_enable(clk) < 0) { + ret = clk_prepare_enable(clk); + if (ret < 0) { pr_err("GIC failed to enable clock\n"); clk_put(clk); - return PTR_ERR(clk); + return ret; } gic_frequency = clk_get_rate(clk);