public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Sitsofe Wheeler <sitsofe@yahoo.com>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	David Zeuthen <davidz@redhat.com>,
	Richard Hughes <richard@hughsie.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ACPI / Battery: Return -ENODATA for unknown values in get_property()
Date: Mon, 25 Oct 2010 15:17:28 +0200	[thread overview]
Message-ID: <20101025131728.GC2162@ucw.cz> (raw)
In-Reply-To: <201010172032.43206.rjw@sisk.pl>

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

  parent reply	other threads:[~2010-10-25 13:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-16 14:13 Returning ACPI_BATTERY_VALUE_UNKNOWN to userspace Sitsofe Wheeler
2010-10-16 23:05 ` [PATCH] ACPI / Battery: Return -ENODATA for unknown values in get_property() (was: Re: Returning ACPI_BATTERY ...) Rafael J. Wysocki
2010-10-17  5:19   ` Henrique de Moraes Holschuh
2010-10-17  9:59     ` [PATCH] ACPI / Battery: Return -ENODATA for unknown values in get_property() Sitsofe Wheeler
2010-10-17 13:10       ` Henrique de Moraes Holschuh
2010-10-17 14:50         ` Sitsofe Wheeler
2010-10-17 18:32           ` Rafael J. Wysocki
2010-10-21 16:54             ` Sitsofe Wheeler
2010-10-21 19:57               ` Rafael J. Wysocki
2010-10-21 20:46                 ` Sitsofe Wheeler
2010-10-22 22:19                   ` Rafael J. Wysocki
2010-10-23 15:36                     ` Sitsofe Wheeler
2010-10-23 17:31                       ` Rafael J. Wysocki
2010-10-22 12:31               ` Richard Hughes
2010-10-23 15:43                 ` Sitsofe Wheeler
2010-10-25 13:17             ` Pavel Machek [this message]
2010-10-25 20:36               ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101025131728.GC2162@ucw.cz \
    --to=pavel@ucw.cz \
    --cc=davidz@redhat.com \
    --cc=hmh@hmh.eng.br \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=richard@hughsie.com \
    --cc=rjw@sisk.pl \
    --cc=rui.zhang@intel.com \
    --cc=sitsofe@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox