From patchwork Tue Jun 28 10:31:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70997 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1509619qgy; Tue, 28 Jun 2016 03:34:21 -0700 (PDT) X-Received: by 10.66.236.133 with SMTP id uu5mr514925pac.35.1467110061255; Tue, 28 Jun 2016 03:34:21 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xa6si33033397pab.117.2016.06.28.03.34.20; Tue, 28 Jun 2016 03:34:21 -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 S1752881AbcF1KeE (ORCPT + 30 others); Tue, 28 Jun 2016 06:34:04 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36016 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752720AbcF1Kd7 (ORCPT ); Tue, 28 Jun 2016 06:33:59 -0400 Received: by mail-wm0-f45.google.com with SMTP id f126so133922213wma.1 for ; Tue, 28 Jun 2016 03:33:59 -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=B0u6DgRP/S7qgnS02SGaoWcATps3H8aHuFF/6SNVe9kc5MVvObkhM7SzCOBDG0zMEK L5DpGyjYs5cNRRbq3nGwUncNyP938u/2cXjaqTCDsAbAKkqBtlrYwSZRu6qP16FyVxR+ N7CILvSi/DPQGVdU9O0BLbKwxU4jpxQ3vlggs= 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=B2Wu5uJ6omvgJSRCx6DIHToMuFOfRAjAAB0BC2pdFT5I7lyJuAgEegnWykQwFY7E8G o0nahwHSeYMwMuoFCfYyrcHFswASCacA7SW6RtQn1Ysw4Px+R9O80oH4viSVOsnuPw3X 3y9L0yiQD4L4qShWSxnpmKhVLrrbDTC8OnAQrNYAUtnHgxFtQ2ctxabcDfHI+ddHFmlW frW+NR3teESY9M7aeDrL4Zw+N/1G8Ju6gIb07302naASrDSe2bnBpWM8s7HN3Khzy1z3 VlLPh0WtXGRAyEtANdJQb8rWUuWeNhdtirSeZJSpAqE+OhAnOBbc5is8986wk+03qyzC L5uw== X-Gm-Message-State: ALyK8tJzBGdfowoxZ+AwYvwGNaOQSasoEqEBueWAAWrmWDKFqlnNQSh1grch7Nxi6r1Q2u9p X-Received: by 10.28.128.69 with SMTP id b66mr7163366wmd.56.1467110038399; Tue, 28 Jun 2016 03:33:58 -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 a84sm5377403wma.0.2016.06.28.03.33.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:57 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 50/92] clocksource/drivers/atmel-pit: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:09 +0200 Message-Id: <1467109911-11060-50-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467109911-11060-1-git-send-email-daniel.lezcano@linaro.org> References: <577251A4.7030508@linaro.org> <1467109911-11060-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);