public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andres Salomon <dilinger@queued.net>
To: linux-kernel@vger.kernel.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	akpm@linux-foundation.org, cbou@mail.ru
Subject: [PATCH 2/5] power: convert pda_power to the new API
Date: Sun, 16 Dec 2007 21:24:51 -0500	[thread overview]
Message-ID: <20071216212451.0623bfc6@ephemeral> (raw)


Signed-off-by: Andres Salomon <dilinger@debian.org>
---
 drivers/power/pda_power.c |   40 ++++++++++++++++------------------------
 1 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
index c058f28..4012a2f 100644
--- a/drivers/power/pda_power.c
+++ b/drivers/power/pda_power.c
@@ -33,27 +33,23 @@ static struct resource *ac_irq, *usb_irq;
 static struct timer_list charger_timer;
 static struct timer_list supply_timer;
 
-static int pda_power_get_property(struct power_supply *psy,
-				  enum power_supply_property psp,
-				  union power_supply_propval *val)
+static ssize_t pda_power_online(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
-	switch (psp) {
-	case POWER_SUPPLY_PROP_ONLINE:
-		if (psy->type == POWER_SUPPLY_TYPE_MAINS)
-			val->intval = pdata->is_ac_online ?
-				      pdata->is_ac_online() : 0;
-		else
-			val->intval = pdata->is_usb_online ?
-				      pdata->is_usb_online() : 0;
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
+	struct power_supply *psy = dev_get_drvdata(dev);
+	int ret;
+
+	if (psy->type == POWER_SUPPLY_TYPE_MAINS)
+		ret = pdata->is_ac_online ? pdata->is_ac_online() : 0;
+	else
+		ret = pdata->is_usb_online ? pdata->is_usb_online() : 0;
+
+	return sprintf(buf, "%d\n", !!ret);
 }
 
-static enum power_supply_property pda_power_props[] = {
-	POWER_SUPPLY_PROP_ONLINE,
+static struct device_attribute pda_power_props[] = {
+	POWER_SUPPLY_ONLINE(pda_power_online),
+	POWER_SUPPLY_END
 };
 
 static char *pda_power_supplied_to[] = {
@@ -67,18 +63,14 @@ static struct power_supply pda_power_supplies[] = {
 		.type = POWER_SUPPLY_TYPE_MAINS,
 		.supplied_to = pda_power_supplied_to,
 		.num_supplicants = ARRAY_SIZE(pda_power_supplied_to),
-		.properties = pda_power_props,
-		.num_properties = ARRAY_SIZE(pda_power_props),
-		.get_property = pda_power_get_property,
+		.props = (struct device_attribute **) &pda_power_props,
 	},
 	{
 		.name = "usb",
 		.type = POWER_SUPPLY_TYPE_USB,
 		.supplied_to = pda_power_supplied_to,
 		.num_supplicants = ARRAY_SIZE(pda_power_supplied_to),
-		.properties = pda_power_props,
-		.num_properties = ARRAY_SIZE(pda_power_props),
-		.get_property = pda_power_get_property,
+		.props = (struct device_attribute **) &pda_power_props,
 	},
 };
 
-- 
1.5.3.5


                 reply	other threads:[~2007-12-17  2:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20071216212451.0623bfc6@ephemeral \
    --to=dilinger@queued.net \
    --cc=akpm@linux-foundation.org \
    --cc=cbou@mail.ru \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /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