From patchwork Thu Jun 16 21:26:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70259 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp467901qgy; Thu, 16 Jun 2016 14:38:47 -0700 (PDT) X-Received: by 10.98.113.4 with SMTP id m4mr7599773pfc.22.1466113127182; Thu, 16 Jun 2016 14:38:47 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si39455703pab.217.2016.06.16.14.38.46; Thu, 16 Jun 2016 14:38:47 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933335AbcFPVio (ORCPT + 30 others); Thu, 16 Jun 2016 17:38:44 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35914 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755255AbcFPV2l (ORCPT ); Thu, 16 Jun 2016 17:28:41 -0400 Received: by mail-wm0-f48.google.com with SMTP id f126so66408341wma.1 for ; Thu, 16 Jun 2016 14:28:41 -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=jvywPQlM74hHJhGlsH+mSxDQodjnSD4qmOsb/7PiLbE=; b=B0o7XxEse3xfDOXu2yQq9S1TrzLG0s3Zqk7J7YjJuf3gsAGJOmYxCcrtQvAaHfWMhE RWoVKLhxc9lSluSbq9FykSqAfToMspWOH+o8EbUGW1uc9BKBn7d3ZjEp03GrJpppHOo1 izvQpWNT3OqQ9YX1AhY/oJv6VjtDLsu6eIx5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jvywPQlM74hHJhGlsH+mSxDQodjnSD4qmOsb/7PiLbE=; b=KJvCNwknALXmFEI5FjdjhFfsss8Nolt53z6NzyQlO9d7gNOjt1wsn88uBIAMpaHmBb u21ypz5IGZEJ9H0Y25fPIrGxJvPbbt9VMGen9/rB6IqKb3NNmaIeQpCpemlWmX9ckn8t gFuXAKixAF3geu4fUDwr0CPNdmAoJq/0qbyPs8DQGH/eNO7HoVpQZLq+k/GVLK9XmCmw cS5ZJdnkECN0jImsImwTjFbfES56fLIgA/RCogxQqvjcGAtfdrKogR3ekEige3jlJM4W GhU+RqN7B5Z93VWaJJ2pw/Nu4Stcj/cEOO7KlCS9dcMFfxEMFRRlWbKP6orDRYWFgRh5 A3JA== X-Gm-Message-State: ALyK8tL/pvHaeSAp5Mx/ODwD8ZPmYuRbdKjOyeu2OIPoEx+BTVBp5Yvst+nMVrmaKlHLFwKM X-Received: by 10.28.197.132 with SMTP id v126mr6623256wmf.8.1466112520283; Thu, 16 Jun 2016 14:28:40 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id x128sm16705606wmf.6.2016.06.16.14.28.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:39 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH V2 29/63] clocksource/drivers/samsung_pwm_timer: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:48 +0200 Message-Id: <1466112442-31105-30-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> References: <1466112442-31105-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 The init functions do not return any error. They behave as the following: - panic, thus leading to a kernel crash while another timer may work and make the system boot up correctly or - print an error and let the caller unaware if the state of the system Change that by converting the init functions to return an error conforming to the CLOCKSOURCE_OF_RET prototype. Proper error handling (rollback, errno value) will be changed later case by case, thus this change just return back an error or success in the init function. Signed-off-by: Daniel Lezcano --- drivers/clocksource/qcom-timer.c | 27 +++++++++++++++------------ drivers/clocksource/samsung_pwm_timer.c | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/qcom-timer.c b/drivers/clocksource/qcom-timer.c index f8e09f9..79f73bd 100644 --- a/drivers/clocksource/qcom-timer.c +++ b/drivers/clocksource/qcom-timer.c @@ -178,7 +178,7 @@ static struct delay_timer msm_delay_timer = { .read_current_timer = msm_read_current_timer, }; -static void __init msm_timer_init(u32 dgt_hz, int sched_bits, int irq, +static int __init msm_timer_init(u32 dgt_hz, int sched_bits, int irq, bool percpu) { struct clocksource *cs = &msm_clocksource; @@ -218,12 +218,14 @@ err: sched_clock_register(msm_sched_clock_read, sched_bits, dgt_hz); msm_delay_timer.freq = dgt_hz; register_current_timer_delay(&msm_delay_timer); + + return res; } -static void __init msm_dt_timer_init(struct device_node *np) +static int __init msm_dt_timer_init(struct device_node *np) { u32 freq; - int irq; + int irq, ret; struct resource res; u32 percpu_offset; void __iomem *base; @@ -232,34 +234,35 @@ static void __init msm_dt_timer_init(struct device_node *np) base = of_iomap(np, 0); if (!base) { pr_err("Failed to map event base\n"); - return; + return -ENXIO; } /* We use GPT0 for the clockevent */ irq = irq_of_parse_and_map(np, 1); if (irq <= 0) { pr_err("Can't get irq\n"); - return; + return -EINVAL; } /* We use CPU0's DGT for the clocksource */ if (of_property_read_u32(np, "cpu-offset", &percpu_offset)) percpu_offset = 0; - if (of_address_to_resource(np, 0, &res)) { + ret = of_address_to_resource(np, 0, &res); + if (ret) { pr_err("Failed to parse DGT resource\n"); - return; + return ret; } cpu0_base = ioremap(res.start + percpu_offset, resource_size(&res)); if (!cpu0_base) { pr_err("Failed to map source base\n"); - return; + return -EINVAL; } if (of_property_read_u32(np, "clock-frequency", &freq)) { pr_err("Unknown frequency\n"); - return; + return -EINVAL; } event_base = base + 0x4; @@ -268,7 +271,7 @@ static void __init msm_dt_timer_init(struct device_node *np) freq /= 4; writel_relaxed(DGT_CLK_CTL_DIV_4, source_base + DGT_CLK_CTL); - msm_timer_init(freq, 32, irq, !!percpu_offset); + return msm_timer_init(freq, 32, irq, !!percpu_offset); } -CLOCKSOURCE_OF_DECLARE(kpss_timer, "qcom,kpss-timer", msm_dt_timer_init); -CLOCKSOURCE_OF_DECLARE(scss_timer, "qcom,scss-timer", msm_dt_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(kpss_timer, "qcom,kpss-timer", msm_dt_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(scss_timer, "qcom,scss-timer", msm_dt_timer_init); diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index 47e0515..503a2f7 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -499,7 +499,7 @@ static const struct samsung_pwm_variant s5p_variant = { static void __init s5p_pwm_clocksource_init(struct device_node *np) { - samsung_pwm_alloc(np, &s5p_variant); + return samsung_pwm_alloc(np, &s5p_variant); } CLOCKSOURCE_OF_DECLARE(s5pc100_pwm, "samsung,s5pc100-pwm", s5p_pwm_clocksource_init); #endif