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]
Message-ID: <20180827121910.GB2448@localhost.localdomain>
Date:   Mon, 27 Aug 2018 15:19:10 +0300
From:   Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
To:     lgirdwood@...il.com, broonie@...nel.org, mazziesaccount@...il.com
Cc:     mikko.mutanen@...rohmeurope.com, heikki.haikola@...rohmeurope.com,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC/PATCH] regulator: Support regulators where voltage ranges
 are selectable

On Wed, Aug 22, 2018 at 02:05:07PM +0300, Matti Vaittinen wrote:
> For example ROHM BD71837 and ROHM BD71847 Power management ICs have
> regulators which provide multiple linear ranges. Ranges can be
> selected by individual non contagious bit in vsel register. Add
> regmap helper functions for selecting ranges.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
[Snip...]
>  
> +static int regulator_range_selector_to_index(struct regulator_dev *rdev,
> +					     unsigned int rval)
> +{
> +	int i;
> +
> +	if (!rdev->desc->linear_range_selectors)
> +		return -EINVAL;
> +
> +	rval &= rdev->desc->vsel_range_mask;
> +
> +	for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
> +		if (rdev->desc->linear_range_selectors[i] == rval)
> +			return i;
> +	}
> +	return -EINVAL;
> +}
> +
> +/**
> + * regulator_get_voltage_sel_pickable_regmap - pickable range get_voltage_sel
> + *
> + * @rdev: regulator to operate on
> + *
> + * Regulators that use regmap for their register I/O and use pickable
> + * ranges can set the vsel_reg, vsel_mask, vsel_range_reg and vsel_range_mask
> + * fields in their descriptor and then use this as their get_voltage_vsel
> + * operation, saving some code.
> + */
> +int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev)
> +{
> +	unsigned int r_val;
> +	unsigned int range;
> +	unsigned int val;
> +	int ret, i;
> +	unsigned int voltages_in_range = 0;
> +
> +	if (!rdev->desc->linear_ranges)
> +		return -EINVAL;
> +
> +	ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
> +	if (ret != 0)
> +		return ret;
> +
> +	ret = regmap_read(rdev->regmap, rdev->desc->vsel_range_reg, &r_val);
> +	if (ret != 0)
> +		return ret;
> +
> +	val &= rdev->desc->vsel_mask;
> +	val >>= ffs(rdev->desc->vsel_mask) - 1;
> +
> +	range = regulator_range_selector_to_index(rdev, r_val);
> +	if (range < 0)
> +		return -EINVAL;

Got buildbot warning for checking whether unsigned int is negative.
I'll fix this one.

Other than that - I have BD71847 support almost finished - should I
send this change as part of that patch set as these helpers would be
used by the BD71847 patch series?

Br,
	Matti Vaittinen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ