From patchwork Thu Jul 31 11:22:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Humberto Naves X-Patchwork-Id: 4655091 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5059AC0338 for ; Thu, 31 Jul 2014 11:23:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73E1E201B4 for ; Thu, 31 Jul 2014 11:23:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9418720158 for ; Thu, 31 Jul 2014 11:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754725AbaGaLXl (ORCPT ); Thu, 31 Jul 2014 07:23:41 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:65428 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382AbaGaLWb (ORCPT ); Thu, 31 Jul 2014 07:22:31 -0400 Received: by mail-wg0-f51.google.com with SMTP id b13so2563878wgh.22 for ; Thu, 31 Jul 2014 04:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=flRjtW7BQdA0eYT3/diaYb+va6DmtrRFc8p7TuZKKcA=; b=qz/fd5Xao7WRQ9OT+DLgaVY0YSSEKV9p5Cjq6IfuYJlUwI3T/ar/pHnpgo81WdL16T a1e5q04KqYn0JPUdxOg1OaXj4/L2OT79CyURwn+4c/WKwfbFKyVy/VOQromKGRf0Muw6 DXAUc7VOsADHaI6JA6vHRKHYCuDNvqpqyOd6Df9LrgTI8i3tQB93r6lsVfNFCwWn7ypQ w451yG4D3lqdEOZ8LiSV4okkT5HZawHm7tXytX9MDQrQO33/XZb1Gb1U1lpgOdJ2soDa UrheXO+GoP7ZV8nwiOs8jquEXv88rcCCmMGsxUA535IGVp0AMvescpSFhcjJmT1fOIIA /xpw== X-Received: by 10.180.221.172 with SMTP id qf12mr14978656wic.18.1406805747225; Thu, 31 Jul 2014 04:22:27 -0700 (PDT) Received: from localhost.localdomain (84-73-200-99.dclient.hispeed.ch. [84.73.200.99]) by mx.google.com with ESMTPSA id cx5sm12713714wjb.8.2014.07.31.04.22.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jul 2014 04:22:26 -0700 (PDT) From: Humberto Silva Naves To: linux-samsung-soc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, Kukjin Kim , Tomasz Figa , Thomas Abraham , Andreas Farber , Randy Dunlap , Ian Campbell , Humberto Silva Naves Subject: [PATCHv2 1/5] clk: samsung: exynos5410: Add NULL pointer checks in clock init Date: Thu, 31 Jul 2014 13:22:08 +0200 Message-Id: <1406805732-17372-2-git-send-email-hsnaves@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1406805732-17372-1-git-send-email-hsnaves@gmail.com> References: <1406805732-17372-1-git-send-email-hsnaves@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added NULL pointer checks for device_node input parameter and for the samsung_clk_provider context returned by samsung_clk_init. Even though the *current* samsung_clk_init function never returns a NULL pointer, it is good to keep this check in place to avoid possible problems in the future due to changes in implementation. That way, we also improve the consistency of the code that performs clock initialization across the different SoCs. Signed-off-by: Humberto Silva Naves --- drivers/clk/samsung/clk-exynos5410.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos5410.c b/drivers/clk/samsung/clk-exynos5410.c index 231475b..bf57c80 100644 --- a/drivers/clk/samsung/clk-exynos5410.c +++ b/drivers/clk/samsung/clk-exynos5410.c @@ -188,11 +188,17 @@ static void __init exynos5410_clk_init(struct device_node *np) struct samsung_clk_provider *ctx; void __iomem *reg_base; - reg_base = of_iomap(np, 0); - if (!reg_base) - panic("%s: failed to map registers\n", __func__); + if (np) { + reg_base = of_iomap(np, 0); + if (!reg_base) + panic("%s: failed to map registers\n", __func__); + } else { + panic("%s: unable to determine soc\n", __func__); + } ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS); + if (!ctx) + panic("%s: unable to allocate context.\n", __func__); samsung_clk_register_pll(ctx, exynos5410_plls, ARRAY_SIZE(exynos5410_plls), reg_base);