Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753892AbbBMT4g (ORCPT ); Fri, 13 Feb 2015 14:56:36 -0500 Received: from v1ros.org ([109.234.34.72]:39508 "EHLO smtp.v1ros.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753137AbbBMT4e (ORCPT ); Fri, 13 Feb 2015 14:56:34 -0500 From: Roman Volkov To: Dmitry Torokhov , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Grant Likely Cc: Hans de Goede , Jiri Kosina , Wolfram Sang , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Roman Volkov , Tony Prisk Subject: [PATCH v2 4/5] i8042: Prepare i8042 driver for DT support Date: Fri, 13 Feb 2015 22:52:52 +0300 Message-Id: <1423857173-16432-5-git-send-email-v1ron@v1ros.org> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1423857173-16432-1-git-send-email-v1ron@v1ros.org> References: <20150203011051.11999a16@v1ron-s7> <1423857173-16432-1-git-send-email-v1ron@v1ros.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2870 Lines: 113 Use platform_device_probe() instead of platform_create_bundle() when compiled with DT support, since the latter function is not suitable for handling the OF device tree. The order of initialization is changed, since i8042_platform_init() for DT requires initialized platform_device structure. To avoid searching of the compatible node twice, the platform_device structure pointer must be passed to the i8042_platform_init() function right after initialization by platform_device_probe(). Signed-off-by: Tony Prisk Signed-off-by: Roman Volkov --- This is remaining weak place in the patch set. No ideas yet on how to reduce the using of ifdefs to make code cleaner, need more discussion. drivers/input/serio/i8042.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 2f09062..86a47ec 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -1421,16 +1421,32 @@ static int __init i8042_probe(struct platform_device *dev) int error; i8042_platform_device = dev; +#ifdef SERIO_I8042_DT + error = i8042_platform_init(dev); + if (error) + return error; + error = i8042_controller_check(); + if (error) + goto out_platform_exit; +#endif if (i8042_reset) { error = i8042_controller_selftest(); if (error) +#ifdef SERIO_I8042_DT + goto out_platform_exit; +#else return error; +#endif } error = i8042_controller_init(); if (error) +#ifdef SERIO_I8042_DT + goto out_platform_exit; +#else return error; +#endif #ifdef CONFIG_X86 if (i8042_dritek) @@ -1460,7 +1476,10 @@ static int __init i8042_probe(struct platform_device *dev) i8042_free_irqs(); i8042_controller_reset(false); i8042_platform_device = NULL; - +#ifdef SERIO_I8042_DT + out_platform_exit: + i8042_platform_exit(); +#endif return error; } @@ -1497,11 +1516,18 @@ static struct platform_driver i8042_driver = { static int __init i8042_init(void) { +#ifndef SERIO_I8042_DT struct platform_device *pdev; +#endif int err; dbg_init(); +#ifdef SERIO_I8042_DT + err = platform_driver_probe(&i8042_driver, i8042_probe); + if (err) + return err; +#else err = i8042_platform_init(); if (err) return err; @@ -1515,14 +1541,15 @@ static int __init i8042_init(void) err = PTR_ERR(pdev); goto err_platform_exit; } - +#endif panic_blink = i8042_panic_blink; return 0; - +#ifndef SERIO_I8042_DT err_platform_exit: i8042_platform_exit(); return err; +#endif } static void __exit i8042_exit(void) -- 2.3.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/