[PATCH 2/7] add-powersupply-ac-usb-automonitor.patch
Werner Almesberger
werner at openmoko.org
Tue Sep 23 01:40:09 CEST 2008
Andy Green wrote:
> +static int usb_get_property(struct power_supply *psy,
> + enum power_supply_property psp,
> + union power_supply_propval *val)
> +{
> + int ret = 0;
> + struct bq27000_device_info *di = container_of(psy, struct bq27000_device_info, usb);
> +
> + if (!(di->pdata->hdq_initialized)())
> + return -EINVAL;
> +
> + switch (psp) {
> + case POWER_SUPPLY_PROP_ONLINE:
> + if (di->pdata->get_charger_online_status)
> + val->intval = (di->pdata->get_charger_online_status)();
> + else
> + return -EINVAL;
> + break;
> + default:
> + ret = -EINVAL;
> + break;
> + }
> + return ret;
> +}
This looks a bit chatty. Maybe a future style improvement could look like
this ?
{
struct bq27000_device_info *di = container_of(psy, struct bq27000_device_info, usb);
if (!di->pdata->hdq_initialized())
return -EINVAL;
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
if (!di->pdata->get_charger_online_status)
return -EINVAL;
val->intval = di->pdata->get_charger_online_status();
break;
default:
return -EINVAL;
}
return 0;
}
- Werner
More information about the openmoko-kernel
mailing list