[PATCH v2 2/3] Add s3c-adc-battery driver
Anton Vorontsov
cbouatmailru at gmail.com
Tue Jul 13 14:27:06 EDT 2010
On Sat, Jul 10, 2010 at 07:57:48PM +0300, Vasily Khoruzhick wrote:
> s3c-adc-battery is driver for monitoring
> and charging battery on iPAQ H1930/H1940/RX1950.
> It depends on s3c-adc driver to get battery voltage and current.
>
> Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>
[...]
> +static enum power_supply_property s3c_adc_backup_bat_props[] = {
> + POWER_SUPPLY_PROP_VOLTAGE_NOW,
> + POWER_SUPPLY_PROP_VOLTAGE_MIN,
> + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
> +};
> +
> +static int s3c_adc_backup_bat_get_property(struct power_supply *psy,
> + enum power_supply_property psp,
> + union power_supply_propval *val);
Do you really need this forward decl? I think you can just rearrange
the code to avoid it.
> +static struct s3c_adc_bat backup_bat = {
> + .psy = {
> + .name = "backup-battery",
> + .type = POWER_SUPPLY_TYPE_BATTERY,
> + .properties = s3c_adc_backup_bat_props,
> + .num_properties = ARRAY_SIZE(s3c_adc_backup_bat_props),
> + .get_property = s3c_adc_backup_bat_get_property,
> + .use_for_apm = 1,
> + },
> +};
> +
> +static enum power_supply_property s3c_adc_main_bat_props[] = {
> + POWER_SUPPLY_PROP_STATUS,
> + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
> + POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
> + POWER_SUPPLY_PROP_CHARGE_NOW,
> + POWER_SUPPLY_PROP_VOLTAGE_NOW,
> + POWER_SUPPLY_PROP_CURRENT_NOW,
> +};
> +
> +static int s3c_adc_bat_get_property(struct power_supply *psy,
> + enum power_supply_property psp,
> + union power_supply_propval *val);
Ditto.
[...]
> +static void s3c_adc_bat_work(struct work_struct *work)
> +{
> + struct s3c_adc_bat *bat = &main_bat;
> + int is_charged;
> + int is_plugged;
> + static int was_plugged;
> +
> + is_plugged = power_supply_am_i_supplied(&bat->psy);
Nice, isn't it? :-)
--
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2
More information about the linux-arm-kernel
mailing list