From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934069AbcAMLu0 (ORCPT ); Wed, 13 Jan 2016 06:50:26 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:16719 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933894AbcAMLuX (ORCPT ); Wed, 13 Jan 2016 06:50:23 -0500 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Wed, 13 Jan 2016 03:45:53 -0800 Message-ID: <5696378B.6070704@nvidia.com> Date: Wed, 13 Jan 2016 17:09:55 +0530 From: Laxman Dewangan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Krzysztof Kozlowski , , , , , , , , , , , CC: , , , , , , , Mallikarjun Kasoju Subject: Re: [PATCH V2 6/6] regulator: max77620: add regulator driver for max77620/max20024 References: <1452590273-16421-1-git-send-email-ldewangan@nvidia.com> <1452590273-16421-7-git-send-email-ldewangan@nvidia.com> <5695A854.60108@samsung.com> In-Reply-To: <5695A854.60108@samsung.com> X-Originating-IP: [10.19.65.30] X-ClientProxiedBy: DRUKMAIL101.nvidia.com (10.25.59.19) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 13 January 2016 06:58 AM, Krzysztof Kozlowski wrote: > On 12.01.2016 18:17, Laxman Dewangan wrote: > + > + ret = of_regulator_match(&pdev->dev, np, max77620_regulator_matches, > + ARRAY_SIZE(max77620_regulator_matches)); > Why not using 'regulators_node' and getting rid of this and some code > below? If you need to parse custom regulator properties use 'of_parse_cb'. > Yaah, this is something new and I think Mark also wanted to do this cleanup on his comment. I did not understand it previously. Looks cool now. However, I have requirement to configure PMIC with some inital setting based on init_data (parsed) before regulator registration happened. Once I move to this new mecahinsm, the inti_data parsing and regulator init happen in the same function. So I need to have one callback from regulator_register to driver. Something below. This will do the pre configuration before regulator_register happena dn machine constraint sets. I can not use the init_data->regulator_init() as I need to have the init data passed to the driver. Created sample patch below. ldewangan@ldewanganubuntu-System-Product-Name:~/upstream/linux-next/linux-next/drivers/regulator$ git diff core.c ../../include/linux/regulator/driver.h diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 3308c6b..aa2ca20 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3899,6 +3899,17 @@ regulator_register(const struct regulator_desc *regulator_desc, rdev->dev.of_node = of_node_get(config->of_node); } + if (init_data && regulator_desc->pre_register_init) { + ret = regulator_desc->pre_register_init(regulator_desc, + config, init_data); + if (ret < 0) { + dev_err(dev, "Pre register failed: %d\n", ret); + kfree(rdev); + kfree(config); + return ERR_PTR(ret); + } + } + mutex_lock(®ulator_list_mutex); mutex_init(&rdev->mutex); diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 16ac9e1..fd1d989 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -280,6 +280,9 @@ struct regulator_desc { int (*of_parse_cb)(struct device_node *, const struct regulator_desc *, struct regulator_config *); + int (*pre_register_init)(const struct regulator_desc *, + struct regulator_config *, + struct regulator_init_data *); int id; bool continuous_voltage_range; unsigned n_voltages;