Re: [PATCH v3 3/5] drivers: regulator: Add ADI MAX77541/MAX77540 Regulator Support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 18, 2023 at 09:38:10AM +0300, Okan Sahin wrote:
> 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.

...

> + * Copyright (c) 2022 Analog Devices, Inc.

Happy New Year!

...

> +static int max77541_regulator_probe(struct platform_device *pdev)
> +{
> +	struct max77541 *max77541 = dev_get_drvdata(pdev->dev.parent);
> +	struct regulator_config config = {};
> +	const struct regulator_desc *desc;
> +	struct device *dev = &pdev->dev;

You may rearrange this a bit

	struct max77541 *max77541 = dev_get_drvdata(dev->parent);

> +	struct regulator_dev *rdev;
> +	int i;

> +	config.dev = pdev->dev.parent;

dev->parent

> +
> +	if (max77541->id == MAX77540)
> +		desc = max77540_regulators_desc;
> +	else if (max77541->id == MAX77541)
> +		desc = max77541_regulators_desc;
> +	else
> +		return -EINVAL;
> +
> +	for (i = 0; i < MAX77541_MAX_REGULATORS; i++) {

> +		rdev = devm_regulator_register(dev,
> +					       &desc[i], &config);

This is perfectly one line.

> +		if (IS_ERR(rdev))
> +			return dev_err_probe(dev, PTR_ERR(rdev),
> +					     "Failed to register regulator\n");
> +	}
> +
> +	return 0;
> +}

...

> +static const struct of_device_id max77541_regulator_of_id[] = {
> +	{
> +		.compatible = "adi,max77540-regulator",
> +		.data = (void *)MAX77540,
> +	},
> +	{
> +		.compatible = "adi,max77541-regulator",
> +		.data = (void *)MAX77541,
> +	},
> +	{ /* sentinel */  }

As pointed out, better to use pointers directly.

> +};

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux