public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] olpc_battery: Hide ambient temperature attribute on XO-1.5
@ 2010-12-06 20:35 Daniel Drake
  2010-12-22  0:14 ` Anton Vorontsov
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2010-12-06 20:35 UTC (permalink / raw)
  To: cbou, dwmw2; +Cc: pgf, linux-kernel

This attribute is not available on the XO-1.5 laptop, but remains
functional on the XO-1.

Signed-off-by: Daniel Drake <dsd@laptop.org>
---
 drivers/power/olpc_battery.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 5bc1dcf..8986701 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -204,6 +204,16 @@ static int olpc_bat_get_tech(union power_supply_propval *val)
 /*********************************************************************
  *		Battery properties
  *********************************************************************/
+static bool olpc_bat_property_is_available(struct power_supply *psy,
+					   enum power_supply_property psp)
+{
+	/* Ambient temperature is only available on XO-1 */
+	if (olpc_platform_info.boardrev >= olpc_board_pre(0xd0) &&
+			psp == POWER_SUPPLY_PROP_TEMP_AMBIENT)
+		return false;
+	return true;
+}
+
 static int olpc_bat_get_property(struct power_supply *psy,
 				 enum power_supply_property psp,
 				 union power_supply_propval *val)
@@ -301,7 +311,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
 
 		val->intval = (s16)be16_to_cpu(ec_word) * 100 / 256;
 		break;
-	case POWER_SUPPLY_PROP_TEMP_AMBIENT:
+	case POWER_SUPPLY_PROP_TEMP_AMBIENT: /* XO-1 only */
 		ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
 		if (ret)
 			return ret;
@@ -421,6 +431,7 @@ static struct platform_device *bat_pdev;
 static struct power_supply olpc_bat = {
 	.properties = olpc_bat_props,
 	.num_properties = ARRAY_SIZE(olpc_bat_props),
+	.property_is_available = olpc_bat_property_is_available,
 	.get_property = olpc_bat_get_property,
 	.use_for_apm = 1,
 };
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] olpc_battery: Hide ambient temperature attribute on XO-1.5
  2010-12-06 20:35 [PATCH 2/2] olpc_battery: Hide ambient temperature attribute on XO-1.5 Daniel Drake
@ 2010-12-22  0:14 ` Anton Vorontsov
  0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2010-12-22  0:14 UTC (permalink / raw)
  To: Daniel Drake; +Cc: dwmw2, pgf, linux-kernel

On Mon, Dec 06, 2010 at 08:35:35PM +0000, Daniel Drake wrote:
> This attribute is not available on the XO-1.5 laptop, but remains
> functional on the XO-1.
> 
> Signed-off-by: Daniel Drake <dsd@laptop.org>
> ---

Er.. why just not register the unneeded properties?
I.e. introduce olpc_1_5_bat_props and use it for XO-1.5?

Thanks,

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-22  0:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06 20:35 [PATCH 2/2] olpc_battery: Hide ambient temperature attribute on XO-1.5 Daniel Drake
2010-12-22  0:14 ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox