From patchwork Sat Mar 12 10:22:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sangwon Jee X-Patchwork-Id: 8571331 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A64BEC0553 for ; Sat, 12 Mar 2016 10:23:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6FE2201B4 for ; Sat, 12 Mar 2016 10:23:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56D0620166 for ; Sat, 12 Mar 2016 10:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751383AbcCLKXG (ORCPT ); Sat, 12 Mar 2016 05:23:06 -0500 Received: from sbs.melfas.com ([39.118.242.30]:46950 "EHLO sbs.melfas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbcCLKXF (ORCPT ); Sat, 12 Mar 2016 05:23:05 -0500 Received: from unknown (HELO localhost.localdomain) (jeesw@melfas.com@172.16.10.138) by 172.16.0.30 with ESMTP; 12 Mar 2016 19:22:46 +0900 X-Original-SENDERIP: 172.16.10.138 X-Original-MAILFROM: jeesw@melfas.com X-Original-RCPTTO: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, jeesw@melfas.com From: Sangwon Jee To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, jeesw@melfas.com Subject: Input: melfas_mip4 - add hw_version sysfs attribute Date: Sat, 12 Mar 2016 19:22:50 +0900 Message-Id: <1457778170-31320-1-git-send-email-jeesw@melfas.com> X-Mailer: git-send-email 1.9.1 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 Add hw_version sysfs attribute for retrieving hardware information from firmware. Signed-off-by: Sangwon Jee --- drivers/input/touchscreen/melfas_mip4.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 89272973..fb5fb91 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -1310,8 +1310,34 @@ static ssize_t mip4_sysfs_read_fw_version(struct device *dev, static DEVICE_ATTR(fw_version, S_IRUGO, mip4_sysfs_read_fw_version, NULL); +static ssize_t mip4_sysfs_read_hw_version(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct mip4_ts *ts = i2c_get_clientdata(client); + size_t count; + + /* Take lock to prevent racing with firmware update */ + mutex_lock(&ts->input->mutex); + + /* + * product_name shows the name or version of the hardware + * paired with current firmware in the chip. + */ + count = snprintf(buf, PAGE_SIZE, "%.*s\n", + (int)sizeof(ts->product_name), ts->product_name); + + mutex_unlock(&ts->input->mutex); + + return count; +} + +static DEVICE_ATTR(hw_version, S_IRUGO, mip4_sysfs_read_hw_version, NULL); + static struct attribute *mip4_attrs[] = { &dev_attr_fw_version.attr, + &dev_attr_hw_version.attr, &dev_attr_update_fw.attr, NULL, }; @@ -1512,6 +1538,6 @@ static struct i2c_driver mip4_driver = { module_i2c_driver(mip4_driver); MODULE_DESCRIPTION("MELFAS MIP4 Touchscreen"); -MODULE_VERSION("2016.03.03"); +MODULE_VERSION("2016.03.12"); MODULE_AUTHOR("Sangwon Jee "); MODULE_LICENSE("GPL");