Subject: [PATCH] ARM: 3ds_debugboard: Let ethernet be functional again

From: [email-masked] (Sascha Hauer)
Date: Mon, 27 Feb 2012 18:20:20 +0100

On Mon, Feb 27, 2012 at 01:29:08PM +0000, Mark Brown wrote:
> On Mon, Feb 27, 2012 at 10:04:53AM +0100, Sascha Hauer wrote:
> 
> > If I drop the microvolts parameter what microvolts should I assume? I
> > tried 0 but the regulator core does not like it:
> 
> > machine_constraints_voltage: dummy: unsupportable voltage constraints
> 
> > (with max: -2147483648 min: 2147483647)
> 
> I'd expect zero to work, unless something wants a particular voltage in
> which case you really should be filling things in properly.  The fact
> that the fixed voltage regulator supports get_voltage() might be
> confusing things.
> 
> Like I say if people can be bothered filling voltages in I suspect
> they're not your target audience for this.

The culprit is in machine_constraints_voltage:

> 
> 	int     min_uV = INT_MAX;
>         int     max_uV = INT_MIN;
> 
> 	...
> 
> 	/* initial: [cmin..cmax] valid, [min_uV..max_uV] not */
> 	for (i = 0; i < count; i++) {
> 		int     value;
> 
> 		value = ops->list_voltage(rdev, i);
> 		if (value <= 0)
> 			continue;

list_voltage returns 0 if the fixed regulator is initialized to 0
microvolts, so...

> 
> 		/* maybe adjust [min_uV..max_uV] */
> 		if (value >= cmin && value < min_uV)
> 			min_uV = value;
> 		if (value <= cmax && value > max_uV)
> 			max_uV = value;

max_uV/min_uV are not initialized...

> 	}
> 
> 	/* final: [min_uV..max_uV] valid iff constraints valid */
> 	if (max_uV < min_uV) {
> 		rdev_err(rdev, "unsupportable voltage constraints\n");
> 		return -EINVAL;
> 	}

And we end here.

I don't know what to do here. Probably the check for value <= 0 should
be removed, but then again the description shows:

 * @list_voltage: Return one of the supported voltages, in microvolts; zero
 *      if the selector indicates a voltage that is unusable on this system;
 *      or negative errno.  Selectors range from zero to one less than
 *      regulator_desc.n_voltages.  Voltages may be reported in any order.

(I wonder if negative voltages are intentionally not supported)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |