From patchwork Thu Jul 7 08:01:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71540 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1276454qgy; Thu, 7 Jul 2016 01:15:25 -0700 (PDT) X-Received: by 10.98.49.133 with SMTP id x127mr3037568pfx.90.1467879325211; Thu, 07 Jul 2016 01:15:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ss9si2865146pab.185.2016.07.07.01.15.24; Thu, 07 Jul 2016 01:15: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 S1030338AbcGGIET (ORCPT + 30 others); Thu, 7 Jul 2016 04:04:19 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:35968 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933582AbcGGIDw (ORCPT ); Thu, 7 Jul 2016 04:03:52 -0400 Received: by mail-wm0-f47.google.com with SMTP id f126so200139179wma.1 for ; Thu, 07 Jul 2016 01:03:51 -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=Rppz3v5gNpusD1VccxqkljhLAz1wr0hTxBbJlb1itzU=; b=GMvKup8WC657HZ7xfVBwVACp8SWnGGJMxaqaZRoJ0Pf5U9RC22ZDQTFA1pv7gIzSW+ MnhGOSkH2ITXfPnFTpxOKFtuL7MUIaerW9z4g9twNvlH9NEPbooMZnDXahsuQkdUdlpJ dF8Pzwb472nl5T1sNWkE+mujMgbwQrThwZDW8= 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=Rppz3v5gNpusD1VccxqkljhLAz1wr0hTxBbJlb1itzU=; b=jg4zg4LucHDEHs9XQHxOp4MV8NBCAOZgoe1I42ZPLZt+z78T2oMWR8B1knbKn++XZN cqhp9SFRgHof3aca9jcSYwpw3OIZZFxUCLySIbhJGK9wqyyNfPWAhB8ACHYkp4AZHKDC log7AKOMTGkdzw39WJkpVWhgbwiGD5AxLljP9P/nuqbBzmj2TN3p7i8oYO0Kdrf2pIZP 5CAL4IxM8Gz7458bWWwtOtUriTtQyZxCYPAri//z9BGJWBLOBq2ykGITtpTt05ItDNtF v/y2/yw3HT3GyriE/eBCSt7aJzA/FGHDM3RdDOtwN4Bq1QwB/PrOHLLkeO1NBVWGFIew P6qw== X-Gm-Message-State: ALyK8tLLcp2svTQcgVO0VX2NBE9Q/sUutKOZOQjIkLDp4yoPORWTKsJa0xZR8QFSaNdySyow X-Received: by 10.28.52.142 with SMTP id b136mr1369918wma.35.1467878625707; Thu, 07 Jul 2016 01:03:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:03:45 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 50/93] clocksource/drivers/atmel-pit: Convert init function to return error Date: Thu, 7 Jul 2016 10:01:23 +0200 Message-Id: <1467878526-1238-50-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/timer-atmel-pit.c | 43 +++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c index d911c5d..ffaca7c 100644 --- a/drivers/clocksource/timer-atmel-pit.c +++ b/drivers/clocksource/timer-atmel-pit.c @@ -177,7 +177,7 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id) /* * Set up both clocksource and clockevent support. */ -static void __init at91sam926x_pit_common_init(struct pit_data *data) +static int __init at91sam926x_pit_common_init(struct pit_data *data) { unsigned long pit_rate; unsigned bits; @@ -204,14 +204,21 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data) data->clksrc.rating = 175; data->clksrc.read = read_pit_clk; data->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS; - clocksource_register_hz(&data->clksrc, pit_rate); + + ret = clocksource_register_hz(&data->clksrc, pit_rate); + if (ret) { + pr_err("Failed to register clocksource"); + return ret; + } /* Set up irq handler */ ret = request_irq(data->irq, at91sam926x_pit_interrupt, IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, "at91_tick", data); - if (ret) - panic(pr_fmt("Unable to setup IRQ\n")); + if (ret) { + pr_err("Unable to setup IRQ\n"); + return ret; + } /* Set up and register clockevents */ data->clkevt.name = "pit"; @@ -226,34 +233,42 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data) data->clkevt.resume = at91sam926x_pit_resume; data->clkevt.suspend = at91sam926x_pit_suspend; clockevents_register_device(&data->clkevt); + + return 0; } -static void __init at91sam926x_pit_dt_init(struct device_node *node) +static int __init at91sam926x_pit_dt_init(struct device_node *node) { struct pit_data *data; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) - panic(pr_fmt("Unable to allocate memory\n")); + return -ENOMEM; data->base = of_iomap(node, 0); - if (!data->base) - panic(pr_fmt("Could not map PIT address\n")); + if (!data->base) { + pr_err("Could not map PIT address\n"); + return -ENXIO; + } data->mck = of_clk_get(node, 0); if (IS_ERR(data->mck)) /* Fallback on clkdev for !CCF-based boards */ data->mck = clk_get(NULL, "mck"); - if (IS_ERR(data->mck)) - panic(pr_fmt("Unable to get mck clk\n")); + if (IS_ERR(data->mck)) { + pr_err("Unable to get mck clk\n"); + return PTR_ERR(data->mck); + } /* Get the interrupts property */ data->irq = irq_of_parse_and_map(node, 0); - if (!data->irq) - panic(pr_fmt("Unable to get IRQ from DT\n")); + if (!data->irq) { + pr_err("Unable to get IRQ from DT\n"); + return -EINVAL; + } - at91sam926x_pit_common_init(data); + return at91sam926x_pit_common_init(data); } -CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", +CLOCKSOURCE_OF_DECLARE_RET(at91sam926x_pit, "atmel,at91sam9260-pit", at91sam926x_pit_dt_init);