From patchwork Tue Jun 13 14:41:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 9784153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 89602602DC for ; Tue, 13 Jun 2017 14:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88BBC2870F for ; Tue, 13 Jun 2017 14:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D6CF28717; Tue, 13 Jun 2017 14:42:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0D9528714 for ; Tue, 13 Jun 2017 14:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753306AbdFMOmD (ORCPT ); Tue, 13 Jun 2017 10:42:03 -0400 Received: from [91.227.64.183] ([91.227.64.183]:52300 "EHLO rere.qmqm.pl" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752854AbdFMOmC (ORCPT ); Tue, 13 Jun 2017 10:42:02 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4DEE62C; Tue, 13 Jun 2017 16:41:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1497364918; bh=8twnTDkZ1F1qZoRpuPZLZgBzaGAbuUWUOwjDP5G61nA=; h=Date:From:Subject:To:In-Reply-To:Cc:From; b=AyFHeWOnhQ2dgz7sRyvL22ErBy1uLsCcRFiegakt6XxfXbzsdGBicYB2wlohuZ0ci JwxUXpOErtrTIy12Dqdfgntjc0q1vItkhE2v4KP7pB6RIxN5mOP+xRash87UA6tii9 THorFr3+c+xKTZaQGPBRktYlwQ5dTLGHf85P+mHdRaRz57QexfStOiPkZFSxUZo71H jcGwxf4ezMieRdRDKV8VjojJaBPnu0e03ZAncAIam1rg6gk8ZK/WOpGWTJ58Net8XA 7VNqsknOKoEsozz2ii3pQ9jsIQc1N4AdiIBWETWnnwSyVnDDnXq54/c+oVhTGD2GUN aBdzH/UaQD6dw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at rere Date: Tue, 13 Jun 2017 16:41:56 +0200 Message-Id: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v2 1/2] regulator: tps65910: check TPS65910_NUM_REGS at build time MIME-Version: 1.0 To: linux-kernel@vger.kernel.org In-Reply-To: <0c5e903eed2005e39bdf7abdd1061dffc078109a.1497361550.git.mirq-linux@rere.qmqm.pl> Cc: Tony Lindgren , Liam Girdwood , Mark Brown , j-keerthy@ti.com, linux-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Check TPS65910_NUM_REGS at build time instead of silently registering not all regulators at runtime. Signed-off-by: Michał Mirosław --- v2: - added commit message drivers/regulator/tps65910-regulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 696116ebdf50a..81672a58fcc23 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -1107,6 +1107,7 @@ static int tps65910_probe(struct platform_device *pdev) switch (tps65910_chip_id(tps65910)) { case TPS65910: + BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65910_regs)); pmic->get_ctrl_reg = &tps65910_get_ctrl_register; pmic->num_regulators = ARRAY_SIZE(tps65910_regs); pmic->ext_sleep_control = tps65910_ext_sleep_control; @@ -1119,6 +1120,7 @@ static int tps65910_probe(struct platform_device *pdev) DCDCCTRL_DCDCCKSYNC_MASK); break; case TPS65911: + BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65911_regs)); pmic->get_ctrl_reg = &tps65911_get_ctrl_register; pmic->num_regulators = ARRAY_SIZE(tps65911_regs); pmic->ext_sleep_control = tps65911_ext_sleep_control; @@ -1144,8 +1146,7 @@ static int tps65910_probe(struct platform_device *pdev) if (!pmic->rdev) return -ENOMEM; - for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; - i++, info++) { + for (i = 0; i < pmic->num_regulators; i++, info++) { /* Register the regulators */ pmic->info[i] = info;