[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y/S2pTZzzHCQzNY3@smile.fi.intel.com>
Date: Tue, 21 Feb 2023 14:18:45 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Okan Sahin <okan.sahin@...log.com>
Cc: 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>,
Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Marcelo Schmitt <marcelo.schmitt1@...il.com>,
ChiYuan Huang <cy_huang@...htek.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
Marcus Folkesson <marcus.folkesson@...il.com>,
William Breathitt Gray <william.gray@...aro.org>,
Ramona Bolboaca <ramona.bolboaca@...log.com>,
Caleb Connolly <caleb.connolly@...aro.org>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org
Subject: Re: [PATCH v5 2/5] regulator: max77541: Add ADI MAX77541/MAX77540
Regulator Support
On Tue, Feb 21, 2023 at 01:39:10PM +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.
...
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2022 Analog Devices, Inc.
> + * ADI Regulator driver for the MAX77540 and MAX77541
> + */
Dunno if Mark requires // comments for regulator new code.
...
> +#include <linux/i2c.h>
Is there any user of this?
...
> +static int max77541_regulator_probe(struct platform_device *pdev)
> +{
> + struct regulator_config config = {};
> + const struct regulator_desc *desc;
> + struct device *dev = &pdev->dev;
> + struct regulator_dev *rdev;
> + struct max77541 *max77541;
> + int i;
unsigned ?
> + max77541 = dev_get_drvdata(dev->parent);
Can be done in definition block (but it's up to you):
struct regulator_config config = {};
const struct regulator_desc *desc;
struct device *dev = &pdev->dev;
struct max77541 *max77541 = dev_get_drvdata(dev->parent);
struct regulator_dev *rdev;
unsigned int i;
> + config.dev = dev->parent;
> +
> + switch (max77541->chip->id) {
> + case MAX77540:
> + desc = max77540_regulators_desc;
> + break;
> + case MAX77541:
> + desc = max77541_regulators_desc;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + for (i = 0; i < MAX77541_MAX_REGULATORS; i++) {
> + rdev = devm_regulator_register(dev, &desc[i], &config);
> + if (IS_ERR(rdev))
> + return dev_err_probe(dev, PTR_ERR(rdev),
> + "Failed to register regulator\n");
> + }
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists