lkml.org 
[lkml]   [2022]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] staging: drivers: regulator: Add MAX77541 Regulator Support
On Wed, 7 Dec 2022 12:08:42 +0300
Okan Sahin <okan.sahin@analog.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@analog.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;
> +}

\
 
 \ /
  Last update: 2022-12-11 13:36    [W:0.453 / U:0.764 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site