From patchwork Wed Jul 25 03:41:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 1235171 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7765F3FD4F for ; Wed, 25 Jul 2012 03:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932815Ab2GYDwv (ORCPT ); Tue, 24 Jul 2012 23:52:51 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:46154 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932804Ab2GYDm2 (ORCPT ); Tue, 24 Jul 2012 23:42:28 -0400 Received: by mail-qc0-f174.google.com with SMTP id o28so169000qcr.19 for ; Tue, 24 Jul 2012 20:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:reply-to:organization; bh=fRGiRhzJ6FfdFbGn/IA6gRjbNO/CsOMxdaVlPsVRlOY=; b=p0mQfz0GldiwrzGp4uKwWJbisY9juwD8zzAG1ngOh/wnMJFDWfnD8O88Me9LeCS5WI TZDSi/c8a+WLYaceoOzWG3JQH20Ph99T8M00QmgHu4c2/vHV+aVPyFfdSYsOyJZbWS58 gkYExC8F8rTo/1lPNJZ8xLc67EBr5BV02m1WdneRDevHIcTgFk7QItEkUuyh6U8U0Avx 2TkDKF2jbOYimzfLx5fd0lFkOkFKQzFzlWaWph0RiHNuIRTC6XKJCZnQ/fwWO3a96FV5 UoDhofugBayVBSpF3vv99d2USaJ0BULyth1JHXXBo+kNszaxpm82pWcY/yaGsa+6cj6F hMFg== Received: by 10.224.42.68 with SMTP id r4mr35565809qae.84.1343187747690; Tue, 24 Jul 2012 20:42:27 -0700 (PDT) Received: from x980.localdomain6 (h184-61-125-197.altnnh.dsl.dynamic.tds.net. [184.61.125.197]) by mx.google.com with ESMTPS id et6sm15489186qab.8.2012.07.24.20.42.26 (version=SSLv3 cipher=OTHER); Tue, 24 Jul 2012 20:42:26 -0700 (PDT) From: Len Brown To: linux-acpi@vger.kernel.org, linux-pm@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, srinivas pandruvada , Len Brown Subject: [PATCH 14/52] ACPI Battery: Added capacity Date: Tue, 24 Jul 2012 23:41:10 -0400 Message-Id: X-Mailer: git-send-email 1.7.12.rc0 In-Reply-To: <1343187708-19532-1-git-send-email-lenb@kernel.org> References: <1343187708-19532-1-git-send-email-lenb@kernel.org> In-Reply-To: <6af1c4fc5227af65092ebc848989693562bfa3e8.1343187617.git.len.brown@intel.com> References: <6af1c4fc5227af65092ebc848989693562bfa3e8.1343187617.git.len.brown@intel.com> Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: srinivas pandruvada Added Capacity field, which is a pre-defined power_supply property. Calculating capacity using current charge/energy and full charge/energy. Some user mode implementations are relying on capacity field to show battery strength and power down decision. Signed-off-by: srinivas pandruvada Signed-off-by: Len Brown --- drivers/acpi/battery.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 7dd3f9f..5662d64 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -250,6 +250,13 @@ static int acpi_battery_get_property(struct power_supply *psy, else val->intval = battery->capacity_now * 1000; break; + case POWER_SUPPLY_PROP_CAPACITY: + if (battery->capacity_now && battery->full_charge_capacity) + val->intval = battery->capacity_now * 100/ + battery->full_charge_capacity; + else + val->intval = 0; + break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = battery->model_number; break; @@ -276,6 +283,7 @@ static enum power_supply_property charge_battery_props[] = { POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_CHARGE_FULL, POWER_SUPPLY_PROP_CHARGE_NOW, + POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_SERIAL_NUMBER, @@ -292,6 +300,7 @@ static enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, POWER_SUPPLY_PROP_ENERGY_FULL, POWER_SUPPLY_PROP_ENERGY_NOW, + POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_SERIAL_NUMBER,