[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221211124817.5bd07ef8@jic23-huawei>
Date: Sun, 11 Dec 2022 12:48:17 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Okan Sahin <okan.sahin@...log.com>
Cc: <outreachy@...ts.linux.dev>, Lee Jones <lee@...nel.org>,
"Rob Herring" <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Marcelo Schmitt <marcelo.schmitt1@...il.com>,
ChiYuan Huang <cy_huang@...htek.com>,
"Geert Uytterhoeven" <geert+renesas@...der.be>,
Marcus Folkesson <marcus.folkesson@...il.com>,
Caleb Connolly <caleb.connolly@...aro.org>,
Anand Ashok Dumbre <anand.ashok.dumbre@...inx.com>,
Ramona Bolboaca <ramona.bolboaca@...log.com>,
William Breathitt Gray <william.gray@...aro.org>,
Manish Narani <manish.narani@...inx.com>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-iio@...r.kernel.org>
Subject: Re: [PATCH 3/5] staging: drivers: regulator: Add MAX77541 Regulator
Support
On Wed, 7 Dec 2022 12:08:42 +0300
Okan Sahin <okan.sahin@...log.com> wrote:
> This patch adds regulator driver for both MAX77541 and MAX77540.
> The MAX77541 is a high-efficiency step-down converter
> with two 3A switching phases for single-cell Li+ battery and 5VDC systems.
>
> The MAX77540 is a high-efficiency step-down converter
> with two 3A switching phases.
>
> Signed-off-by: Okan Sahin <okan.sahin@...log.com>
...
> +static int max77541_regulator_probe(struct platform_device *pdev)
> +{
> + struct max77541_dev *max77541 = dev_get_drvdata(pdev->dev.parent);
> + struct max77541_regulator_dev *regulator;
> + struct regulator_config config = {};
> + struct regulator_dev *rdev;
> + int i;
> +
> + regulator = devm_kzalloc(&pdev->dev, sizeof(*regulator), GFP_KERNEL);
> + if (!regulator)
> + return -ENOMEM;
> +
> + regulator->dev = &pdev->dev;
> + regulator->max77541 = max77541;
> +
> + config.dev = pdev->dev.parent;
> + config.driver_data = regulator;
> + config.regmap = regulator->max77541->regmap;
> +
> + for (i = 0; i < MAX77541_MAX_REGULATORS; i++) {
> + switch (regulator->max77541->type) {
> + case MAX77540:
As in mfd driver, better to move this from code to constant data
by using a chip_info type structure. You could just use the
*_regulator_desc array, but probably better to wrap that in a structure
to reduce difficulty of adding other stuff in future.
> + rdev = devm_regulator_register(&pdev->dev,
> + &max77540_regulators_desc[i], &config);
> + if (IS_ERR(rdev))
> + return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
> + "Failed to register regulator\n");
> + break;
> + case MAX77541:
> + rdev = devm_regulator_register(&pdev->dev,
> + &max77541_regulators_desc[i], &config);
> + if (IS_ERR(rdev))
> + return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
> + "Failed to register regulator\n");
> + break;
> + default:
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
Powered by blists - more mailing lists