public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: rpurdie@rpsys.net, lenz@cs.wisc.edu,
	kernel list <linux-kernel@vger.kernel.org>,
	Russell King <rmk@arm.linux.org.uk>
Subject: [rfc] separate sharpsl_pm initialization from sysfs code
Date: Thu, 9 Mar 2006 13:42:37 +0100	[thread overview]
Message-ID: <20060309124237.GA3794@elf.ucw.cz> (raw)

Hi!

On collie, battery sensing code is not on platform bus -- it is on
ucb1x00. Is this acceptable way to make sharpsl_pm useful for collie?
It separates code that is bus-independent, so collie can call only
code it needs.

Signed-off-by: Pavel Machek <pavel@suse.cz>

diff --git a/arch/arm/common/sharpsl_pm.c b/arch/arm/common/sharpsl_pm.c
index 978d32e..3482cc0 100644
--- a/arch/arm/common/sharpsl_pm.c
+++ b/arch/arm/common/sharpsl_pm.c
@@ -765,18 +787,13 @@ static void sharpsl_apm_get_power_status
 
 static struct pm_ops sharpsl_pm_ops = {
 	.pm_disk_mode	= PM_DISK_FIRMWARE,
 	.prepare	= pxa_pm_prepare,
 	.enter		= corgi_pxa_pm_enter,
 	.finish		= pxa_pm_finish,
 };
 
-static int __init sharpsl_pm_probe(struct platform_device *pdev)
+int sharpsl_pm_init(void)
 {
-	if (!pdev->dev.platform_data)
-		return -EINVAL;
-
-	sharpsl_pm.dev = &pdev->dev;
-	sharpsl_pm.machinfo = pdev->dev.platform_data;
 	sharpsl_pm.charge_mode = CHRG_OFF;
 	sharpsl_pm.flags = 0;
 
@@ -788,9 +807,6 @@ static int __init sharpsl_pm_probe(struc
 
 	sharpsl_pm.machinfo->init();
 
-	device_create_file(&pdev->dev, &dev_attr_battery_percentage);
-	device_create_file(&pdev->dev, &dev_attr_battery_voltage);
-
 	apm_get_power_status = sharpsl_apm_get_power_status;
 
 	pm_set_ops(&sharpsl_pm_ops);
@@ -800,13 +816,10 @@ static int __init sharpsl_pm_probe(struc
 	return 0;
 }
 
-static int sharpsl_pm_remove(struct platform_device *pdev)
+int sharpsl_pm_done(void)
 {
 	pm_set_ops(NULL);
 
-	device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
-	device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
-
 	sharpsl_pm.machinfo->exit();
 
 	del_timer_sync(&sharpsl_pm.chrg_full_timer);
@@ -815,6 +828,32 @@ static int sharpsl_pm_remove(struct plat
 	return 0;
 }
 
+static int __init sharpsl_pm_probe(struct platform_device *pdev)
+{
+	if (!pdev->dev.platform_data)
+		return -EINVAL;
+
+	sharpsl_pm.dev = &pdev->dev;
+	sharpsl_pm.machinfo = pdev->dev.platform_data;
+
+	sharpsl_pm_init();
+
+	device_create_file(&pdev->dev, &dev_attr_battery_percentage);
+	device_create_file(&pdev->dev, &dev_attr_battery_voltage);
+
+	return 0;
+}
+
+static int sharpsl_pm_remove(struct platform_device *pdev)
+{
+	sharpsl_pm_done();
+
+	device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
+	device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
+
+	return 0;
+}
+
 static struct platform_driver sharpsl_pm_driver = {
 	.probe		= sharpsl_pm_probe,
 	.remove		= sharpsl_pm_remove,

-- 
Web maintainer for suspend.sf.net (www.sf.net/projects/suspend) wanted...

             reply	other threads:[~2006-03-09 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-09 12:42 Pavel Machek [this message]
2006-03-09 13:33 ` [rfc] separate sharpsl_pm initialization from sysfs code Richard Purdie
2006-03-10 18:07   ` Pavel Machek
2006-03-13  0:02     ` Russell King
2006-03-22  9:37       ` Pavel Machek

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=20060309124237.GA3794@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=lenz@cs.wisc.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=rpurdie@rpsys.net \
    /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