public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru•mvista.com>
To: Kumar Gala <galak@kernel•crashing.org>, Wim Van Sebroeck <wim@iguana•be>
Cc: Stephen Rothwell <sfr@canb•auug.org.au>,
	linuxppc-dev@ozlabs•org, Chen Gong <G.Chen@freescale•com>,
	Scott Wood <scottwood@freescale•com>,
	Timur Tabi <timur@freescale•com>
Subject: [PATCH 2/8] [WATCHDOG] mpc83xx_wdt: convert to the OF platform driver
Date: Thu, 15 May 2008 20:53:49 +0400	[thread overview]
Message-ID: <20080515165349.GB3887@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <20080515165250.GA30738@polina.dev.rtsoft.ru>

This patch simply converts mpc83xx_wdt to the OF platform driver so we
can directly work with the device tree without passing various stuff
through platform data.

Signed-off-by: Anton Vorontsov <avorontsov@ru•mvista.com>
---
 drivers/watchdog/mpc83xx_wdt.c |   62 +++++++++++++++++++--------------------
 1 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/drivers/watchdog/mpc83xx_wdt.c b/drivers/watchdog/mpc83xx_wdt.c
index 6905712..127d85e 100644
--- a/drivers/watchdog/mpc83xx_wdt.c
+++ b/drivers/watchdog/mpc83xx_wdt.c
@@ -19,11 +19,12 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
-#include <linux/platform_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/watchdog.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
+#include <sysdev/fsl_soc.h>
 
 struct mpc83xx_wdt {
 	__be32 res0;
@@ -149,53 +150,42 @@ static struct miscdevice mpc83xx_wdt_miscdev = {
 	.fops	= &mpc83xx_wdt_fops,
 };
 
-static int __devinit mpc83xx_wdt_probe(struct platform_device *dev)
+static int __devinit mpc83xx_wdt_probe(struct of_device *ofdev,
+				       const struct of_device_id *match)
 {
-	struct resource *r;
 	int ret;
-	unsigned int *freq = dev->dev.platform_data;
+	u32 freq = fsl_get_sys_freq();
 
-	/* get a pointer to the register memory */
-	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (!freq || freq == -1)
+		return -EINVAL;
 
-	if (!r) {
-		ret = -ENODEV;
-		goto err_out;
-	}
-
-	wd_base = ioremap(r->start, sizeof(struct mpc83xx_wdt));
-
-	if (wd_base == NULL) {
-		ret = -ENOMEM;
-		goto err_out;
-	}
+	wd_base = of_iomap(ofdev->node, 0);
+	if (!wd_base)
+		return -ENOMEM;
 
 	ret = misc_register(&mpc83xx_wdt_miscdev);
 	if (ret) {
-		printk(KERN_ERR "cannot register miscdev on minor=%d "
-				"(err=%d)\n",
-				WATCHDOG_MINOR, ret);
+		pr_err("cannot register miscdev on minor=%d (err=%d)\n",
+			WATCHDOG_MINOR, ret);
 		goto err_unmap;
 	}
 
 	/* Calculate the timeout in seconds */
 	if (prescale)
-		timeout_sec = (timeout * 0x10000) / (*freq);
+		timeout_sec = (timeout * 0x10000) / freq;
 	else
-		timeout_sec = timeout / (*freq);
+		timeout_sec = timeout / freq;
 
-	printk(KERN_INFO "WDT driver for MPC83xx initialized. "
-		"mode:%s timeout=%d (%d seconds)\n",
-		reset ? "reset":"interrupt", timeout, timeout_sec);
+	pr_info("WDT driver for MPC83xx initialized. mode:%s timeout=%d "
+		"(%d seconds)\n", reset ? "reset" : "interrupt", timeout,
+		timeout_sec);
 	return 0;
-
 err_unmap:
 	iounmap(wd_base);
-err_out:
 	return ret;
 }
 
-static int __devexit mpc83xx_wdt_remove(struct platform_device *dev)
+static int __devexit mpc83xx_wdt_remove(struct of_device *ofdev)
 {
 	misc_deregister(&mpc83xx_wdt_miscdev);
 	iounmap(wd_base);
@@ -203,7 +193,16 @@ static int __devexit mpc83xx_wdt_remove(struct platform_device *dev)
 	return 0;
 }
 
-static struct platform_driver mpc83xx_wdt_driver = {
+static const struct of_device_id mpc83xx_wdt_match[] = {
+	{
+		.compatible = "mpc83xx_wdt",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, mpc83xx_wdt_match);
+
+static struct of_platform_driver mpc83xx_wdt_driver = {
+	.match_table	= mpc83xx_wdt_match,
 	.probe		= mpc83xx_wdt_probe,
 	.remove		= __devexit_p(mpc83xx_wdt_remove),
 	.driver		= {
@@ -214,12 +213,12 @@ static struct platform_driver mpc83xx_wdt_driver = {
 
 static int __init mpc83xx_wdt_init(void)
 {
-	return platform_driver_register(&mpc83xx_wdt_driver);
+	return of_register_platform_driver(&mpc83xx_wdt_driver);
 }
 
 static void __exit mpc83xx_wdt_exit(void)
 {
-	platform_driver_unregister(&mpc83xx_wdt_driver);
+	of_unregister_platform_driver(&mpc83xx_wdt_driver);
 }
 
 module_init(mpc83xx_wdt_init);
@@ -229,4 +228,3 @@ MODULE_AUTHOR("Dave Updegraff, Kumar Gala");
 MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
-MODULE_ALIAS("platform:mpc83xx_wdt");
-- 
1.5.5.1

  parent reply	other threads:[~2008-05-15 16:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 16:52 [PATCH 0/8 v3] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Anton Vorontsov
2008-05-15 16:53 ` [PATCH 1/8] [WATCHDOG] mpc83xx_wdt: fix checkpatch issues Anton Vorontsov
2008-05-15 16:53 ` Anton Vorontsov [this message]
2008-05-16  4:20   ` [PATCH 2/8] [WATCHDOG] mpc83xx_wdt: convert to the OF platform driver Stephen Rothwell
2008-05-15 16:53 ` [PATCH 3/8] [WATCHDOG] mpc83xx_wdt: add support for MPC86xx CPUs Anton Vorontsov
2008-05-15 16:53 ` [PATCH 4/8] [WATCHDOG] mpc83xx_wdt: rename to mpc8xxx_wdt Anton Vorontsov
2008-05-15 16:53 ` [PATCH 5/8] [WATCHDOG] mpc8xxx_wdt: various renames, mostly s/mpc83xx/mpc8xxx/g Anton Vorontsov
2008-05-15 16:54 ` [PATCH 6/8] [WATCHDOG] mpc8xxx_wdt: add support for MPC8xx watchdogs Anton Vorontsov
2008-05-16  9:17   ` Jochen Friedrich
2008-05-16 11:46     ` Anton Vorontsov
2008-05-15 16:54 ` [PATCH 7/8] [POWERPC] fsl_soc: remove mpc83xx_wdt code Anton Vorontsov
2008-05-15 16:54 ` [PATCH 8/8] [POWERPC] 86xx: mpc8610_hpcd: add watchdog node Anton Vorontsov
2008-05-15 21:21 ` [PATCH 0/8 v3] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Jochen Friedrich
  -- strict thread matches above, loose matches on Subject: below --
2008-05-19 18:37 [PATCH 0/8 v4] " Anton Vorontsov
2008-05-19 18:37 ` [PATCH 2/8] [WATCHDOG] mpc83xx_wdt: convert to the OF platform driver Anton Vorontsov
2008-06-02 17:37 [PATCH 0/8 v4] mpc83xx_wdt rework, support for mpc8610 and mpc8xx Anton Vorontsov
2008-06-02 17:38 ` [PATCH 2/8] [WATCHDOG] mpc83xx_wdt: convert to the OF platform driver Anton Vorontsov

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=20080515165349.GB3887@polina.dev.rtsoft.ru \
    --to=avorontsov@ru$(echo .)mvista.com \
    --cc=G.Chen@freescale$(echo .)com \
    --cc=galak@kernel$(echo .)crashing.org \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=scottwood@freescale$(echo .)com \
    --cc=sfr@canb$(echo .)auug.org.au \
    --cc=timur@freescale$(echo .)com \
    --cc=wim@iguana$(echo .)be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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