From patchwork Sat Apr 27 06:29:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2496691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 40D02DF23A for ; Sat, 27 Apr 2013 06:30:08 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVydx-0002af-9Y; Sat, 27 Apr 2013 06:29:57 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVydu-00029F-Rn; Sat, 27 Apr 2013 06:29:54 +0000 Received: from smtp40.i.mail.ru ([94.100.177.100]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVydq-00028b-Ei for linux-arm-kernel@lists.infradead.org; Sat, 27 Apr 2013 06:29:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=hZOeqJBIbMRI3nXV6p5HtUPWtvMot1ovK5/KgTsYPv8=; b=q3+6CRP3S0pNhzKhjqxAZTtpeK5xXu6hN2ozMRx/13z43sb6CaTql/zHonwfvMbTopz4MAx8K9HpFVnuvsri1EGRj6nElAYp7bGt94DRODYDj7rNcS65fFY5kM4Y3dxWqGjCHZu2+JNJuJJLaEN0WWVvg6qQAYnEqS1fex5AbsQ=; Received: from [188.134.40.128] (port=30729 helo=shc.zet) by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1UVydm-0000qq-VR; Sat, 27 Apr 2013 10:29:47 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/2] regulator: mc13xxx: Add warning of incorrect names of regulators Date: Sat, 27 Apr 2013 10:29:24 +0400 Message-Id: <1367044165-6373-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 X-Spam: Not detected X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130427_022951_116831_607AA521 X-CRM114-Status: GOOD ( 18.13 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Fabio Estevam , Alexander Shiyan , Arnd Bergmann , devicetree-discuss@lists.ozlabs.org, Liam Girdwood , Rob Herring , Olof Johansson , Mark Brown , Rob Landley , Grant Likely , Sascha Hauer X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds a warning about incorrect regulators instead of printing the names of non-information message about the wrong amount. Signed-off-by: Alexander Shiyan --- drivers/regulator/mc13892-regulator.c | 39 +++--------------------------- drivers/regulator/mc13xxx-regulator-core.c | 17 +++++++++---- drivers/regulator/mc13xxx.h | 4 +-- 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 714377c..b716283 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c @@ -536,7 +536,7 @@ static int mc13892_regulator_probe(struct platform_device *pdev) struct mc13xxx_regulator_init_data *mc13xxx_data; struct regulator_config config = { }; int i, ret; - int num_regulators = 0, num_parsed; + int num_regulators = 0; u32 val; num_regulators = mc13xxx_get_num_regulators_dt(pdev); @@ -546,8 +546,6 @@ static int mc13892_regulator_probe(struct platform_device *pdev) if (num_regulators <= 0) return -EINVAL; - num_parsed = num_regulators; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv) + num_regulators * sizeof(priv->regulators[0]), GFP_KERNEL); @@ -590,40 +588,9 @@ static int mc13892_regulator_probe(struct platform_device *pdev) = mc13892_vcam_get_mode; mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators, - ARRAY_SIZE(mc13892_regulators), - &num_parsed); - - /* - * Perform a little sanity check on the regulator tree - if we found - * a number of regulators from mc13xxx_get_num_regulators_dt and - * then parsed a smaller number in mc13xxx_parse_regulators_dt then - * there is a regulator defined in the regulators node which has - * not matched any usable regulator in the driver. In this case, - * there is one missing and what will happen is the first regulator - * will get registered again. - * - * Fix this by basically making our number of registerable regulators - * equal to the number of regulators we parsed. We are allocating - * too much memory for priv, but this is unavoidable at this point. - * - * As an example of how this can happen, try making a typo in your - * regulators node (vviohi {} instead of viohi {}) so that the name - * does not match.. - * - * The check will basically pass for platform data (non-DT) because - * mc13xxx_parse_regulators_dt for !CONFIG_OF will not touch num_parsed. - * - */ - if (num_parsed != num_regulators) { - dev_warn(&pdev->dev, - "parsed %d != regulators %d - check your device tree!\n", - num_parsed, num_regulators); - - num_regulators = num_parsed; - priv->num_regulators = num_regulators; - } + ARRAY_SIZE(mc13892_regulators)); - for (i = 0; i < num_regulators; i++) { + for (i = 0; i < priv->num_regulators; i++) { struct regulator_init_data *init_data; struct regulator_desc *desc; struct device_node *node = NULL; diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 23cf9f9..da48592 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c @@ -180,15 +180,13 @@ EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt); struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( struct platform_device *pdev, struct mc13xxx_regulator *regulators, - int num_regulators, int *num_parsed) + int num_regulators) { struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); struct mc13xxx_regulator_init_data *data, *p; struct device_node *parent, *child; int i, parsed = 0; - *num_parsed = 0; - of_node_get(pdev->dev.parent->of_node); parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators"); if (!parent) @@ -204,10 +202,13 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( p = data; for_each_child_of_node(parent, child) { + int found = 0; + for (i = 0; i < num_regulators; i++) { + if (!regulators[i].desc.name) + continue; if (!of_node_cmp(child->name, regulators[i].desc.name)) { - p->id = i; p->init_data = of_get_regulator_init_data( &pdev->dev, child); @@ -215,13 +216,19 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( p++; parsed++; + found = 1; break; } } + + if (!found) + dev_warn(&pdev->dev, + "Unknown regulator: %s\n", child->name); } of_node_put(parent); - *num_parsed = parsed; + priv->num_regulators = parsed; + return data; } EXPORT_SYMBOL_GPL(mc13xxx_parse_regulators_dt); diff --git a/drivers/regulator/mc13xxx.h b/drivers/regulator/mc13xxx.h index 007f833..06c8903 100644 --- a/drivers/regulator/mc13xxx.h +++ b/drivers/regulator/mc13xxx.h @@ -39,7 +39,7 @@ extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev, extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev); extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( struct platform_device *pdev, struct mc13xxx_regulator *regulators, - int num_regulators, int *num_parsed); + int num_regulators); #else static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) { @@ -48,7 +48,7 @@ static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( struct platform_device *pdev, struct mc13xxx_regulator *regulators, - int num_regulators, int *num_parsed) + int num_regulators) { return NULL; }