lkml.org 
[lkml]   [2010]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] ACPI / Battery: Return -ENODATA for unknown values in get_property()
    Hi!

    > That's why I suggested to use -ENODATA. :-)
    >
    > Still, if user space has problems with failing reads from the sysfs attributes,
    > it may be better to simply put -1 in there. Patch is appended, please test.

    I'd say that reporting -1 for unknown is ugly. You can have -1A
    current easily (charging at 1A), and I've seen machines reporting <0
    current -- when charging. Logical and well-defined.

    Pavel


    > case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
    > - val->intval = battery->design_voltage * 1000;
    > + if (battery->design_voltage != ACPI_BATTERY_VALUE_UNKNOWN)
    > + val->intval = battery->design_voltage * 1000;
    > break;
    > case POWER_SUPPLY_PROP_VOLTAGE_NOW:
    > - val->intval = battery->voltage_now * 1000;
    > + if (battery->voltage_now != ACPI_BATTERY_VALUE_UNKNOWN)
    > + val->intval = battery->voltage_now * 1000;
    > break;
    > case POWER_SUPPLY_PROP_CURRENT_NOW:
    > case POWER_SUPPLY_PROP_POWER_NOW:
    > - val->intval = battery->rate_now * 1000;
    > + if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN)
    > + val->intval = battery->rate_now * 1000;
    > break;
    > case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
    > case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
    > - val->intval = battery->design_capacity * 1000;
    > + if (battery->design_capacity != ACPI_BATTERY_VALUE_UNKNOWN)
    > + val->intval = battery->design_capacity * 1000;
    > break;
    > case POWER_SUPPLY_PROP_CHARGE_FULL:
    > case POWER_SUPPLY_PROP_ENERGY_FULL:
    > - val->intval = battery->full_charge_capacity * 1000;
    > + if (battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN)
    > + val->intval = battery->full_charge_capacity * 1000;
    > break;
    > case POWER_SUPPLY_PROP_CHARGE_NOW:
    > case POWER_SUPPLY_PROP_ENERGY_NOW:
    > - val->intval = battery->capacity_now * 1000;
    > + if (battery->capacity_now != ACPI_BATTERY_VALUE_UNKNOWN)
    > + val->intval = battery->capacity_now * 1000;
    > break;
    > case POWER_SUPPLY_PROP_MODEL_NAME:
    > val->strval = battery->model_number;
    > --
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.kernel.org
    > More majordomo info at http://vger.kernel.org/majordomo-info.html
    > Please read the FAQ at http://www.tux.org/lkml/

    --
    (english) http://www.livejournal.com/~pavelmachek
    (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


    \
     
     \ /
      Last update: 2010-10-25 15:21    [W:0.024 / U:239.896 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site