From patchwork Tue Oct 18 23:26:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Dyer X-Patchwork-Id: 9383311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDE81607D0 for ; Tue, 18 Oct 2016 23:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7D8B29840 for ; Tue, 18 Oct 2016 23:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC53F29844; Tue, 18 Oct 2016 23:26:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7D0829840 for ; Tue, 18 Oct 2016 23:26:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755082AbcJRX0Q (ORCPT ); Tue, 18 Oct 2016 19:26:16 -0400 Received: from avasout06.plus.net ([212.159.14.18]:46768 "EHLO avasout06.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754762AbcJRX0P (ORCPT ); Tue, 18 Oct 2016 19:26:15 -0400 Received: from lava ([80.229.148.18]) by avasout06 with smtp id xBSB1t00B0Q3Geg01BSDx7; Wed, 19 Oct 2016 00:26:13 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=apbwMmRV c=1 sm=1 tr=0 a=o7Djd4SkmPXITDn8qH+ssQ==:117 a=o7Djd4SkmPXITDn8qH+ssQ==:17 a=CH0kA5CcgfcA:10 a=beXlt2xKAAAA:8 a=VdAOGdoH8dYTn5LnIecA:9 a=gcY2M4Ci8LIz02MwfSIM:22 Received: from nick by lava with local (Exim 4.86_2) (envelope-from ) id 1bwdlr-0003Mr-8I; Wed, 19 Oct 2016 00:26:11 +0100 From: Nick Dyer To: Dmitry Torokhov , Andrew Duggan Cc: Chris Healy , Henrik Rydberg , Benjamin Tissoires , Linus Walleij , Bjorn Andersson , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Dyer Subject: [PATCH v4 7/7] Input: synaptics-rmi4 - add package_id sysfs attribute Date: Wed, 19 Oct 2016 00:26:08 +0100 Message-Id: <1476833168-12880-7-git-send-email-nick@shmanahar.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476833168-12880-1-git-send-email-nick@shmanahar.org> References: <1476833168-12880-1-git-send-email-nick@shmanahar.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nick Dyer --- drivers/input/rmi4/rmi_driver.h | 1 + drivers/input/rmi4/rmi_f01.c | 24 +++++++++++++++++++++++- drivers/input/rmi4/rmi_f34.c | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h index e22a77f..85cdb70 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h @@ -109,6 +109,7 @@ const char *rmi_f01_get_product_ID(struct rmi_function *fn); u8 rmi_f01_get_manufacturer_ID(struct rmi_function *fn); const char *rmi_f01_get_date_of_manufacture(struct rmi_function *fn); u32 rmi_f01_get_firmware_ID(struct rmi_function *fn); +u32 rmi_f01_get_package_ID(struct rmi_function *fn); #ifdef CONFIG_RMI4_F34 int rmi_f34_create_sysfs(struct rmi_device *rmi_dev); diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c index 8624be8..463c810 100644 --- a/drivers/input/rmi4/rmi_f01.c +++ b/drivers/input/rmi4/rmi_f01.c @@ -54,6 +54,7 @@ struct f01_basic_properties { u8 product_id[RMI_PRODUCT_ID_LENGTH + 1]; u16 productinfo; u32 firmware_id; + u32 package_id; }; /* F01 device status bits */ @@ -220,8 +221,22 @@ static int rmi_f01_read_properties(struct rmi_device *rmi_dev, has_build_id_query = !!(queries[0] & BIT(1)); } - if (has_package_id_query) + if (has_package_id_query) { + ret = rmi_read_block(rmi_dev, prod_info_addr, + queries, 4); + if (ret) { + dev_err(&rmi_dev->dev, + "Failed to read package info: %d\n", + ret); + return ret; + } + + props->package_id = queries[3] << 24 | + queries[2] << 16 | + queries[1] << 8 | + queries[0]; prod_info_addr++; + } if (has_build_id_query) { ret = rmi_read_block(rmi_dev, prod_info_addr, queries, @@ -269,6 +284,13 @@ u32 rmi_f01_get_firmware_ID(struct rmi_function *fn) return f01->properties.firmware_id; } +u32 rmi_f01_get_package_ID(struct rmi_function *fn) +{ + struct f01_data *f01 = dev_get_drvdata(&fn->dev); + + return f01->properties.package_id; +} + #ifdef CONFIG_OF static int rmi_f01_of_probe(struct device *dev, struct rmi_device_platform_data *pdata) diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c index 10b9722..9840968 100644 --- a/drivers/input/rmi4/rmi_f34.c +++ b/drivers/input/rmi4/rmi_f34.c @@ -486,6 +486,21 @@ static ssize_t rmi_driver_configuration_id_show(struct device *dev, static DEVICE_ATTR(configuration_id, 0444, rmi_driver_configuration_id_show, NULL); +static ssize_t rmi_driver_package_id_show(struct device *dev, + struct device_attribute *dattr, + char *buf) +{ + struct rmi_driver_data *data = dev_get_drvdata(dev); + struct rmi_function *fn = data->f01_container; + + u32 package_id = rmi_f01_get_package_ID(fn); + + return scnprintf(buf, PAGE_SIZE, "%04x.%04x\n", + package_id & 0xffff, (package_id >> 16) & 0xffff); +} + +static DEVICE_ATTR(package_id, 0444, rmi_driver_package_id_show, NULL); + static int rmi_firmware_update(struct rmi_driver_data *data, const struct firmware *fw); @@ -545,6 +560,7 @@ static struct attribute *rmi_firmware_attrs[] = { &dev_attr_manufacturer_id.attr, &dev_attr_date_of_manufacture.attr, &dev_attr_product_id.attr, + &dev_attr_package_id.attr, &dev_attr_firmware_id.attr, &dev_attr_update_fw.attr, &dev_attr_update_fw_status.attr,