devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Volkov <rvolkov@v1ros.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Grant Likely <grant.likely@linaro.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Jiri Kosina <jkosina@suse.cz>, Wolfram Sang <wsa@the-dreams.de>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, Tony Prisk <linux@prisktech.co.nz>,
	Roman Volkov <rvolkov@v1ros.org>
Subject: [PATCH v4 3/4] i8042: Add OF/FDT support to the driver
Date: Sat,  4 Jul 2015 20:35:43 +0300	[thread overview]
Message-ID: <1436031344-15455-4-git-send-email-rvolkov@v1ros.org> (raw)
In-Reply-To: <1436031344-15455-1-git-send-email-rvolkov@v1ros.org>

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


  parent reply	other threads:[~2015-07-04 17:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <342234234esdfewrewrwer@dkoi.org>
2015-07-04 17:35 ` [PATCH v4 0/4] FDT support for i8042 driver Roman Volkov
     [not found]   ` <1436031344-15455-1-git-send-email-rvolkov-oLhuKTjYqW/YtjvyW6yDsg@public.gmane.org>
2015-07-04 17:35     ` [PATCH v4 1/4] i8042: Add i8042_of.h header Roman Volkov
2015-07-04 17:35   ` [PATCH v4 2/4] i8042: Kernel configuration for OF/FDT support Roman Volkov
2015-07-04 17:35   ` Roman Volkov [this message]
2015-07-04 17:35   ` [PATCH v4 4/4] Documentation: Add 'intel,8042' FDT bindings Roman Volkov

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=1436031344-15455-4-git-send-email-rvolkov@v1ros.org \
    --to=rvolkov@v1ros.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=hdegoede@redhat.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@prisktech.co.nz \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=wsa@the-dreams.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).