linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: andy.shevchenko@gmail.com
To: Esteban Blanc <eblanc@baylibre.com>
Cc: linus.walleij@linaro.org, lgirdwood@gmail.com,
	broonie@kernel.org, a.zummo@towertech.it,
	alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org,
	jpanis@baylibre.com, jneanne@baylibre.com,
	aseketeli@baylibre.com, sterzik@ti.com, u-kumar1@ti.com
Subject: Re: [PATCH v4 3/3] regulator: tps6594-regulator: Add driver for TI TPS6594 regulators
Date: Fri, 12 May 2023 20:34:47 +0300	[thread overview]
Message-ID: <ZF54t38o2PFsl_oX@surfacebook> (raw)
In-Reply-To: <20230512141755.1712358-4-eblanc@baylibre.com>

Fri, May 12, 2023 at 04:17:55PM +0200, Esteban Blanc kirjoitti:
> From: Jerome Neanne <jneanne@baylibre.com>
> 
> This patch adds support for TPS6594 regulators (bucks and LDOs).
> The output voltages are configurable and are meant to supply power
> to the main processor and other components.
> Bucks can be used in single or multiphase mode, depending on PMIC
> part number.

...

> +	enum {
> +	MULTI_BUCK12,
> +	MULTI_BUCK123,
> +	MULTI_BUCK1234,
> +	MULTI_BUCK12_34,
> +	MULTI_FIRST = MULTI_BUCK12,
> +	MULTI_LAST = MULTI_BUCK12_34,
> +	MULTI_NUM = MULTI_LAST - MULTI_FIRST + 1

Missing TABs?

> +	};

...

> +	for (multi = MULTI_FIRST ; multi < MULTI_NUM ; multi++) {

Just a remark: spaces before ; are not standard.

> +		np = of_find_node_by_name(tps->dev->of_node, multiphases[multi]);
> +		npname = of_node_full_name(np);
> +		np_pmic_parent = of_get_parent(of_get_parent(np));
> +		if (strcmp((of_node_full_name(np_pmic_parent)), tps->dev->of_node->full_name))
> +			continue;

Isn't there an API to compare OF node name with a given parameter?

> +		delta = strcmp(npname, multiphases[multi]);
> +		if (!delta) {
> +			switch (multi) {
> +			case MULTI_BUCK12:
> +				buck_multi[0] = 1;
> +				buck_configured[0] = 1;
> +				buck_configured[1] = 1;
> +				break;
> +			/* multiphase buck34 is supported only with buck12 */
> +			case MULTI_BUCK12_34:
> +				buck_multi[0] = 1;
> +				buck_configured[0] = 1;
> +				buck_configured[1] = 1;

> +				buck_multi[1] = 1;

Might be easier to read if this is grouped with [0] assignment above.

> +				buck_configured[2] = 1;
> +				buck_configured[3] = 1;
> +				break;
> +			case MULTI_BUCK123:
> +				buck_multi[2] = 1;
> +				buck_configured[0] = 1;
> +				buck_configured[1] = 1;
> +				buck_configured[2] = 1;
> +				break;
> +			case MULTI_BUCK1234:
> +				buck_multi[3] = 1;
> +				buck_configured[0] = 1;
> +				buck_configured[1] = 1;
> +				buck_configured[2] = 1;
> +				buck_configured[3] = 1;
> +				break;
> +			}
> +		}
> +	}

...

> +	irq_data = devm_kmalloc(tps->dev,
> +				ARRAY_SIZE(tps6594_bucks_irq_types) *
> +				REGS_INT_NB *
> +				sizeof(struct tps6594_regulator_irq_data) +
> +				ARRAY_SIZE(tps6594_ldos_irq_types) *
> +				REGS_INT_NB *
> +				sizeof(struct tps6594_regulator_irq_data),

We have respective macros in overflow.h that can be used here.

> +				GFP_KERNEL);
> +	if (!irq_data)
> +		return -ENOMEM;

...

> +		rdev = devm_regulator_register(&pdev->dev, &multi_regs[i], &config);
> +		if (IS_ERR(rdev)) {
> +			dev_err(tps->dev, "failed to register %s regulator\n",
> +				pdev->name);
> +			return PTR_ERR(rdev);

		return dev_err_probe(...);
?

> +		}

...

> +		rdev = devm_regulator_register(&pdev->dev, &buck_regs[i], &config);
> +		if (IS_ERR(rdev)) {
> +			dev_err(tps->dev, "failed to register %s regulator\n",
> +				pdev->name);
> +			return PTR_ERR(rdev);

Same question.

> +		}

...

> +			rdev = devm_regulator_register(&pdev->dev, &ldo_regs[i], &config);
> +			if (IS_ERR(rdev)) {
> +				dev_err(tps->dev,
> +					"failed to register %s regulator\n",
> +					pdev->name);
> +				return PTR_ERR(rdev);

Same question.

> +			}

> +	irq_ext_reg_data = devm_kmalloc(tps->dev,
> +					ext_reg_irq_nb *
> +					sizeof(struct tps6594_ext_regulator_irq_data),
> +					GFP_KERNEL);

devm_kmalloc_array()

> +	if (!irq_ext_reg_data)
> +		return -ENOMEM;

...

> +		error = devm_request_threaded_irq(tps->dev, irq, NULL,
> +						  tps6594_regulator_irq_handler,
> +						  IRQF_ONESHOT,
> +						  irq_type->irq_name,
> +						  &irq_ext_reg_data[i]);
> +		if (error) {
> +			dev_err(tps->dev, "failed to request %s IRQ %d: %d\n",
> +				irq_type->irq_name, irq, error);
> +			return error;

	return dev_err_probe(...);

?

> +		}
> +	}
> +	return 0;
> +}

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2023-05-12 17:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12 14:17 [PATCH v4 0/3] TI TPS6594 PMIC support (RTC, pinctrl, regulators) Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 1/3] rtc: tps6594: Add driver for TPS6594 RTC Esteban Blanc
2023-05-12 17:22   ` andy.shevchenko
2023-05-17 16:47     ` Esteban Blanc
2023-05-17 16:52       ` Andy Shevchenko
2023-05-22 11:49         ` Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 2/3] pinctrl: tps6594: Add driver for TPS6594 pinctrl and GPIOs Esteban Blanc
2023-05-12 17:07   ` andy.shevchenko
2023-05-16 13:05     ` Esteban Blanc
2023-05-16 16:48       ` Andy Shevchenko
2023-05-17  9:58         ` Esteban Blanc
2023-05-17 13:51           ` Andy Shevchenko
2023-05-17 14:43             ` Esteban Blanc
2023-05-17 15:04               ` Andy Shevchenko
2023-05-22  8:45                 ` Esteban Blanc
2023-05-23  9:26                 ` Esteban Blanc
2023-05-23 11:03                   ` Andy Shevchenko
2023-05-23 11:32                     ` Esteban Blanc
2023-05-12 14:17 ` [PATCH v4 3/3] regulator: tps6594-regulator: Add driver for TI TPS6594 regulators Esteban Blanc
2023-05-12 17:34   ` andy.shevchenko [this message]

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=ZF54t38o2PFsl_oX@surfacebook \
    --to=andy.shevchenko@gmail.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=aseketeli@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=eblanc@baylibre.com \
    --cc=jneanne@baylibre.com \
    --cc=jpanis@baylibre.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sterzik@ti.com \
    --cc=u-kumar1@ti.com \
    /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).