From patchwork Fri Dec 6 00:29:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Heiny X-Patchwork-Id: 3291941 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 61295C0D4A for ; Fri, 6 Dec 2013 00:29:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16771204FB for ; Fri, 6 Dec 2013 00:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0A37204EC for ; Fri, 6 Dec 2013 00:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590Ab3LFA3W (ORCPT ); Thu, 5 Dec 2013 19:29:22 -0500 Received: from us-mx2.synaptics.com ([192.147.44.131]:60544 "EHLO us-mx2.synaptics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752426Ab3LFA3V (ORCPT ); Thu, 5 Dec 2013 19:29:21 -0500 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 05 Dec 2013 16:29:21 -0800 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Thu, 05 Dec 2013 16:20:47 -0800 X-PGP-Universal: processed; by securemail.synaptics.com on Thu, 05 Dec 2013 16:20:47 -0800 Received: from brontomerus.synaptics-inc.local (10.3.20.103) by USW-OWA1.synaptics-inc.local (10.20.24.15) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 5 Dec 2013 16:29:20 -0800 From: Christopher Heiny To: Dmitry Torokhov CC: Linux Input , Christopher Heiny , Andrew Duggan , Vincent Huang , Vivian Ly , Daniel Rosenberg , Jean Delvare , Joerie de Gram , Linus Walleij , Benjamin Tissoires Subject: [PATCH V2] input synaptics-rmi4: Reorder declarations in rmi_bus.c Date: Thu, 5 Dec 2013 16:29:16 -0800 Message-ID: <1386289756-12429-1-git-send-email-cheiny@synaptics.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.3.20.103] X-Brightmail-Tracker: AAAAAQAAAWE= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements changes to the synaptics-rmi4 branch of Dmitry's input tree. The base for the patch is commit 8ca01dc61a42b6f7bcba052a8c084000f7057a34. This patch primarily reorders the various declarations in rmi_bus.c in order to group related elements together, along with some typo fixes. The code is still horribly broken, but this change should make the following fixes easier to review. Signed-off-by: Christopher Heiny Cc: Dmitry Torokhov Cc: Jean Delvare Cc: Linus Walleij Cc: Joerie de Gram Cc: Benjamin Tissoires Reviewed-by: benjamin Tissoires --- drivers/input/rmi4/rmi_bus.c | 189 +++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 99 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c index 88f60ca..d9c450b 100644 --- a/drivers/input/rmi4/rmi_bus.c +++ b/drivers/input/rmi4/rmi_bus.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012 Synaptics Incorporated + * Copyright (c) 2011-2013 Synaptics Incorporated * Copyright (c) 2011 Unixphere * * This program is free software; you can redistribute it and/or modify it @@ -19,77 +19,20 @@ #include "rmi_bus.h" #include "rmi_driver.h" -static int rmi_function_match(struct device *dev, struct device_driver *drv) -{ - struct rmi_function_handler *handler = to_rmi_function_handler(drv); - struct rmi_function *fn = to_rmi_function(dev); - - return fn->fd.function_number == handler->func; -} - -static int rmi_bus_match(struct device *dev, struct device_driver *drv) -{ - bool physical = rmi_is_physical_device(dev); - - /* First see if types are not compatible */ - if (physical != rmi_is_physical_driver(drv)) - return 0; - - return physical || rmi_function_match(dev, drv); -} - -struct bus_type rmi_bus_type = { - .match = rmi_bus_match, - .name = "rmi", -}; - -#ifdef CONFIG_RMI4_DEBUG - -static struct dentry *rmi_debugfs_root; - -static void rmi_bus_setup_debugfs(void) -{ - rmi_debugfs_root = debugfs_create_dir(rmi_bus_type.name, NULL); - if (!rmi_debugfs_root) - pr_err("%s: Failed to create debugfs root\n", - __func__); -} - -static void rmi_bus_teardown_debugfs(void) -{ - if (rmi_debugfs_root) - debugfs_remove_recursive(rmi_debugfs_root); -} - -#else - -static void rmi_bus_setup_debugfs(void) -{ -} - -static void rmi_bus_teardown_debugfs(void) -{ -} - -#endif - - /* * RMI Physical devices * * Physical RMI device consists of several functions serving particular - * purpose. For example F11 is a 2D touch sensor while F10 is a generic + * purpose. For example F11 is a 2D touch sensor while F01 is a generic * function present in every RMI device. */ static void rmi_release_device(struct device *dev) { struct rmi_device *rmi_dev = to_rmi_device(dev); - kfree(rmi_dev); } -/* Device type for physical RMI devices */ struct device_type rmi_device_type = { .name = "rmi_sensor", .release = rmi_release_device, @@ -118,7 +61,7 @@ static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev) #else -static void rmi_physocal_setup_debugfs(struct rmi_device *rmi_dev) +static void rmi_physical_setup_debugfs(struct rmi_device *rmi_dev) { } @@ -128,7 +71,6 @@ static void rmi_physical_teardown_debugfs(struct rmi_device *rmi_dev) #endif - /** * rmi_register_physical_device - register a physical device connection on the RMI * bus. Physical drivers provide communication from the devices on the bus to @@ -174,7 +116,7 @@ int rmi_register_physical_device(struct rmi_phys_device *phys) return 0; } -EXPORT_SYMBOL(rmi_register_physical_device); +EXPORT_SYMBOL_GPL(rmi_register_physical_device); /** * rmi_unregister_physical_device - unregister a physical device connection @@ -191,18 +133,14 @@ void rmi_unregister_physical_device(struct rmi_phys_device *phys) EXPORT_SYMBOL(rmi_unregister_physical_device); -/* - * RMI Function devices and their handlers - */ +/* Function specific stuff */ static void rmi_release_function(struct device *dev) { struct rmi_function *fn = to_rmi_function(dev); - kfree(fn); } -/* Device type for RMI Function devices */ struct device_type rmi_function_type = { .name = "rmi_function", .release = rmi_release_function, @@ -244,35 +182,12 @@ static void rmi_function_teardown_debugfs(struct rmi_function *fn) #endif -int rmi_register_function(struct rmi_function *fn) +static int rmi_function_match(struct device *dev, struct device_driver *drv) { - struct rmi_device *rmi_dev = fn->rmi_dev; - int error; - - dev_set_name(&fn->dev, "%s.fn%02x", - dev_name(&rmi_dev->dev), fn->fd.function_number); - - fn->dev.parent = &rmi_dev->dev; - fn->dev.type = &rmi_function_type; - fn->dev.bus = &rmi_bus_type; - - error = device_register(&fn->dev); - if (error) { - dev_err(&rmi_dev->dev, - "Failed device_register function device %s\n", - dev_name(&fn->dev)); - } - - dev_dbg(&rmi_dev->dev, "Registered F%02X.\n", fn->fd.function_number); - - rmi_function_setup_debugfs(fn); - return 0; -} + struct rmi_function_handler *handler = to_rmi_function_handler(drv); + struct rmi_function *fn = to_rmi_function(dev); -void rmi_unregister_function(struct rmi_function *fn) -{ - rmi_function_teardown_debugfs(fn); - device_unregister(&fn->dev); + return fn->fd.function_number == handler->func; } static int rmi_function_probe(struct device *dev) @@ -302,6 +217,38 @@ static int rmi_function_remove(struct device *dev) return 0; } +int rmi_register_function(struct rmi_function *fn) +{ + struct rmi_device *rmi_dev = fn->rmi_dev; + int error; + + dev_set_name(&fn->dev, "%s.fn%02x", + dev_name(&rmi_dev->dev), fn->fd.function_number); + + fn->dev.parent = &rmi_dev->dev; + fn->dev.type = &rmi_function_type; + fn->dev.bus = &rmi_bus_type; + + error = device_register(&fn->dev); + if (error) { + dev_err(&rmi_dev->dev, + "Failed device_register function device %s\n", + dev_name(&fn->dev)); + return error; + } + + dev_dbg(&rmi_dev->dev, "Registered F%02X.\n", fn->fd.function_number); + + rmi_function_setup_debugfs(fn); + return 0; +} + +void rmi_unregister_function(struct rmi_function *fn) +{ + rmi_function_teardown_debugfs(fn); + device_unregister(&fn->dev); +} + /** * rmi_register_function_handler - register a handler for an RMI function * @handler: RMI handler that should be registered. @@ -334,7 +281,7 @@ int __rmi_register_function_handler(struct rmi_function_handler *handler, return 0; } -EXPORT_SYMBOL(__rmi_register_function_handler); +EXPORT_SYMBOL_GPL(__rmi_register_function_handler); /** * rmi_unregister_function_handler - unregister given RMI function handler @@ -347,11 +294,55 @@ void rmi_unregister_function_handler(struct rmi_function_handler *handler) { driver_unregister(&handler->driver); } -EXPORT_SYMBOL(rmi_unregister_function_handler); +EXPORT_SYMBOL_GPL(rmi_unregister_function_handler); -/* - * Bus registration and tear-down - */ +/* Bus specific stuff */ + +static int rmi_bus_match(struct device *dev, struct device_driver *drv) +{ + bool physical = rmi_is_physical_device(dev); + + /* First see if types are not compatible */ + if (physical != rmi_is_physical_driver(drv)) + return 0; + + return physical || rmi_function_match(dev, drv); +} + +struct bus_type rmi_bus_type = { + .match = rmi_bus_match, + .name = "rmi", +}; + +#ifdef CONFIG_RMI4_DEBUG + +static struct dentry *rmi_debugfs_root; + +static void rmi_bus_setup_debugfs(void) +{ + rmi_debugfs_root = debugfs_create_dir(rmi_bus_type.name, NULL); + if (!rmi_debugfs_root) + pr_err("%s: Failed to create debugfs root\n", + __func__); +} + +static void rmi_bus_teardown_debugfs(void) +{ + if (rmi_debugfs_root) + debugfs_remove_recursive(rmi_debugfs_root); +} + +#else + +static void rmi_bus_setup_debugfs(void) +{ +} + +static void rmi_bus_teardown_debugfs(void) +{ +} + +#endif static int __init rmi_bus_init(void) {