From patchwork Fri Jun 17 10:26:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70309 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp204835qgy; Fri, 17 Jun 2016 03:27:20 -0700 (PDT) X-Received: by 10.98.63.199 with SMTP id z68mr1664113pfj.41.1466159239945; Fri, 17 Jun 2016 03:27:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l190si3836061pfc.53.2016.06.17.03.27.19; Fri, 17 Jun 2016 03:27:19 -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 S933466AbcFQK1R (ORCPT + 30 others); Fri, 17 Jun 2016 06:27:17 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:34028 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932065AbcFQK04 (ORCPT ); Fri, 17 Jun 2016 06:26:56 -0400 Received: by mail-wm0-f54.google.com with SMTP id k184so36881568wme.1 for ; Fri, 17 Jun 2016 03:26:56 -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=o+3CStwOQbIdpQq6dcnk5GmSV6S+bAEt6Aaeqbiqrxs=; b=SWON5XEryg2Jcyilfk42dP5j07z1IEF5ig0FgoEXx6ecnNasGeFmeUhPzjFujb+xvF Oh08chAubF4VTfCh5jDyki0n5n6+m6GTQu7Hytrgajqp1jWM/FJOXI52Ybl7b+oKAxOD LGTm6Tbi4QUw9UMwZtWdByxhX/iYn4jrF8RoA= 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=o+3CStwOQbIdpQq6dcnk5GmSV6S+bAEt6Aaeqbiqrxs=; b=MUUdu6GK0RYF/N3EZEEIJJ2lHBMCsgAEpoQyWYVETFDjVAlvhGkqEKHikbLv4V/27J 4ka/Pp4INsL67Iwxke8x8HTud7JzzefOiXJBtNu+6OK4e+KtVbB6wIvI67wO6e2Dvc9I L7c/EESfdsZvPOoaJjws5Fr6aCE00AB9+o8Ti82IFFIZjI6ULW3mU35JgFI8UkxEW3AU w0k46Xj8NmW4/xDZrcdau9YR/uw4p5PKady+h6urvOxT+oDCqrR8kLb+skG7OuelIBXE wTm1aVyR8ZBIqAvryvey6fStNPmgZsy6KZFU+f5MpDaAdSdTHuLhB88DtyltHm8vwZ3x JuKg== X-Gm-Message-State: ALyK8tKppTKCD0sHMl5+giFZpjDjy42wilSyIi9Ax9WyVoXREtf93oQWYslwjVn8fTvQIuId X-Received: by 10.28.189.130 with SMTP id n124mr20588081wmf.76.1466159215145; Fri, 17 Jun 2016 03:26:55 -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 n66sm19326821wmn.7.2016.06.17.03.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 03:26:54 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, slash.tmp@free.fr, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH V3] clocksource/drivers/tango_xtal: Convert init function to return error Date: Fri, 17 Jun 2016 12:26:37 +0200 Message-Id: <1466159197-23203-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <5763C0BE.8090900@free.fr> References: <5763C0BE.8090900@free.fr> 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/tango_xtal.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/tango_xtal.c b/drivers/clocksource/tango_xtal.c index c407c47..7dc716c 100644 --- a/drivers/clocksource/tango_xtal.c +++ b/drivers/clocksource/tango_xtal.c @@ -19,7 +19,7 @@ static u64 notrace read_sched_clock(void) return read_xtal_counter(); } -static void __init tango_clocksource_init(struct device_node *np) +static int __init tango_clocksource_init(struct device_node *np) { struct clk *clk; int xtal_freq, ret; @@ -27,13 +27,13 @@ static void __init tango_clocksource_init(struct device_node *np) xtal_in_cnt = of_iomap(np, 0); if (xtal_in_cnt == NULL) { pr_err("%s: invalid address\n", np->full_name); - return; + return -ENXIO; } clk = of_clk_get(np, 0); if (IS_ERR(clk)) { pr_err("%s: invalid clock\n", np->full_name); - return; + return PTR_ERR(clk); } xtal_freq = clk_get_rate(clk); @@ -44,11 +44,13 @@ static void __init tango_clocksource_init(struct device_node *np) 32, clocksource_mmio_readl_up); if (ret) { pr_err("%s: registration failed\n", np->full_name); - return; + return ret; } sched_clock_register(read_sched_clock, 32, xtal_freq); register_current_timer_delay(&delay_timer); + + return 0; } -CLOCKSOURCE_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init); +CLOCKSOURCE_OF_DECLARE_RET(tango, "sigma,tick-counter", tango_clocksource_init);