All of lore.kernel.org
 help / color / mirror / Atom feed
From: felipe.balbi@nokia.com
To: Linux OMAP Mailing List <linux-omap@vger.kernel.org>
Cc: Felipe Balbi <felipe.balbi@nokia.com>
Subject: [RFC PATCH 36/37] cbus: retu-wtd: convert to platform_driver
Date: Wed,  7 Apr 2010 19:04:27 +0300	[thread overview]
Message-ID: <1270656268-7034-37-git-send-email-felipe.balbi@nokia.com> (raw)
In-Reply-To: <1270656268-7034-1-git-send-email-felipe.balbi@nokia.com>

From: Felipe Balbi <felipe.balbi@nokia.com>

trivial patch converting a device_driver into
platform_driver.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/cbus/retu-wdt.c |   77 +++++++++++++++++++++++++----------------------
 1 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/drivers/cbus/retu-wdt.c b/drivers/cbus/retu-wdt.c
index 763b34f..53bec32 100644
--- a/drivers/cbus/retu-wdt.c
+++ b/drivers/cbus/retu-wdt.c
@@ -252,34 +252,38 @@ static const struct file_operations retu_wdt_fops = {
 
 /*----------------------------------------------------------------------------*/
 
-static int __devinit retu_wdt_probe(struct device *dev)
+static int __devinit retu_wdt_probe(struct platform_device *pdev)
 {
 	struct retu_wdt_dev *wdev;
 	int ret;
 
+	ret = retu_get_status();
+	if (!ret)
+		return -ENODEV;
+
 	wdev = kzalloc(sizeof(struct retu_wdt_dev), GFP_KERNEL);
 	if (!wdev)
 		return -ENOMEM;
 
 	wdev->users = 0;
 
-	ret = device_create_file(dev, &dev_attr_period);
+	ret = device_create_file(&pdev->dev, &dev_attr_period);
 	if (ret) {
 		printk(KERN_ERR "retu_wdt_probe: Error creating "
 					"sys device file: period\n");
 		goto free1;
 	}
 
-	ret = device_create_file(dev, &dev_attr_counter);
+	ret = device_create_file(&pdev->dev, &dev_attr_counter);
 	if (ret) {
 		printk(KERN_ERR "retu_wdt_probe: Error creating "
 					"sys device file: counter\n");
 		goto free2;
 	}
 
-	dev_set_drvdata(dev, wdev);
+	platform_set_drvdata(pdev, wdev);
 	retu_wdt = wdev;
-	wdev->retu_wdt_miscdev.parent = dev;
+	wdev->retu_wdt_miscdev.parent = &pdev->dev;
 	wdev->retu_wdt_miscdev.minor = WATCHDOG_MINOR;
 	wdev->retu_wdt_miscdev.name = "watchdog";
 	wdev->retu_wdt_miscdev.fops = &retu_wdt_fops;
@@ -290,68 +294,69 @@ static int __devinit retu_wdt_probe(struct device *dev)
 
 	setup_timer(&wdev->ping_timer, retu_wdt_set_ping_timer, 1);
 
+	/* passed as module parameter? */
+	ret = retu_modify_counter(counter_param);
+	if (ret == -EINVAL) {
+		ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER);
+		printk(KERN_INFO
+		       "retu_wdt_init: Intializing to default value\n");
+	}
+
 	/* Kick the watchdog for kernel booting to finish */
 	retu_modify_counter(RETU_WDT_MAX_TIMER);
 
+	ret = retu_wdt_ping();
+	if (ret < 0) {
+		printk(KERN_INFO "retu_wdt_init: Failed to ping\n");
+		goto free4;
+	}
+
 	return 0;
 
+free4:
+	misc_deregister(&wdev->retu_wdt_miscdev);
+
 free3:
-	device_remove_file(dev, &dev_attr_counter);
+	device_remove_file(&pdev->dev, &dev_attr_counter);
 
 free2:
-	device_remove_file(dev, &dev_attr_period);
+	device_remove_file(&pdev->dev, &dev_attr_period);
+
 free1:
 	kfree(wdev);
 
 	return ret;
 }
 
-static int __devexit retu_wdt_remove(struct device *dev)
+static int __devexit retu_wdt_remove(struct platform_device *pdev)
 {
 	struct retu_wdt_dev *wdev;
 
-	wdev = dev_get_drvdata(dev);
+	wdev = platform_get_drvdata(pdev);
 	misc_deregister(&(wdev->retu_wdt_miscdev));
-	device_remove_file(dev, &dev_attr_period);
-	device_remove_file(dev, &dev_attr_counter);
+	device_remove_file(&pdev->dev, &dev_attr_period);
+	device_remove_file(&pdev->dev, &dev_attr_counter);
 	kfree(wdev);
 
 	return 0;
 }
 
-static struct device_driver retu_wdt_driver = {
-	.name = "retu-wdt",
-	.bus = &platform_bus_type,
-	.probe = retu_wdt_probe,
-	.remove = __devexit_p(retu_wdt_remove),
+static struct platform_driver retu_wdt_driver = {
+	.probe		= retu_wdt_probe,
+	.remove		= __devexit_p(retu_wdt_remove),
+	.driver		= {
+		.name	= "retu-wdt",
+	},
 };
 
 static int __init retu_wdt_init(void)
 {
-	int ret;
-
-	ret = retu_get_status();
-	if (!ret)
-		return -ENODEV;
-
-	ret = driver_register(&retu_wdt_driver);
-	if (ret)
-		return ret;
-
-	/* passed as module parameter? */
-	ret = retu_modify_counter(counter_param);
-	if (ret == -EINVAL) {
-		ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER);
-		printk(KERN_INFO
-		       "retu_wdt_init: Intializing to default value\n");
-	}
-
-	return retu_wdt_ping();
+	return platform_driver_register(&retu_wdt_driver);
 }
 
 static void __exit retu_wdt_exit(void)
 {
-	driver_unregister(&retu_wdt_driver);
+	platform_driver_unregister(&retu_wdt_driver);
 }
 
 module_init(retu_wdt_init);
-- 
1.7.0.rc0.33.g7c3932


  parent reply	other threads:[~2010-04-07 16:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 16:03 [RFC PATCH 00/37] cbus patches felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 01/37] cbus: convert u32 base to void __iomem *base felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 02/37] cbus: NULL global variable on exit felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 03/37] cbus: checkpatch.pl fix on cbus.c felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 04/37] cbus: don't export the global cbus_host variable felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 05/37] cbus: rely on gpiolib felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 06/37] cbus: no ternary on return felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 07/37] cbus: add read/write flag to cbus_transfer felipe.balbi
2010-04-07 16:03 ` [RFC PATCH 08/37] cbus: don't type case when issuing read/write felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 09/37] cbus: fix a resource leakage felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 10/37] cbus: move cbus_host definition to C source felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 11/37] cbus: handle possible errors on cbus_send/receive_bit felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 12/37] cbus: introduce cbus_send/receive_data wrappers felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 13/37] cbus: add kerneldoc felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 14/37] cbus: retu-wdt: fix compile breakage felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 15/37] cbus: retu: fix compile breakage on retu-headset felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 16/37] cbus: retu: split one MODULE_AUTHOR into several felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 17/37] cbus: retu: don't assing ret inside the if () felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 18/37] cbus: retu: convert printk to dev_* felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 19/37] cbus: retu: convert to a platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 20/37] cbus: tahvo: split MODULE_AUTHOR into several entries felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 21/37] cbus: tahvo: move EXPORT_SYMBOL macros closer to functions felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 22/37] cbus: tahvo: don't assign ret inside if () felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 23/37] cbus: tahvo: convert printk into dev_* felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 24/37] cbus: tahvo: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 25/37] cbus: retu: allocate platform_device for Retu's children felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 26/37] cbus: retu-pwrbutton: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 27/37] cbus: retu-headset: simplify module_init felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 28/37] cbus: retu-rtc: remove platform_device code felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 29/37] cbus: retu-rtc: convert to platform_driver felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 30/37] cbus: retu-rtc: split MODULE_AUTHOR into several entries felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 31/37] cbus: retu-rtc: get rid of globals felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 32/37] cbus: retu-rtc: move retu_rtc_barrier up on source code felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 33/37] cbus: retu-rtc: make checkpatch.pl happy felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 34/37] cbus: retu-rtc: switch to rtc class device felipe.balbi
2010-04-07 16:04 ` [RFC PATCH 35/37] cbus: retu-wdt: remove the platform_device felipe.balbi
2010-04-07 16:04 ` felipe.balbi [this message]
2010-04-07 16:04 ` [RFC PATCH 37/37] cbus: retu-wdt: misc cleanup on retu-wdt driver felipe.balbi
2010-04-08  9:23 ` [RFC PATCH 00/37] cbus patches Tony Lindgren
2010-04-24  0:45   ` Tony Lindgren
2010-04-26  5:25     ` Felipe Balbi

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=1270656268-7034-37-git-send-email-felipe.balbi@nokia.com \
    --to=felipe.balbi@nokia.com \
    --cc=linux-omap@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.