From patchwork Wed Oct 29 15:06:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5188811 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 706C39F30B for ; Wed, 29 Oct 2014 15:15:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6989920121 for ; Wed, 29 Oct 2014 15:15:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60D6A200ED for ; Wed, 29 Oct 2014 15:15:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XjUve-0001ML-6I; Wed, 29 Oct 2014 15:12:54 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XjUuM-0008Vi-Oj for linux-arm-kernel@lists.infradead.org; Wed, 29 Oct 2014 15:11:36 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE700MZGOZ73B20@mailout1.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 29 Oct 2014 15:13:55 +0000 (GMT) X-AuditID: cbfec7f4-b7f6c6d00000120b-8f-54510385cfe4 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 3B.47.04619.58301545; Wed, 29 Oct 2014 15:11:01 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NE70053ROU6N540@eusync1.samsung.com>; Wed, 29 Oct 2014 15:11:01 +0000 (GMT) From: Krzysztof Kozlowski To: Samuel Ortiz , Lee Jones , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, Ben Dooks , Kukjin Kim , Russell King , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Subject: [RFT v2 2/8] regulator: max77802: Remove support for board files Date: Wed, 29 Oct 2014 16:06:40 +0100 Message-id: <1414595206-1437-3-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1414595206-1437-1-git-send-email-k.kozlowski@samsung.com> References: <1414595206-1437-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLLMWRmVeSWpSXmKPExsVy+t/xy7qtzIEhBqv7RSw2zljPajFp3QEm i6kPn7BZXP/ynNVi/pFzrBZHfxdYvH5haNG74CqbxdmmN+wW978eZbT4dqWDyWLT42usFpd3 zWGzmHF+H5PF7cu8FmuP3GW3ON3N6iDo0dLcw+bx9/l1Fo+/q14we+ycdZfdY9OqTjaPO9f2 sHnMOxnosXlJvUffllWMHp83yQVwRXHZpKTmZJalFunbJXBlPH0wjb1guUbFlePzmRsYbyh0 MXJySAiYSPx+9JcRwhaTuHBvPVsXIxeHkMBSRom511ZDOX1MEkuPTWAHqWITMJbYvHwJWEJE oJNZoudgLzOIwyywmkni55VTzCBVwgKeEn9mzGEFsVkEVCUutj4Gi/MKuEk8e9QFtU9O4uSx yWA1nALuEgtbPoDFhYBq3i6bxDKBkXcBI8MqRtHU0uSC4qT0XEO94sTc4tK8dL3k/NxNjJAg /7KDcfExq0OMAhyMSjy8DhsDQoRYE8uKK3MPMUpwMCuJ8H7+BRTiTUmsrEotyo8vKs1JLT7E yMTBKdXAWKekoBy8wtVmb62+/Vw7nxDFybsai/7OFlzw/4XcF322UIFpRxYxnepab1v4YR+P 180vvjKmsx+kGqyc3Lju44OM3rXvGZXDYpufN/2zXvYpw+PvowVh++JeCx6QO1+a+jz8kc8X 4VKFF5kyTgvObdnPOblyZ5npi4Y7UoV3//KedLjynblqhhJLcUaioRZzUXEiALOO9IhQAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141029_081134_993237_1C1ECA71 X-CRM114-Status: GOOD ( 20.17 ) X-Spam-Score: -5.6 (-----) Cc: Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Chanwoo Choi , Kyungmin Park , Javier Martinez Canillas , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The driver is used only on Exynos based boards with DTS support. Convert the driver to DTS-only version. Parse all regulators at once, not one-by-one. Remove dependency on data provided by max77686 MFD driver. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/max77802.c | 87 +++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 53 deletions(-) diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index b9958d927297..e3390c7db5ae 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -70,6 +70,7 @@ static unsigned int ramp_table_77802_4bit[] = { }; struct max77802_regulator_prv { + /* Array indexed by regulator id */ unsigned int opmode[MAX77802_REG_MAX]; }; @@ -513,15 +514,14 @@ static struct regulator_desc regulators[] = { regulator_77802_desc_n_ldo(35, 2, 1), }; -#ifdef CONFIG_OF -static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev, - struct max77686_platform_data *pdata) +static int max77802_pmic_dt_parse(struct platform_device *pdev, + struct of_regulator_match *rdata) { struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct device_node *pmic_np, *regulators_np; - struct max77686_regulator_data *rdata; - struct of_regulator_match rmatch; - unsigned int i; + int ret = 0; + + BUILD_BUG_ON(MAX77802_REG_MAX != ARRAY_SIZE(regulators)); pmic_np = iodev->dev->of_node; regulators_np = of_get_child_by_name(pmic_np, "regulators"); @@ -530,55 +530,27 @@ static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev, return -EINVAL; } - pdata->num_regulators = ARRAY_SIZE(regulators); - rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * - pdata->num_regulators, GFP_KERNEL); - if (!rdata) { + ret = of_regulator_match(&pdev->dev, regulators_np, rdata, + MAX77802_REG_MAX); + if (ret < 0) { + dev_err(&pdev->dev, "error parsing regulators data\n"); of_node_put(regulators_np); - return -ENOMEM; - } - - for (i = 0; i < pdata->num_regulators; i++) { - rmatch.name = regulators[i].name; - rmatch.init_data = NULL; - rmatch.of_node = NULL; - if (of_regulator_match(&pdev->dev, regulators_np, &rmatch, - 1) != 1) { - dev_warn(&pdev->dev, "No matching regulator for '%s'\n", - rmatch.name); - continue; - } - rdata[i].initdata = rmatch.init_data; - rdata[i].of_node = rmatch.of_node; - rdata[i].id = regulators[i].id; + return ret; } + /* else: don't care how many regulators were parsed from DTS. */ - pdata->regulators = rdata; of_node_put(regulators_np); return 0; } -#else -static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev, - struct max77686_platform_data *pdata) -{ - return 0; -} -#endif /* CONFIG_OF */ static int max77802_pmic_probe(struct platform_device *pdev) { struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev); struct max77802_regulator_prv *max77802; int i, ret = 0, val; struct regulator_config config = { }; - - /* This is allocated by the MFD driver */ - if (!pdata) { - dev_err(&pdev->dev, "no platform data found for regulator\n"); - return -ENODEV; - } + struct of_regulator_match *rdata; max77802 = devm_kzalloc(&pdev->dev, sizeof(struct max77802_regulator_prv), @@ -586,24 +558,29 @@ static int max77802_pmic_probe(struct platform_device *pdev) if (!max77802) return -ENOMEM; - if (iodev->dev->of_node) { - ret = max77802_pmic_dt_parse_pdata(pdev, pdata); - if (ret) - return ret; - } - config.dev = iodev->dev; config.regmap = iodev->regmap; config.driver_data = max77802; platform_set_drvdata(pdev, max77802); + rdata = kzalloc(sizeof(*rdata) * MAX77802_REG_MAX, GFP_KERNEL); + if (!rdata) + return -ENOMEM; + + for (i = 0; i < MAX77802_REG_MAX; i++) + rdata[i].name = regulators[i].name; + + ret = max77802_pmic_dt_parse(pdev, rdata); + if (ret) + goto out; + for (i = 0; i < MAX77802_REG_MAX; i++) { struct regulator_dev *rdev; - int id = pdata->regulators[i].id; + int id = regulators[i].id; int shift = max77802_get_opmode_shift(id); - config.init_data = pdata->regulators[i].initdata; - config.of_node = pdata->regulators[i].of_node; + config.init_data = rdata[i].init_data; + config.of_node = rdata[i].of_node; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); val = val >> shift & MAX77802_OPMODE_MASK; @@ -621,13 +598,17 @@ static int max77802_pmic_probe(struct platform_device *pdev) rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); dev_err(&pdev->dev, - "regulator init failed for %d\n", i); - return PTR_ERR(rdev); + "regulator init failed for %d: %d\n", i, ret); + goto out; } } - return 0; +out: + kfree(rdata); + + return ret; } static const struct platform_device_id max77802_pmic_id[] = {