From patchwork Wed Jan 8 01:02:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Heiny X-Patchwork-Id: 3450991 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 843C19F1C4 for ; Wed, 8 Jan 2014 01:02:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8888620121 for ; Wed, 8 Jan 2014 01:02:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 985A5200DE for ; Wed, 8 Jan 2014 01:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754014AbaAHBCO (ORCPT ); Tue, 7 Jan 2014 20:02:14 -0500 Received: from us-mx2.synaptics.com ([192.147.44.131]:9748 "EHLO us-mx2.synaptics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754037AbaAHBCO (ORCPT ); Tue, 7 Jan 2014 20:02:14 -0500 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 07 Jan 2014 17:02:13 -0800 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Tue, 07 Jan 2014 16:51:43 -0800 X-PGP-Universal: processed; by securemail.synaptics.com on Tue, 07 Jan 2014 16:51:43 -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, 7 Jan 2014 17:02:18 -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] input synaptics-rmi4: move rmi_f01 query register parsing to its own function Date: Tue, 7 Jan 2014 17:02:10 -0800 Message-ID: <1389142930-26279-1-git-send-email-cheiny@synaptics.com> X-Mailer: git-send-email 1.8.3.1 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 In the near future, query register parsing is going to get a lot more complicated. It's also going to be needed by the reflash code. Now is the time to move this from the F01 initialization into its own function, while the code is still fairly simple. Signed-off-by: Christopher Heiny Cc: Dmitry Torokhov Cc: Benjamin Tissoires --- drivers/input/rmi4/rmi_f01.c | 71 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 28 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_f01.c b/drivers/input/rmi4/rmi_f01.c index d547633..1cb11ea 100644 --- a/drivers/input/rmi4/rmi_f01.c +++ b/drivers/input/rmi4/rmi_f01.c @@ -167,6 +167,46 @@ static int rmi_f01_alloc_memory(struct rmi_function *fn, return 0; } +static int rmi_f01_read_properties(struct rmi_device *rmi_dev, + u16 query_base_addr, + struct f01_basic_properties *props) +{ + u8 basic_query[RMI_F01_BASIC_QUERY_LEN]; + int error; + + error = rmi_read_block(rmi_dev, query_base_addr, + basic_query, sizeof(basic_query)); + if (error < 0) { + dev_err(&rmi_dev->dev, "Failed to read device query registers.\n"); + return error; + } + + /* Now parse what we got */ + props->manufacturer_id = basic_query[0]; + + props->has_lts = basic_query[1] & RMI_F01_QRY1_HAS_LTS; + props->has_adjustable_doze = + basic_query[1] & RMI_F01_QRY1_HAS_ADJ_DOZE; + props->has_adjustable_doze_holdoff = + basic_query[1] & RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF; + + snprintf(props->dom, sizeof(props->dom), + "20%02x%02x%02x", + basic_query[5] & RMI_F01_QRY5_YEAR_MASK, + basic_query[6] & RMI_F01_QRY6_MONTH_MASK, + basic_query[7] & RMI_F01_QRY7_DAY_MASK); + + memcpy(props->product_id, &basic_query[11], + RMI_PRODUCT_ID_LENGTH); + props->product_id[RMI_PRODUCT_ID_LENGTH] = '\0'; + + props->productinfo = + ((basic_query[2] & RMI_F01_QRY2_PRODINFO_MASK) << 7) | + (basic_query[3] & RMI_F01_QRY2_PRODINFO_MASK); + + return 0; +} + static int rmi_f01_initialize(struct rmi_function *fn) { u8 temp; @@ -176,7 +216,6 @@ static int rmi_f01_initialize(struct rmi_function *fn) struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev); struct f01_data *data = fn->data; struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev); - u8 basic_query[RMI_F01_BASIC_QUERY_LEN]; mutex_init(&data->control_mutex); @@ -248,36 +287,12 @@ static int rmi_f01_initialize(struct rmi_function *fn) return error; } - error = rmi_read_block(rmi_dev, fn->fd.query_base_addr, - basic_query, sizeof(basic_query)); + error = rmi_f01_read_properties(rmi_dev, fn->fd.query_base_addr, + &data->properties); if (error < 0) { - dev_err(&fn->dev, "Failed to read device query registers.\n"); + dev_err(&fn->dev, "Failed to read F01 properties.\n"); return error; } - - /* Now parse what we got */ - data->properties.manufacturer_id = basic_query[0]; - - data->properties.has_lts = basic_query[1] & RMI_F01_QRY1_HAS_LTS; - data->properties.has_adjustable_doze = - basic_query[1] & RMI_F01_QRY1_HAS_ADJ_DOZE; - data->properties.has_adjustable_doze_holdoff = - basic_query[1] & RMI_F01_QRY1_HAS_ADJ_DOZE_HOFF; - - snprintf(data->properties.dom, sizeof(data->properties.dom), - "20%02x%02x%02x", - basic_query[5] & RMI_F01_QRY5_YEAR_MASK, - basic_query[6] & RMI_F01_QRY6_MONTH_MASK, - basic_query[7] & RMI_F01_QRY7_DAY_MASK); - - memcpy(data->properties.product_id, &basic_query[11], - RMI_PRODUCT_ID_LENGTH); - data->properties.product_id[RMI_PRODUCT_ID_LENGTH] = '\0'; - - data->properties.productinfo = - ((basic_query[2] & RMI_F01_QRY2_PRODINFO_MASK) << 7) | - (basic_query[3] & RMI_F01_QRY2_PRODINFO_MASK); - dev_info(&fn->dev, "found RMI device, manufacturer: %s, product: %s\n", data->properties.manufacturer_id == 1 ? "Synaptics" : "unknown",