public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [rfc] separate sharpsl_pm initialization from sysfs code
@ 2006-03-09 12:42 Pavel Machek
  2006-03-09 13:33 ` Richard Purdie
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2006-03-09 12:42 UTC (permalink / raw)
  To: rpurdie, lenz, kernel list, Russell King

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...

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

end of thread, other threads:[~2006-03-22  9:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-09 12:42 [rfc] separate sharpsl_pm initialization from sysfs code Pavel Machek
2006-03-09 13:33 ` Richard Purdie
2006-03-10 18:07   ` Pavel Machek
2006-03-13  0:02     ` Russell King
2006-03-22  9:37       ` Pavel Machek

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