Re: [PATCH 2/2] ar7_wdt: convert to become a platform driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Florian,

Forgot the attachment...

Kind regards,
Wim.

> Hi Florian,
> 
> > This patch converts the ar7_wdt driver to become a platform
> > driver. The AR7 SoC specific identification and base register
> > calculation is performed by the board code, therefore we no
> > longer need to have access to ar7_chip_id.
> 
> > @@ -298,22 +285,33 @@ static struct miscdevice ar7_wdt_miscdev = {
> >  	.fops		= &ar7_wdt_fops,
> >  };
> >  
> > -static int __init ar7_wdt_init(void)
> > +static int __init ar7_wdt_probe(struct platform_device *pdev)
> 
> Should be __devinit .
> 
> > +static struct platform_driver ar7_wdt_driver = {
> > +	.driver.name = "ar7_wdt",
> > +	.probe = ar7_wdt_probe,
> > +	.remove = __devexit_p(ar7_wdt_remove),
> > +};
> 
> I prefer to have it as follows (so that the driver.owner field is also set):
> static struct platform_driver ar7_wdt_driver = {
> 	.probe = ar7_wdt_probe,
> 	.remove = __devexit_p(ar7_wdt_remove),
> 	.driver = {
> 		.owner = THIS_MODULE,
> 		.name = "ar7_wdt",
> 	},
> };
> 
> I suggest to also change the reboot notifier code into a platform shutdown method.
> You then get something like the attached patch (untested, uncompiled and I included above 2 remarks).
> For the rest: code is OK for me. After the __init to __devinit fix you can add my signed-off-by.
> 
> Kind regards,
> Wim.
> 
--- ar7_wdt.c.orig	2009-07-18 20:54:33.000000000 +0200
+++ ar7_wdt.c	2009-07-18 21:06:00.000000000 +0200
@@ -30,8 +30,6 @@
 #include <linux/miscdevice.h>
 #include <linux/platform_device.h>
 #include <linux/watchdog.h>
-#include <linux/notifier.h>
-#include <linux/reboot.h>
 #include <linux/fs.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
@@ -189,20 +187,6 @@
 	return 0;
 }
 
-static int ar7_wdt_notify_sys(struct notifier_block *this,
-			      unsigned long code, void *unused)
-{
-	if (code == SYS_HALT || code == SYS_POWER_OFF)
-		if (!nowayout)
-			ar7_wdt_disable_wdt();
-
-	return NOTIFY_DONE;
-}
-
-static struct notifier_block ar7_wdt_notifier = {
-	.notifier_call = ar7_wdt_notify_sys,
-};
-
 static ssize_t ar7_wdt_write(struct file *file, const char *data,
 			     size_t len, loff_t *ppos)
 {
@@ -286,7 +270,7 @@
 	.fops		= &ar7_wdt_fops,
 };
 
-static int __init ar7_wdt_probe(struct platform_device *pdev)
+static int __devinit ar7_wdt_probe(struct platform_device *pdev)
 {
 	int rc;
 
@@ -318,22 +302,13 @@
 	ar7_wdt_prescale(prescale_value);
 	ar7_wdt_update_margin(margin);
 
-	rc = register_reboot_notifier(&ar7_wdt_notifier);
-	if (rc) {
-		printk(KERN_ERR DRVNAME
-			": unable to register reboot notifier\n");
-		goto out_alloc;
-	}
-
 	rc = misc_register(&ar7_wdt_miscdev);
 	if (rc) {
 		printk(KERN_ERR DRVNAME ": unable to register misc device\n");
-		goto out_register;
+		goto out_alloc;
 	}
 	goto out;
 
-out_register:
-	unregister_reboot_notifier(&ar7_wdt_notifier);
 out_alloc:
 	iounmap(ar7_wdt);
 	release_mem_region(ar7_regs_wdt->start, resource_size(ar7_regs_wdt));
@@ -344,17 +319,26 @@
 static int __devexit ar7_wdt_remove(struct platform_device *pdev)
 {
 	misc_deregister(&ar7_wdt_miscdev);
-	unregister_reboot_notifier(&ar7_wdt_notifier);
 	iounmap(ar7_wdt);
 	release_mem_region(ar7_regs_wdt->start, resource_size(ar7_regs_wdt));
 
 	return 0;
 }
 
+static void ar7_wdt_shutdown(struct platform_device *pdev)
+{
+	if (!nowayout)
+		ar7_wdt_disable_wdt();
+}
+
 static struct platform_driver ar7_wdt_driver = {
-	.driver.name = "ar7_wdt",
 	.probe = ar7_wdt_probe,
 	.remove = __devexit_p(ar7_wdt_remove),
+	.shutdown = ar7_wdt_shutdown,
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = "ar7_wdt",
+	},
 };
 
 static int __init ar7_wdt_init(void)

[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux