From patchwork Thu Jul 7 08:00:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71506 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1271192qgy; Thu, 7 Jul 2016 01:03:25 -0700 (PDT) X-Received: by 10.98.24.148 with SMTP id 142mr3006342pfy.52.1467878605660; Thu, 07 Jul 2016 01:03:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si2882401pay.156.2016.07.07.01.03.25; Thu, 07 Jul 2016 01:03:25 -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 S933359AbcGGIDN (ORCPT + 30 others); Thu, 7 Jul 2016 04:03:13 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:36378 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030251AbcGGIC4 (ORCPT ); Thu, 7 Jul 2016 04:02:56 -0400 Received: by mail-wm0-f44.google.com with SMTP id f126so200112032wma.1 for ; Thu, 07 Jul 2016 01:02:55 -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=Rbhh/zUI83Dtals3un+fesnM4sywY2IF6Tw9H3gBjVs=; b=Y0r+N0lzL1HfEvVHbq2TJNEluHWK5GIcdzW4oZaVWmMRpGmnu2sHG5ezh3KbNM81R0 g9sZQD+yIeLhJs1KuVLW4fX5HTQhO1bK0WOotC0PAIm2RChKthpjQWR87o8ZLehibZT/ BbP85FKMf+GG9ijkuYondnkxPm+i9UNxKzg7Y= 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=Rbhh/zUI83Dtals3un+fesnM4sywY2IF6Tw9H3gBjVs=; b=OnOCIkHkpmL+C0/l7+WrOEsjiFBzz+Efol7Q6sK4edYblgnlq3hfUp2uI/r2eNMrJ4 EmqQB1bn/PCIB8g5P/V+uu9lhdSSW+nQSvDjw0Pz80SLpYLmt9YHnzG8PoTcsICOgXgl RVPpeS5qPWoNzLoNMIWjseLL+oa2nuP0fXY2T8sugxAJPYrPPCATl4H4UOQ6PV5Uj5pE obFk1U04mSPxJCbdZAKslONwJaHIG5mG74pnZh32+oL+VNpmjPg36pR+MCQBOyKHzuOb MzWTrannDkP1PNYusrYKsSPT1mfJlN4r4bXdDlxJOE2G/xd5suz0IeEEwJqO/unIlIaZ JcKg== X-Gm-Message-State: ALyK8tLE+KuyBtfLD9+5ZeIOuhXAfHgG5ZQjQhACnye4bNgMaUX94D9dub1mlmEDhis6Wj59 X-Received: by 10.28.209.14 with SMTP id i14mr1432367wmg.95.1467878573802; Thu, 07 Jul 2016 01:02:53 -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.02.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:02:53 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, Patrice Chotard , Maxime Coquelin , linux-arm-kernel@lists.infradead.org, kernel@stlinux.com Subject: [PATCH 18/93] clocksource/drivers/st_lpc: Convert init function to return error Date: Thu, 7 Jul 2016 10:00:51 +0200 Message-Id: <1467878526-1238-18-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 Acked-by: Patrice Chotard Acked-by: Maxime Coquelin --- drivers/clocksource/clksrc_st_lpc.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/clksrc_st_lpc.c b/drivers/clocksource/clksrc_st_lpc.c index 65ec467..c9022a9 100644 --- a/drivers/clocksource/clksrc_st_lpc.c +++ b/drivers/clocksource/clksrc_st_lpc.c @@ -92,7 +92,7 @@ static int __init st_clksrc_setup_clk(struct device_node *np) return 0; } -static void __init st_clksrc_of_register(struct device_node *np) +static int __init st_clksrc_of_register(struct device_node *np) { int ret; uint32_t mode; @@ -100,32 +100,36 @@ static void __init st_clksrc_of_register(struct device_node *np) ret = of_property_read_u32(np, "st,lpc-mode", &mode); if (ret) { pr_err("clksrc-st-lpc: An LPC mode must be provided\n"); - return; + return ret; } /* LPC can either run as a Clocksource or in RTC or WDT mode */ if (mode != ST_LPC_MODE_CLKSRC) - return; + return 0; ddata.base = of_iomap(np, 0); if (!ddata.base) { pr_err("clksrc-st-lpc: Unable to map iomem\n"); - return; + return -ENXIO; } - if (st_clksrc_setup_clk(np)) { + ret = st_clksrc_setup_clk(np); + if (ret) { iounmap(ddata.base); - return; + return ret; } - if (st_clksrc_init()) { + ret = st_clksrc_init(); + if (ret) { clk_disable_unprepare(ddata.clk); clk_put(ddata.clk); iounmap(ddata.base); - return; + return ret; } pr_info("clksrc-st-lpc: clocksource initialised - running @ %luHz\n", clk_get_rate(ddata.clk)); + + return ret; } -CLOCKSOURCE_OF_DECLARE(ddata, "st,stih407-lpc", st_clksrc_of_register); +CLOCKSOURCE_OF_DECLARE_RET(ddata, "st,stih407-lpc", st_clksrc_of_register);