From patchwork Thu Jul 7 08:01:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71537 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1275548qgy; Thu, 7 Jul 2016 01:13:01 -0700 (PDT) X-Received: by 10.98.73.69 with SMTP id w66mr3082448pfa.104.1467879181809; Thu, 07 Jul 2016 01:13:01 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id wa12si2967963pac.138.2016.07.07.01.13.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 01:13:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bL4P8-00010V-TY; Thu, 07 Jul 2016 08:11:27 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bL4IT-0005W7-Fp for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2016 08:04:36 +0000 Received: by mail-wm0-x22b.google.com with SMTP id f126so200154101wma.1 for ; Thu, 07 Jul 2016 01:04:13 -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=4JFbBNZlt4QcsZb1EtcCUL96H3F9QNT5dBIIssrTXD8=; b=GwVDy/wgpgNUAVtLlC0ZQg8Y8zDQX0N8HJrAcDAciNnZuqXdhBhJjNbBfTy3aHSP7k 8Wdwcay+yWZeBe2acRD0bAVpTRPIT+Ds5ipmJD0dc+7QQ027lHSaKDyihd9kBEdoL52/ uC7cPPQPw9sG/yI/bYIEQEGumUzVAZjA9ckqs= 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=4JFbBNZlt4QcsZb1EtcCUL96H3F9QNT5dBIIssrTXD8=; b=jDQBiIf8ggZkiMdpihOh3WEazwTpeg5J1MO5/kHsQHdlvzt+xdBv8R9rePopD6k03w 5yG1uHBP+V3ROFLuYH8V6zVhnxEFxkx2oaeIcdPvai4AeVyb7dArW6CRvDTaySMXO8BG FgNBTQJtgTSiy/o5jpPGsK4U+Vxm1rEkpztTBRu0IlIqPnP1YGjKwAYiBH0KB578OmLe F+mCfzP3RUNWsppHaFCviTeqO7yqKNJiqNEOnMvesuq+wpn37gyxHg16PrLLuSCoXYEE dntZoPNmzVawRIwmHvRHxUi5uiNTW8y/BgqBln+FvVIO8xL7369LHfuXZ+7xRngAwa8r vc/A== X-Gm-Message-State: ALyK8tJKm38hLesLRmJbwxR0VtFDBZHurFAHj+IqaEsf2kZYN0syHpuhMOoNtJgtt0rSpM2s X-Received: by 10.194.141.174 with SMTP id rp14mr8581565wjb.7.1467878651956; Thu, 07 Jul 2016 01:04:11 -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.04.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:04:11 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Subject: [PATCH 71/93] clocksource/drivers/oxnas-rps: Convert init function to return error Date: Thu, 7 Jul 2016 10:01:44 +0200 Message-Id: <1467878526-1238-71-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160707_010434_074829_FB27DAF7 X-CRM114-Status: GOOD ( 15.68 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Armstrong MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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 Acked-by: Neil Armstrong --- drivers/clocksource/timer-oxnas-rps.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/clocksource/timer-oxnas-rps.c b/drivers/clocksource/timer-oxnas-rps.c index c002e99..0d99f40 100644 --- a/drivers/clocksource/timer-oxnas-rps.c +++ b/drivers/clocksource/timer-oxnas-rps.c @@ -220,32 +220,37 @@ static int __init oxnas_rps_clocksource_init(struct oxnas_rps_timer *rps) return 0; } -static void __init oxnas_rps_timer_init(struct device_node *np) +static int __init oxnas_rps_timer_init(struct device_node *np) { struct oxnas_rps_timer *rps; void __iomem *base; int ret; rps = kzalloc(sizeof(*rps), GFP_KERNEL); - if (!rps) { - pr_err("Failed to allocate rps structure\n"); - return; - } + if (!rps) + return -ENOMEM; rps->clk = of_clk_get(np, 0); - if (WARN_ON(IS_ERR(rps->clk))) + if (IS_ERR(rps->clk)) { + ret = PTR_ERR(rps->clk); goto err_alloc; + } - if (WARN_ON(clk_prepare_enable(rps->clk))) + ret = clk_prepare_enable(rps->clk); + if (ret) goto err_clk; base = of_iomap(np, 0); - if (WARN_ON(!base)) + if (!base) { + ret = -ENXIO; goto err_clk_prepare; + } rps->irq = irq_of_parse_and_map(np, 0); - if (WARN_ON(rps->irq < 0)) + if (rps->irq < 0) { + ret = -EINVAL; goto err_iomap; + } rps->clkevt_base = base + TIMER1_REG_OFFSET; rps->clksrc_base = base + TIMER2_REG_OFFSET; @@ -261,7 +266,7 @@ static void __init oxnas_rps_timer_init(struct device_node *np) ret = request_irq(rps->irq, oxnas_rps_timer_irq, IRQF_TIMER | IRQF_IRQPOLL, "rps-timer", rps); - if (WARN_ON(ret)) + if (ret) goto err_iomap; ret = oxnas_rps_clocksource_init(rps); @@ -272,7 +277,7 @@ static void __init oxnas_rps_timer_init(struct device_node *np) if (ret) goto err_irqreq; - return; + return 0; err_irqreq: free_irq(rps->irq, rps); @@ -284,7 +289,9 @@ err_clk: clk_put(rps->clk); err_alloc: kfree(rps); + + return ret; } -CLOCKSOURCE_OF_DECLARE(ox810se_rps, - "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(ox810se_rps, + "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init);