From patchwork Thu Jul 7 08:01:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71551 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1279163qgy; Thu, 7 Jul 2016 01:22:59 -0700 (PDT) X-Received: by 10.66.121.136 with SMTP id lk8mr49498372pab.51.1467879779459; Thu, 07 Jul 2016 01:22:59 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w85si3084277pfi.6.2016.07.07.01.22.59; Thu, 07 Jul 2016 01:22:59 -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 S1030444AbcGGIW4 (ORCPT + 30 others); Thu, 7 Jul 2016 04:22:56 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37047 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030285AbcGGIEC (ORCPT ); Thu, 7 Jul 2016 04:04:02 -0400 Received: by mail-wm0-f54.google.com with SMTP id a66so21420367wme.0 for ; Thu, 07 Jul 2016 01:04:01 -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=9qa5gru+2A7l9gkuat9yCHZR6gBoZikByuk8O5UzY0o=; b=RouthXdKGW3bFUqyJxsjrtZloysUvSApfOVTyqJ2eflbxNoiPgXVjO6dczsi5m6bKn tcOUceTLp2ehbBCtEhhykyl8TfPQSLpEsssa8HQeKpDQ5ZQpXZeivMQAZjOkQEOGQicm WmA9je5p/E2+VOFPdVrblRt4W2yoHiLJ0k7FM= 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=9qa5gru+2A7l9gkuat9yCHZR6gBoZikByuk8O5UzY0o=; b=OY4AORhKJp29fhRJDm92sCuJ/MZNZVLofPL6iG/H5iI4zEHM1+wPMsElnVDRrNR876 9KSesJiYadJlgmUm0HYDq9QoaNo1rr9DMeNKhLAazJ6DwD74JekAs32DQ/N2QHbzLxjI R985oO4DWCYQpdS4PwXf/Aw+juPS1Tz3E9DRkOXheE3/z+ABINLU89xECoT6GRhUTYRj 29JBqdXr5M2+7vhhTLwIgKqKrlysv/s/aJ/9n9NldgoR9lLu0wRcy1Vs8M+jTML62pkr 1o9m/IaIppe+HyUxKGZNiMQKSVlWBRP4Z8kR4HbfOOQB4A+w7v5seHZ3+f1xa/PeCFCy pP1w== X-Gm-Message-State: ALyK8tJR6+4jL5ZHZsGGrUJ4oOctzOsa6aqF7Zgxa6bYXLWTwGo3RbH6Pj76pclOTtx5drga X-Received: by 10.28.29.146 with SMTP id d140mr1484267wmd.27.1467878640680; Thu, 07 Jul 2016 01:04:00 -0700 (PDT) Received: from localhost.localdomain (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.gmail.com with ESMTPSA id v70sm51327wmf.18.2016.07.07.01.03.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:04:00 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 62/93] clocksource/drivers/vf_pit_timer: Convert init function to return error Date: Thu, 7 Jul 2016 10:01:35 +0200 Message-Id: <1467878526-1238-62-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467878526-1238-1-git-send-email-daniel.lezcano@linaro.org> References: <577E0BED.3020608@linaro.org> <1467878526-1238-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/vf_pit_timer.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/vf_pit_timer.c b/drivers/clocksource/vf_pit_timer.c index a0e6c68..ca4dff4 100644 --- a/drivers/clocksource/vf_pit_timer.c +++ b/drivers/clocksource/vf_pit_timer.c @@ -156,15 +156,18 @@ static int __init pit_clockevent_init(unsigned long rate, int irq) return 0; } -static void __init pit_timer_init(struct device_node *np) +static int __init pit_timer_init(struct device_node *np) { struct clk *pit_clk; void __iomem *timer_base; unsigned long clk_rate; - int irq; + int irq, ret; timer_base = of_iomap(np, 0); - BUG_ON(!timer_base); + if (!timer_base) { + pr_err("Failed to iomap"); + return -ENXIO; + } /* * PIT0 and PIT1 can be chained to build a 64-bit timer, @@ -175,12 +178,16 @@ static void __init pit_timer_init(struct device_node *np) clkevt_base = timer_base + PITn_OFFSET(3); irq = irq_of_parse_and_map(np, 0); - BUG_ON(irq <= 0); + if (irq <= 0) + return -EINVAL; pit_clk = of_clk_get(np, 0); - BUG_ON(IS_ERR(pit_clk)); + if (IS_ERR(pit_clk)) + return PTR_ERR(pit_clk); - BUG_ON(clk_prepare_enable(pit_clk)); + ret = clk_prepare_enable(pit_clk); + if (ret) + return ret; clk_rate = clk_get_rate(pit_clk); cycle_per_jiffy = clk_rate / (HZ); @@ -188,8 +195,10 @@ static void __init pit_timer_init(struct device_node *np) /* enable the pit module */ __raw_writel(~PITMCR_MDIS, timer_base + PITMCR); - BUG_ON(pit_clocksource_init(clk_rate)); + ret = pit_clocksource_init(clk_rate); + if (ret) + return ret; - pit_clockevent_init(clk_rate, irq); + return pit_clockevent_init(clk_rate, irq); } -CLOCKSOURCE_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(vf610, "fsl,vf610-pit", pit_timer_init);