lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 25 Oct 2010 15:17:28 +0200
From:	Pavel Machek <pavel@....cz>
To:	"Rafael J. Wysocki" <rjw@...k.pl>
Cc:	Sitsofe Wheeler <sitsofe@...oo.com>,
	Henrique de Moraes Holschuh <hmh@....eng.br>,
	Matthew Garrett <mjg59@...f.ucam.org>,
	Len Brown <lenb@...nel.org>, Zhang Rui <rui.zhang@...el.com>,
	David Zeuthen <davidz@...hat.com>,
	Richard Hughes <richard@...hsie.com>,
	linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [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@...r.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ