devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Okan Sahin <okan.sahin@analog.com>
Cc: <outreachy@lists.linux.dev>, Lee Jones <lee@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Marcelo Schmitt <marcelo.schmitt1@gmail.com>,
	ChiYuan Huang <cy_huang@richtek.com>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	Marcus Folkesson <marcus.folkesson@gmail.com>,
	Caleb Connolly <caleb.connolly@linaro.org>,
	Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>,
	Ramona Bolboaca <ramona.bolboaca@analog.com>,
	William Breathitt Gray <william.gray@linaro.org>,
	Manish Narani <manish.narani@xilinx.com>,
	<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-iio@vger.kernel.org>
Subject: Re: [PATCH 3/5] staging: drivers: regulator: Add MAX77541 Regulator Support
Date: Sun, 11 Dec 2022 12:48:17 +0000	[thread overview]
Message-ID: <20221211124817.5bd07ef8@jic23-huawei> (raw)
In-Reply-To: <20221207090906.5896-4-okan.sahin@analog.com>

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;
> +}

  parent reply	other threads:[~2022-12-11 12:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  9:08 [PATCH 0/5] staging: drivers: mfd: Add MAX77541 MFD and related device drivers Okan Sahin
2022-12-07  9:08 ` [PATCH 1/5] staging: drivers: mfd: Add MAX77541/MAX77540 PMIC Support Okan Sahin
2022-12-07 11:24   ` Andy Shevchenko
2022-12-11 12:36   ` Jonathan Cameron
2022-12-07  9:08 ` [PATCH 2/5] staging: dt-bindings: mfd: adi,max77541.yaml Add MAX77541 bindings Okan Sahin
2022-12-07 10:05   ` Krzysztof Kozlowski
2022-12-07 14:19   ` Rob Herring
2022-12-07  9:08 ` [PATCH 3/5] staging: drivers: regulator: Add MAX77541 Regulator Support Okan Sahin
2022-12-07 11:16   ` Andy Shevchenko
2022-12-11 12:48   ` Jonathan Cameron [this message]
2022-12-07  9:08 ` [PATCH 4/5] staging: dt-bindings: regulator: adi,max77541.yaml Add MAX77541 Regulator bindings Okan Sahin
2022-12-07 10:07   ` Krzysztof Kozlowski
2022-12-07 14:19   ` Rob Herring
2022-12-07  9:08 ` [PATCH 5/5] staging: drivers: iio: adc: Adc MAX77541 ADC Support Okan Sahin
2022-12-07 11:30   ` Andy Shevchenko
2022-12-07 12:49   ` kernel test robot
2022-12-11 13:01   ` Jonathan Cameron
2022-12-07 11:09 ` [PATCH 0/5] staging: drivers: mfd: Add MAX77541 MFD and related device drivers Andy Shevchenko
2022-12-11 12:20   ` Jonathan Cameron
2022-12-11 13:34     ` Andy Shevchenko
2022-12-11 14:07       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221211124817.5bd07ef8@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=anand.ashok.dumbre@xilinx.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=caleb.connolly@linaro.org \
    --cc=cy_huang@richtek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manish.narani@xilinx.com \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=marcus.folkesson@gmail.com \
    --cc=okan.sahin@analog.com \
    --cc=outreachy@lists.linux.dev \
    --cc=ramona.bolboaca@analog.com \
    --cc=robh+dt@kernel.org \
    --cc=william.gray@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).