From patchwork Wed Mar 13 23:50:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 2266881 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E6A14DFE86 for ; Wed, 13 Mar 2013 23:51:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934370Ab3CMXvf (ORCPT ); Wed, 13 Mar 2013 19:51:35 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:63136 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934461Ab3CMXvQ (ORCPT ); Wed, 13 Mar 2013 19:51:16 -0400 Received: by mail-pb0-f52.google.com with SMTP id ma3so1509637pbc.25 for ; Wed, 13 Mar 2013 16:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=/hnKH599S8G6vV3oOerSnwpuHIz7GY/gWffTQX9uJ9Q=; b=TgYWSGTfqtcgmnymJ09ihv5Y/IAe+UczUuhTbaZv4zQncRPQFws6np8FONtP5MHID5 GweAJp6qmM+Ufu+/hPa6mxzDEE6DHb+TSz58aQKbrJr74gJ2ySCgU5HKfj1T/1D4fKi9 DxFfBs6aMP/gTg1j3Is5B8vYLFFPOvBKn847I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=/hnKH599S8G6vV3oOerSnwpuHIz7GY/gWffTQX9uJ9Q=; b=OSSAf71Dwe/gHCanmQV94bpjPS2HCUXy13dDQ1FSI7KrPu/rycr7XZCQ8iVrvrPdXE MWo77shlHZio1ZVez07qsPIbitm3nIBtPjRNlFbDvNazxztaatiEIWdSqP6Uc+cydaeV /6Y0s1z2SXYgNZ7lkjYAMiC5A1h9WIHu3apyXJMuRfLTuYdtcrfvklOBTSeMMH5tzPGG llg5invNK8nLSjfktGnvuaCsG+uNPZGBcFxVRkRGm8/3T0R5bq5QFTa6JXTOKtMjZcGI T4UAtiOseNPYoOskU3ZxjIlSbug+M9nos89LQ9vUeZG+qZIrU9tq9wjyRC0xZOHnEXVv tGgw== X-Received: by 10.68.129.197 with SMTP id ny5mr661322pbb.110.1363218675789; Wed, 13 Mar 2013 16:51:15 -0700 (PDT) Received: from laughingman.mtv.corp.google.com (laughingman.mtv.corp.google.com [172.22.73.99]) by mx.google.com with ESMTPS id kb3sm420254pbc.21.2013.03.13.16.51.14 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Mar 2013 16:51:14 -0700 (PDT) From: Benson Leung To: rydberg@euromail.se, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com Cc: bleung@chromium.org, olofj@chromium.org, djkurtz@chromium.org, dudl@cypress.com Subject: [PATCH 4/4] Input: cyapa - Add sysfs attrs for product_id and fw version Date: Wed, 13 Mar 2013 16:50:51 -0700 Message-Id: <1363218651-22457-5-git-send-email-bleung@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1363218651-22457-1-git-send-email-bleung@chromium.org> References: <1363218651-22457-1-git-send-email-bleung@chromium.org> X-Gm-Message-State: ALoCoQnTcy/Ruvoog0Iu7ThMLxLwwvCTQrm19yDLGTGOptgaWQsHhnuQwrdZFZCnqgqKIUhk4HrZ Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add attributes to expose the product_id and firmware_version read from the device firmware. Signed-off-by: Dudley Du Signed-off-by: Benson Leung --- drivers/input/mouse/cyapa.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index 51e9d44..97828f6 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c @@ -216,6 +216,8 @@ struct cyapa { /* read from query data region. */ char product_id[16]; + u8 fw_maj_ver; /* firmware major version. */ + u8 fw_min_ver; /* firmware minor version. */ u8 btn_capability; u8 gen; int max_abs_x; @@ -714,6 +716,9 @@ static int cyapa_get_query_data(struct cyapa *cyapa) memcpy(&cyapa->product_id[13], &query_data[11], 2); cyapa->product_id[15] = '\0'; + cyapa->fw_maj_ver = query_data[15]; + cyapa->fw_min_ver = query_data[16]; + cyapa->btn_capability = query_data[19] & CAPABILITY_BTN_MASK; cyapa->gen = query_data[20] & 0x0f; @@ -1175,6 +1180,21 @@ done: /* * Sysfs Interface. */ +static ssize_t cyapa_show_fm_ver(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct cyapa *cyapa = dev_get_drvdata(dev); + return scnprintf(buf, PAGE_SIZE, "%d.%d\n", cyapa->fw_maj_ver, + cyapa->fw_min_ver); +} + +static ssize_t cyapa_show_product_id(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct cyapa *cyapa = dev_get_drvdata(dev); + return scnprintf(buf, PAGE_SIZE, "%s\n", cyapa->product_id); +} + static ssize_t cyapa_update_fw_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1199,9 +1219,13 @@ static ssize_t cyapa_update_fw_store(struct device *dev, return ret ? ret : count; } +static DEVICE_ATTR(firmware_version, S_IRUGO, cyapa_show_fm_ver, NULL); +static DEVICE_ATTR(product_id, S_IRUGO, cyapa_show_product_id, NULL); static DEVICE_ATTR(update_fw, S_IWUSR, NULL, cyapa_update_fw_store); static struct attribute *cyapa_sysfs_entries[] = { + &dev_attr_firmware_version.attr, + &dev_attr_product_id.attr, &dev_attr_update_fw.attr, NULL, };