From patchwork Wed Mar 5 03:39:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Heiny X-Patchwork-Id: 3770191 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 47404BF13A for ; Wed, 5 Mar 2014 03:39:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E8E420240 for ; Wed, 5 Mar 2014 03:39:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E62B620237 for ; Wed, 5 Mar 2014 03:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755658AbaCEDjk (ORCPT ); Tue, 4 Mar 2014 22:39:40 -0500 Received: from us-mx2.synaptics.com ([192.147.44.131]:35090 "EHLO us-mx2.synaptics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755352AbaCEDjj (ORCPT ); Tue, 4 Mar 2014 22:39:39 -0500 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 04 Mar 2014 19:39:38 -0800 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Tue, 04 Mar 2014 19:25:51 -0800 X-PGP-Universal: processed; by securemail.synaptics.com on Tue, 04 Mar 2014 19:25:51 -0800 Received: from brontomerus.synaptics.com (10.3.20.103) by USW-OWA1.synaptics-inc.local (10.20.24.15) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 4 Mar 2014 19:39:38 -0800 From: Christopher Heiny To: Dmitry Torokhov CC: Linux Input , Christopher Heiny , Andrew Duggan , Vincent Huang , Vivian Ly , Daniel Rosenberg , Linus Walleij , Benjamin Tissoires , David Herrmann , Jiri Kosina Subject: [PATCH 02/02] input synaptics-rmi4: improved interrupt enable management Date: Tue, 4 Mar 2014 19:39:20 -0800 Message-ID: <1393990760-2587-2-git-send-email-cheiny@synaptics.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1393990760-2587-1-git-send-email-cheiny@synaptics.com> References: <1393990760-2587-1-git-send-email-cheiny@synaptics.com> MIME-Version: 1.0 X-Originating-IP: [10.3.20.103] Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, 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 The previous interrupt save/restore routine was inflexible. Remove that and add set_bits() and clear_bits() functions, allowing simpler management of individual function interrupt enables. Signed-off-by: Christopher Heiny Cc: Dmitry Torokhov Cc: Benjamin Tissoires Cc: Linux Walleij Cc: David Herrmann Cc: Jiri Kosina --- drivers/input/rmi4/rmi_bus.h | 12 ++--- drivers/input/rmi4/rmi_driver.c | 104 ++++++++++++++++------------------------ drivers/input/rmi4/rmi_driver.h | 3 +- 3 files changed, 48 insertions(+), 71 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.h b/drivers/input/rmi4/rmi_bus.h index 1672b05..d4cfc85 100644 --- a/drivers/input/rmi4/rmi_bus.h +++ b/drivers/input/rmi4/rmi_bus.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013 Synaptics Incorporated + * Copyright (c) 2011-2014 Synaptics Incorporated * Copyright (c) 2011 Unixphere * * This program is free software; you can redistribute it and/or modify it @@ -111,9 +111,8 @@ void rmi_unregister_function_handler(struct rmi_function_handler *); * @driver: Device driver model driver * @irq_handler: Callback for handling irqs * @reset_handler: Called when a reset is detected. - * @get_func_irq_mask: Callback for calculating interrupt mask - * @store_irq_mask: Callback for storing and replacing interrupt mask - * @restore_irq_mask: Callback for restoring previously stored interrupt mask + * @clear_irq_bits: Clear the specified bits in the current interrupt mask. + * @set_irq_bist: Set the specified bits in the current interrupt mask. * @store_productid: Callback for cache product id from function 01 * @data: Private data pointer * @@ -123,9 +122,8 @@ struct rmi_driver { int (*irq_handler)(struct rmi_device *rmi_dev, int irq); int (*reset_handler)(struct rmi_device *rmi_dev); - int (*store_irq_mask)(struct rmi_device *rmi_dev, - unsigned long *new_interupts); - int (*restore_irq_mask)(struct rmi_device *rmi_dev); + int (*clear_irq_bits)(struct rmi_device *rmi_dev, unsigned long *mask); + int (*set_irq_bits)(struct rmi_device *rmi_dev, unsigned long *mask); int (*store_productid)(struct rmi_device *rmi_dev); int (*set_input_params)(struct rmi_device *rmi_dev, struct input_dev *input); diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index 4406a7f..2172c80 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -330,78 +330,56 @@ static int rmi_driver_set_input_params(struct rmi_device *rmi_dev, return 0; } -/** - * This pair of functions allows functions like function 54 to request to have - * other interrupts disabled until the restore function is called. Only one - * store happens at a time. - */ -static int rmi_driver_irq_save(struct rmi_device *rmi_dev, - unsigned long *new_ints) +static int rmi_driver_set_irq_bits(struct rmi_device *rmi_dev, + unsigned long *mask) { - int retval = 0; + int error = 0; struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); struct device *dev = &rmi_dev->dev; mutex_lock(&data->irq_mutex); - if (!data->irq_stored) { - /* Save current enabled interrupts */ - retval = rmi_read_block(rmi_dev, - data->f01_container->fd.control_base_addr + 1, - data->irq_mask_store, data->num_of_irq_regs); - if (retval < 0) { - dev_err(dev, "%s: Failed to read enabled interrupts!", - __func__); - goto error_unlock; - } - retval = rmi_write_block(rmi_dev, - data->f01_container->fd.control_base_addr + 1, - new_ints, data->num_of_irq_regs); - if (retval < 0) { - dev_err(dev, "%s: Failed to change enabled interrupts!", - __func__); - goto error_unlock; - } - bitmap_copy(data->current_irq_mask, new_ints, data->irq_count); - data->irq_stored = true; - } else { - retval = -ENOSPC; /* No space to store IRQs.*/ - dev_err(dev, "Attempted to save IRQs when already stored!"); + bitmap_or(data->new_irq_mask, + data->current_irq_mask, mask, data->irq_count); + error = rmi_write_block(rmi_dev, + data->f01_container->fd.control_base_addr + 1, + data->new_irq_mask, data->num_of_irq_regs); + if (error < 0) { + dev_err(dev, "%s: Failed to change enabled interrupts!", + __func__); + goto error_unlock; } + bitmap_copy(data->current_irq_mask, data->new_irq_mask, + data->num_of_irq_regs); error_unlock: mutex_unlock(&data->irq_mutex); - return retval; + return error; } -static int rmi_driver_irq_restore(struct rmi_device *rmi_dev) +static int rmi_driver_clear_irq_bits(struct rmi_device *rmi_dev, + unsigned long *mask) { - int retval = 0; + int error = 0; struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); struct device *dev = &rmi_dev->dev; mutex_lock(&data->irq_mutex); - - if (data->irq_stored) { - retval = rmi_write_block(rmi_dev, - data->f01_container->fd.control_base_addr+1, - data->irq_mask_store, data->num_of_irq_regs); - if (retval < 0) { - dev_err(dev, "%s: Failed to write enabled interupts!", - __func__); - goto error_unlock; - } - memcpy(data->current_irq_mask, data->irq_mask_store, - data->num_of_irq_regs * sizeof(u8)); - data->irq_stored = false; - } else { - retval = -EINVAL; - dev_err(dev, "%s: Attempted to restore values when not stored!", - __func__); + bitmap_andnot(data->new_irq_mask, + data->current_irq_mask, mask, data->irq_count); + error = rmi_write_block(rmi_dev, + data->f01_container->fd.control_base_addr + 1, + data->new_irq_mask, data->num_of_irq_regs); + if (error < 0) { + dev_err(dev, "%s: Failed to change enabled interrupts!", + __func__); + goto error_unlock; } + bitmap_copy(data->current_irq_mask, data->new_irq_mask, + data->num_of_irq_regs); error_unlock: mutex_unlock(&data->irq_mutex); - return retval; + return error; } static int rmi_driver_irq_handler(struct rmi_device *rmi_dev, int irq) @@ -437,21 +415,23 @@ static int rmi_driver_reset_handler(struct rmi_device *rmi_dev) return 0; } + error = rmi_read_block(rmi_dev, + data->f01_container->fd.control_base_addr + 1, + data->current_irq_mask, data->num_of_irq_regs); + if (error < 0) { + dev_err(&rmi_dev->dev, "%s: Failed to read current IRQ mask.\n", + __func__); + return error; + } + error = rmi_driver_process_reset_requests(rmi_dev); if (error < 0) return error; - error = rmi_driver_process_config_requests(rmi_dev); if (error < 0) return error; - if (data->irq_stored) { - error = rmi_driver_irq_restore(rmi_dev); - if (error < 0) - return error; - } - return 0; } @@ -846,7 +826,7 @@ static int rmi_driver_probe(struct device *dev) data->irq_status = irq_memory + size * 0; data->fn_irq_bits = irq_memory + size * 1; data->current_irq_mask = irq_memory + size * 2; - data->irq_mask_store = irq_memory + size * 3; + data->new_irq_mask = irq_memory + size * 3; irq_count = 0; dev_dbg(dev, "Creating functions."); @@ -957,8 +937,8 @@ static struct rmi_driver rmi_physical_driver = { }, .irq_handler = rmi_driver_irq_handler, .reset_handler = rmi_driver_reset_handler, - .store_irq_mask = rmi_driver_irq_save, - .restore_irq_mask = rmi_driver_irq_restore, + .clear_irq_bits = rmi_driver_clear_irq_bits, + .set_irq_bits = rmi_driver_set_irq_bits, .set_input_params = rmi_driver_set_input_params, }; diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h index a22a4e6..34f7a7d 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h @@ -47,8 +47,7 @@ struct rmi_driver_data { unsigned long *irq_status; unsigned long *fn_irq_bits; unsigned long *current_irq_mask; - unsigned long *irq_mask_store; - bool irq_stored; + unsigned long *new_irq_mask; struct mutex irq_mutex; /* Following are used when polling. */