lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1436031344-15455-4-git-send-email-rvolkov@v1ros.org>
Date:	Sat,  4 Jul 2015 20:35:43 +0300
From:	Roman Volkov <rvolkov@...os.org>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Rob Herring <robh+dt@...nel.org>,
	Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>,
	Grant Likely <grant.likely@...aro.org>
Cc:	Hans de Goede <hdegoede@...hat.com>, Jiri Kosina <jkosina@...e.cz>,
	Wolfram Sang <wsa@...-dreams.de>, linux-input@...r.kernel.org,
	linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
	Tony Prisk <linux@...sktech.co.nz>,
	Roman Volkov <rvolkov@...os.org>
Subject: [PATCH v4 3/4] i8042: Add OF/FDT support to the driver

Original driver should be modified to support OF/FDT bindings. The
platform_create_bundle() function should be removed when compiled for
OF-capable machines, since the device tree is already created by the
platform code. The driver should also contain the OF match table and
call platform-specific probe/remove functions.

Signed-off-by: Roman Volkov <rvolkov@...os.org>
---
 drivers/input/serio/i8042.c | 43 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index cb5ece7..ec58af1 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1442,8 +1442,27 @@ static int __init i8042_probe(struct platform_device *dev)
 {
 	int error;
 
-	i8042_platform_device = dev;
+	if (i8042_platform_device) {
+		printk("%s: multiple controllers found, ignoring '%s'\n",
+			__func__, dev->name);
+		return 0;
+	}
+#ifdef SERIO_I8042_OF
+	if (!dev->dev.of_node) {
+		printk("%s: non-OF device found, ignoring '%s'\n",
+			__func__, dev->name);
+		return 0;
+	}
 
+	error = i8042_platform_probe(dev);
+	if (error)
+		return error;
+#endif
+	error = i8042_controller_check();
+	if (error)
+		return error;
+
+	i8042_platform_device = dev;
 	if (i8042_reset) {
 		error = i8042_controller_selftest();
 		if (error)
@@ -1488,9 +1507,17 @@ static int __init i8042_probe(struct platform_device *dev)
 
 static int i8042_remove(struct platform_device *dev)
 {
+	if (dev != i8042_platform_device) {
+		dbg("%s: ignoring device %s\n", __func__, dev->name);
+		return 0;
+	}
+
 	i8042_unregister_ports();
 	i8042_free_irqs();
 	i8042_controller_reset(false);
+#ifdef SERIO_I8042_OF
+	i8042_platform_remove(dev);
+#endif
 	i8042_platform_device = NULL;
 
 	return 0;
@@ -1502,6 +1529,9 @@ static struct platform_driver i8042_driver = {
 #ifdef CONFIG_PM
 		.pm	= &i8042_pm_ops,
 #endif
+#ifdef SERIO_I8042_OF
+		.of_match_table = i8042_of_match,
+#endif
 	},
 	.remove		= i8042_remove,
 	.shutdown	= i8042_shutdown,
@@ -1514,15 +1544,16 @@ static int __init i8042_init(void)
 
 	dbg_init();
 
+	i8042_platform_device = NULL;
 	err = i8042_platform_init();
 	if (err)
 		return err;
 
-	err = i8042_controller_check();
-	if (err)
-		goto err_platform_exit;
-
+#ifdef SERIO_I8042_OF
+	pdev = ERR_PTR(platform_driver_probe(&i8042_driver, i8042_probe));
+#else
 	pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
+#endif
 	if (IS_ERR(pdev)) {
 		err = PTR_ERR(pdev);
 		goto err_platform_exit;
@@ -1539,7 +1570,9 @@ static int __init i8042_init(void)
 
 static void __exit i8042_exit(void)
 {
+#ifndef SERIO_I8042_OF
 	platform_device_unregister(i8042_platform_device);
+#endif
 	platform_driver_unregister(&i8042_driver);
 	i8042_platform_exit();
 
-- 
2.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ