From patchwork Thu Jun 16 21:27:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70223 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp464856qgy; Thu, 16 Jun 2016 14:29:52 -0700 (PDT) X-Received: by 10.66.25.231 with SMTP id f7mr7519124pag.65.1466112590935; Thu, 16 Jun 2016 14:29:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n188si7982154pfn.2.2016.06.16.14.29.50; Thu, 16 Jun 2016 14:29:50 -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 S1755349AbcFPV3U (ORCPT + 30 others); Thu, 16 Jun 2016 17:29:20 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36133 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754753AbcFPV3P (ORCPT ); Thu, 16 Jun 2016 17:29:15 -0400 Received: by mail-wm0-f45.google.com with SMTP id f126so66421182wma.1 for ; Thu, 16 Jun 2016 14:29:15 -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=LgbT7auWZxM6lUAo9JR9uoM7u/K6dv/nhBdNnk2Ics0=; b=FPAc0L+zT2kv1hhzD4Q7nUYpEQCtSIV115T7ozNSS1UlXp3ibCc7tinW+aRyG+oF8+ NQoDgVJoD1iKa6IUTZLpwc2DsmYiW8rGHKgBrHVDjQVf/H/zPsXEXrERSYIViV/9HoVK 5rMyhra87OV8LNW+SrraVOsIZjAMA2d9Vw3vk= 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=LgbT7auWZxM6lUAo9JR9uoM7u/K6dv/nhBdNnk2Ics0=; b=bcSGyQvunKfKp5V/JG6EDcwIEw7BOsmbh39ynPhrsqsH4qtu8LjdlReSC6kaJx2FjO 5OS4MLmUlDMipOXoJn1zXloQnpyeegOWxP8VJTF8mpS13E9gR+Ka3HAa5pZEev06vqkr 6zsxzxi1rjNUHcjrDAY9ISL9kvKKCoSz9/BVLudgKD7HMYpPXnlhBTdu0iwNow5FOa+4 /vz7PhsQCp5wTeh9jjN1T1Z52dXhi72K7K1ErO0Brlz96BCQjhY9xKoG+doWYGVzvltu 7L0MQ3njL4RObX1kF+Z9mp7CZ2X9KkmolFnYIH88PDdHjc0/QOAe0LiTyp/FOU7qtcx1 IFHw== X-Gm-Message-State: ALyK8tKJq8tsefcyR/t49rfMYU5XL7g9i9sNAREDRjL9OxwnDEYY77rXVriw+bZZftwYViAx X-Received: by 10.194.139.162 with SMTP id qz2mr1383853wjb.111.1466112554329; Thu, 16 Jun 2016 14:29:14 -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.29.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:29:13 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Tony Prisk , linux-arm-kernel@lists.infradead.org (moderated list:ARM/VT8500 ARM AR...) Subject: [PATCH V2 53/63] clocksource/drivers/vt8500_timer: Convert init function to return error Date: Thu, 16 Jun 2016 23:27:12 +0200 Message-Id: <1466112442-31105-54-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/vt8500_timer.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/vt8500_timer.c b/drivers/clocksource/vt8500_timer.c index ddb4092..1bc8707 100644 --- a/drivers/clocksource/vt8500_timer.c +++ b/drivers/clocksource/vt8500_timer.c @@ -121,38 +121,48 @@ static struct irqaction irq = { .dev_id = &clockevent, }; -static void __init vt8500_timer_init(struct device_node *np) +static int __init vt8500_timer_init(struct device_node *np) { - int timer_irq; + int timer_irq, ret; regbase = of_iomap(np, 0); if (!regbase) { pr_err("%s: Missing iobase description in Device Tree\n", __func__); - return; + return -ENXIO; } + timer_irq = irq_of_parse_and_map(np, 0); if (!timer_irq) { pr_err("%s: Missing irq description in Device Tree\n", __func__); - return; + return -EINVAL; } writel(1, regbase + TIMER_CTRL_VAL); writel(0xf, regbase + TIMER_STATUS_VAL); writel(~0, regbase + TIMER_MATCH_VAL); - if (clocksource_register_hz(&clocksource, VT8500_TIMER_HZ)) + ret = clocksource_register_hz(&clocksource, VT8500_TIMER_HZ); + if (ret) { pr_err("%s: vt8500_timer_init: clocksource_register failed for %s\n", - __func__, clocksource.name); + __func__, clocksource.name); + return ret; + } clockevent.cpumask = cpumask_of(0); - if (setup_irq(timer_irq, &irq)) + ret = setup_irq(timer_irq, &irq); + if (ret) { pr_err("%s: setup_irq failed for %s\n", __func__, clockevent.name); + return ret; + } + clockevents_config_and_register(&clockevent, VT8500_TIMER_HZ, MIN_OSCR_DELTA * 2, 0xf0000000); + + return 0; } -CLOCKSOURCE_OF_DECLARE(vt8500, "via,vt8500-timer", vt8500_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(vt8500, "via,vt8500-timer", vt8500_timer_init);