Re: [PATCH] Add support for power_supply on tosa

Andrew Morton
2008-07-01T21:32:58Z

On Fri, 20 Jun 2008 12:49:17 +0400
Dmitry Baryshkov <dbaryshkov@gmail.com> wrote:

> Support the battery management on Sharp Zaurus SL-6000.
>
> This patch depends on the tc6393xb support as found in the arm:devel
> or linux-next trees.

Which means that Anton can't really merge it into his tree, I guess.
I'll babysit it untilthe appropriate time.

> +static unsigned long tosa_read_bat(struct tosa_bat *bat)
> +{
> + unsigned long value = 0;
> +
> + if (bat->gpio_bat < 0 || bat->adc_bat < 0)
> + return 0;
> +
> + mutex_lock(&bat_lock);
> + gpio_set_value(bat->gpio_bat, 1);
> + mdelay(5);

msleep() is preferred over a busywait.

> + value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
> + bat->adc_bat);
> + gpio_set_value(bat->gpio_bat, 0);
> + mutex_unlock(&bat_lock);
> +
> + value = value * 1000000 / bat->adc_bat_divider;
> +
> + return value;
> +}
> +
> +static unsigned long tosa_read_temp(struct tosa_bat *bat)
> +{
> + unsigned long value = 0;
> +
> + if (bat->gpio_temp < 0 || bat->adc_temp < 0)
> + return 0;
> +
> + mutex_lock(&bat_lock);
> + gpio_set_value(bat->gpio_temp, 1);
> + mdelay(5);

ditto. (and elsewhere)