lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 May 2019 12:37:33 +0900
From:   Mark Brown <broonie@...nel.org>
To:     Hsin-Hsiung Wang <hsin-hsiung.wang@...iatek.com>
Cc:     Lee Jones <lee.jones@...aro.org>, Rob Herring <robh+dt@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Rutland <mark.rutland@....com>,
        Eddie Huang <eddie.huang@...iatek.com>,
        Sean Wang <sean.wang@...iatek.com>,
        Alessandro Zummo <a.zummo@...ertech.it>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-rtc@...r.kernel.org, srv_heupstream@...iatek.com
Subject: Re: [PATCH v3 07/10] regulator: mt6358: Add support for MT6358
 regulator

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().

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ