Linux-RTC Archive on lore.kernel.org
 help / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Eddie Huang <eddie.huang@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-rtc@vger.kernel.org, srv_heupstream@mediatek.com
Subject: Re: [PATCH v3 07/10] regulator: mt6358: Add support for MT6358 regulator
Date: Mon, 6 May 2019 12:37:33 +0900
Message-ID: <20190506033733.GH14916@sirena.org.uk> (raw)
In-Reply-To: <20190503093117.54830-8-hsin-hsiung.wang@mediatek.com>

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

On Fri, May 03, 2019 at 05:31:14PM +0800, Hsin-Hsiung Wang wrote:

A few fairly minor things but mostly this looks good.

> +static const u32 vcama1_voltages[] = {
> +	1800000, 2500000, 2700000,
> +	2800000, 2900000, 3000000,
> +};

> +static const u32 vcama2_voltages[] = {
> +	1800000, 2500000, 2700000,
> +	2800000, 2900000, 3000000,
> +};
> +

These two tables look the same?

> +static int mt6358_get_voltage_sel(struct regulator_dev *rdev)
> +{
> +	int idx, ret;
> +	u32 selector;
> +	struct mt6358_regulator_info *info = rdev_get_drvdata(rdev);
> +	const u32 *pvol;
> +
> +	ret = regmap_read(rdev->regmap, info->desc.vsel_reg, &selector);
> +	if (ret != 0) {
> +		dev_info(&rdev->dev,
> +			 "Failed to get mt6358 %s vsel reg: %d\n",
> +			 info->desc.name, ret);
> +		return ret;
> +	}
> +
> +	selector = (selector & info->desc.vsel_mask) >> info->vsel_shift;
> +	pvol = (const u32 *)info->index_table;
> +	ret = -1;
> +	for (idx = 0; idx < info->desc.n_voltages; idx++) {
> +		if (pvol[idx] == selector) {
> +			ret = idx;
> +			break;
> +		}
> +	}
> +
> +	return ret;
> +}

I don't entirely understand what this is intended to do which suggests
it could use some comments.  As far as I can tell it's looking up the
hardware selector in a table and then using the index of the entry in
that table as the selector in order to deal with a sparse set of
selectors, is that right?  You should be able to handle this by having
_list_voltage() return an error code for the invalid selectors though we
don't have helpers for that yet as it's an unusual design.

Also -1 is not a good return value in the case where you fail to do a
mapping, use -EINVAL.

> +	ret = regmap_read(rdev->regmap, info->da_vsel_reg, &regval);
> +	if (ret != 0) {
> +		dev_info(&rdev->dev,
> +			 "Failed to get mt6358 Buck %s vsel reg: %d\n",
> +			 info->desc.name, ret);
> +		return ret;
> +	}

These error messages should be dev_err().

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

  reply index

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03  9:31 [PATCH v3 00/10] Add Support for MediaTek PMIC MT6358 Hsin-Hsiung Wang
2019-05-03  9:31 ` [PATCH v3 01/10] mfd: mt6397: clean up code Hsin-Hsiung Wang
2019-05-03  9:31 ` [PATCH v3 02/10] mfd: mt6397: extract irq related code from core driver Hsin-Hsiung Wang
2019-05-07  5:11   ` Nicolas Boichat
2019-05-07  5:16     ` Nicolas Boichat
2019-05-03  9:31 ` [PATCH v3 03/10] mfd: mt6397: modify suspend/resume behavior Hsin-Hsiung Wang
2019-05-03  9:31 ` [PATCH v3 04/10] dt-bindings: mfd: Add compatible for the MediaTek MT6358 PMIC Hsin-Hsiung Wang
2019-05-07  5:24   ` Nicolas Boichat
2019-05-13 15:04   ` Rob Herring
2019-05-03  9:31 ` [PATCH v3 05/10] regulator: Add document for MT6358 regulator Hsin-Hsiung Wang
2019-05-13 15:06   ` Rob Herring
2019-05-03  9:31 ` [PATCH v3 06/10] mfd: Add support for the MediaTek MT6358 PMIC Hsin-Hsiung Wang
2019-05-07  5:34   ` Nicolas Boichat
2019-05-03  9:31 ` [PATCH v3 07/10] regulator: mt6358: Add support for MT6358 regulator Hsin-Hsiung Wang
2019-05-06  3:37   ` Mark Brown [this message]
2019-05-07  5:40   ` Nicolas Boichat
2019-05-03  9:31 ` [PATCH v3 08/10] arm64: dts: mt6358: add PMIC MT6358 related nodes Hsin-Hsiung Wang
2019-05-08  8:00   ` Ran Bi
2019-05-03  9:31 ` [PATCH v3 09/10] rtc: mt6397: fix alarm register overwrite Hsin-Hsiung Wang
2019-05-03  9:31 ` [PATCH v3 10/10] rtc: Add support for the MediaTek MT6358 RTC Hsin-Hsiung Wang
2019-05-04 14:04   ` Yingjoe Chen

Reply instructions:

You may reply publically 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=20190506033733.GH14916@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eddie.huang@mediatek.com \
    --cc=hsin-hsiung.wang@mediatek.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sean.wang@mediatek.com \
    --cc=srv_heupstream@mediatek.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

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org linux-rtc@archiver.kernel.org
	public-inbox-index linux-rtc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox