mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Fabien Parent <fparent@baylibre.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 6/7] regulator: add mt6357 regulator
Date: Tue, 31 May 2022 15:04:01 +0200	[thread overview]
Message-ID: <YpYSQXWU1NlM4JU6@sirena.org.uk> (raw)
In-Reply-To: <20220531124959.202787-7-fparent@baylibre.com>

[-- Attachment #1: Type: text/plain, Size: 2090 bytes --]

On Tue, May 31, 2022 at 02:49:58PM +0200, Fabien Parent wrote:

> @@ -0,0 +1,485 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 MediaTek Inc.
> + * Copyright (c) 2022 BayLibre, SAS.
> + * Author: Chen Zhong <chen.zhong@mediatek.com>
> + * Author: Fabien Parent <fparent@baylibre.com>
> + *
> + * Based on mt6397-regulator.c
> + */

Please make the entire comment a C++ one so things look more
intentional.

> +static int mt6357_set_voltage_sel(struct regulator_dev *rdev,
> +				  unsigned int selector)
> +{
> +	int idx, ret;
> +	const u32 *pvol;
> +	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
> +
> +	pvol = info->index_table;
> +
> +	idx = pvol[selector];
> +	ret = regmap_update_bits(rdev->regmap, info->desc.vsel_reg,
> +				 info->desc.vsel_mask,
> +				 idx << 8);
> +
> +	return ret;
> +}

I don't really understand what's going on with selectors here -
the general idea with selectors is that we just pass the value
that's written to the bitfield around and have mapping functions
which convert to/from voltages.  Here we're mapping the selectors
using this index_table thing which seems like an extra layer of
mapping.  What's the story there?  

I don't see why this can't just use the functions in helpers.c.
It looks like you can use _list_voltage_table() -EINVALs in there
for invalid selectors and _map_voltage_iterate().  Note that
n_voltages is effectively a maximum selector.

> +static int mt6357_get_buck_voltage_sel(struct regulator_dev *rdev)
> +{
> +	int ret, regval;
> +	struct mt6357_regulator_info *info = rdev_get_drvdata(rdev);
> +
> +	ret = regmap_read(rdev->regmap, info->da_vsel_reg, &regval);
> +	if (ret != 0) {
> +		dev_err(&rdev->dev,
> +			"Failed to get mt6357 Buck %s vsel reg: %d\n",
> +			info->desc.name, ret);
> +		return ret;
> +	}
> +
> +	ret = (regval & info->da_vsel_mask) >> info->da_vsel_shift;
> +
> +	return ret;
> +}

This looks like it should just be able to use
regulator_get_voltage_sel_regmap()?

Otherwise this looks good.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-05-31 13:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220531124959.202787-1-fparent@baylibre.com>
2022-05-31 12:49 ` [PATCH 1/7] dt-bindings: mfd: mt6397: add binding for MT6357 Fabien Parent
2022-06-05 21:30   ` Rob Herring
2022-06-15 22:24   ` Lee Jones
2022-05-31 12:49 ` [PATCH 2/7] dt-bindings: input: mtk-pmic-keys: add binding for MT6357 PMIC Fabien Parent
2022-06-05 21:30   ` Rob Herring
2022-05-31 12:49 ` [PATCH 3/7] dt-bindings: regulator: Add binding schema for mt6357 regulators Fabien Parent
2022-05-31 13:06   ` Mark Brown
2022-05-31 12:49 ` [PATCH 4/7] mfd: mt6397-core: add MT6357 PMIC support Fabien Parent
2022-06-15 22:25   ` Lee Jones
2022-05-31 12:49 ` [PATCH 5/7] mfd: mt6358-irq: " Fabien Parent
2022-06-15 22:25   ` Lee Jones
2022-05-31 12:49 ` [PATCH 6/7] regulator: add mt6357 regulator Fabien Parent
2022-05-31 13:04   ` Mark Brown [this message]
2022-05-31 12:49 ` [PATCH 7/7] Input: mtk-pmic-keys: add MT6357 support Fabien Parent

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=YpYSQXWU1NlM4JU6@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=fparent@baylibre.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.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

all inboxes | Powered by JetHome®