Re: [PATCH 6/7] regulator: AXP20x: Add support for regulators subsystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 01, 2014 at 05:45:51PM +0100, Carlo Caione wrote:

> index d59c826..0cef101 100644
> --- a/arch/arm/configs/sunxi_defconfig
> +++ b/arch/arm/configs/sunxi_defconfig
> @@ -69,3 +69,4 @@ CONFIG_NFS_FS=y
>  CONFIG_ROOT_NFS=y
>  CONFIG_NLS=y
>  CONFIG_PRINTK_TIME=y
> +CONFIG_REGULATOR_AXP20X=y

If you want to update the defconfig do it in a separate patch.

> +static int axp20x_set_suspend_voltage(struct regulator_dev *rdev, int uV)
> +{
> +	return regulator_set_voltage_sel_regmap(rdev, 0);
> +}

I'm not entirely clear what this is supposed to do but it's broken - it
both ignores the voltage that is passed in and immediately writes to the
normal voltage select register which will presumably distrupt the system.

> +static int axp20x_io_enable_regmap(struct regulator_dev *rdev)
> +{
> +	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
> +				  rdev->desc->enable_mask, AXP20X_IO_ENABLED);
> +}

Please make some helpers for this (or extend the existing ones to cope
with more than a single bit control) - there's several other devices
which have similar multi-bit controls so we should factor this out
rather than open coding.

> +	np = of_node_get(pdev->dev.parent->of_node);
> +	if (!np)
> +		return 0;
> +
> +	regulators = of_find_node_by_name(np, "regulators");
> +	if (!regulators) {
> +		dev_err(&pdev->dev, "regulators node not found\n");
> +		return -EINVAL;
> +	}

The driver should be able to start up with no configuration provided at
all except for the device being registered - the user won't be able to
change anything but they will be able to read the current state of the
hardware which can be useful for diagnostics.

> +static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
> +{
> +	unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
> +
> +	if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
> +		return -EINVAL;
> +
> +	if (id == AXP20X_DCDC3)
> +		mask = AXP20X_WORKMODE_DCDC3_MASK;
> +
> +	return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
> +}

What is a workmode?

> +		pmic->rdev[i] = regulator_register(&pmic->rdesc[i], &config);
> +		if (IS_ERR(pmic->rdev[i])) {

Use devm_regulator_register() and then you don't need to clean up the
regulators either.

> +static int __init axp20x_regulator_init(void)
> +{
> +	return platform_driver_register(&axp20x_regulator_driver);
> +}
> +
> +subsys_initcall(axp20x_regulator_init);

module_platform_driver().

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux