From patchwork Wed Jul 4 09:07:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 1155251 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 56C413FE4F for ; Wed, 4 Jul 2012 09:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755086Ab2GDJHW (ORCPT ); Wed, 4 Jul 2012 05:07:22 -0400 Received: from mail-qc0-f202.google.com ([209.85.216.202]:43151 "EHLO mail-qc0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754033Ab2GDJHV (ORCPT ); Wed, 4 Jul 2012 05:07:21 -0400 Received: by qcqs25 with SMTP id s25so286556qcq.1 for ; Wed, 04 Jul 2012 02:07:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=etp0TpcIwrXCzT+Sqo+dXZyd19wp+WIt1+vlLa5XpmA=; b=Ve7jHI0h+Lm74NHB6uX/6q4qsov2wAkvrPCZ6lqpgAj+XkFNyfV1g+KtPUw6+N0XVk wh/YWh2G/ajWLO8tiiOgVr14VClGTOKRxKrs44FnOAOk9gvJNzgtgijBdD5INNLkItAn uxswUg9peGbGQazrW3UW4Mq9vkmYQapDTLlFksjAivK5fAwL76/ICPxi/FcrWwj1Ncpm XdeQnso2G9tYIuxn33iFZjwR2Z+F/ujts0X1lxO1iaszFw9KinY1cz3a0Ovl+SPuDAUE XZPR9IXZ1hocauNYOeY4vFBgEVhPMxzDaUlMzvuHYqLVcfZ8OBuntrkdCtodajblvFT2 4m3Q== Received: by 10.236.73.131 with SMTP id v3mr33909104yhd.6.1341392840734; Wed, 04 Jul 2012 02:07:20 -0700 (PDT) Received: by 10.236.73.131 with SMTP id v3mr33909074yhd.6.1341392840625; Wed, 04 Jul 2012 02:07:20 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id q35si5824180yhe.6.2012.07.04.02.07.20 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 04 Jul 2012 02:07:20 -0700 (PDT) Received: from puck.tpe.corp.google.com (puck.tpe.corp.google.com [172.30.210.35]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 65B961E0043; Wed, 4 Jul 2012 02:07:20 -0700 (PDT) Received: by puck.tpe.corp.google.com (Postfix, from userid 116377) id 7FFA380213; Wed, 4 Jul 2012 17:07:19 +0800 (CST) From: Daniel Kurtz To: Alessandro Rubini , Dmitry Torokhov , Henrik Rydberg Cc: Olof Johansson , Benson Leung , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Kurtz Subject: [PATCH 2/2 v2] Input: synaptics - add sysfs access to firmware ID & board ID Date: Wed, 4 Jul 2012 17:07:17 +0800 Message-Id: <1341392837-19115-2-git-send-email-djkurtz@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1341392837-19115-1-git-send-email-djkurtz@chromium.org> References: <1341392837-19115-1-git-send-email-djkurtz@chromium.org> X-Gm-Message-State: ALoCoQlTdnOsZ+hDsBJs+IaKRDXxDujOqNvEQ6RYAYYQPr5WHIuZ+GSjUasL+vm+QAF08wiOOOXZBlgwrToHraEb5C7nQNHnxgJlULebrMLRhfSxrsOpkMlYHkUSmBh4cjq2JUqQrPdmSuJ/feXB8gMvi5qeeioP4Rj8c1xB3kcwLkxybK7QI0BBE1QFDRhpeRDG8HFEzZ0L Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Allow userspace to query firmware ID and board ID, which are read and cached during device initialization. This information can be read, for instance, by a userspace feedback reporting tool, to include this information in its reports. Signed-off-by: Daniel Kurtz --- drivers/input/mouse/synaptics.c | 41 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 7e0eca7..3b24a0f 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -1258,6 +1258,17 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) } } +/***************************************************************************** + * sysfs interface + ****************************************************************************/ +/* Sysfs entry for board ID */ +static ssize_t synaptics_show_board_id(struct psmouse *psmouse, void *data, + char *buf) +{ + struct synaptics_data *priv = psmouse->private; + return scnprintf(buf, PAGE_SIZE, "%lu\n", priv->board_id); +} + static ssize_t synaptics_show_disable_gesture(struct psmouse *psmouse, void *data, char *buf) { @@ -1296,9 +1307,30 @@ static ssize_t synaptics_set_disable_gesture(struct psmouse *psmouse, return len; } +/* Sysfs entry for firmware ID */ +static ssize_t synaptics_show_firmware_id(struct psmouse *psmouse, void *data, + char *buf) +{ + struct synaptics_data *priv = psmouse->private; + return scnprintf(buf, PAGE_SIZE, "%lu\n", priv->firmware_id); +} + +PSMOUSE_DEFINE_RO_ATTR(board_id, S_IRUGO, NULL, synaptics_show_board_id); PSMOUSE_DEFINE_ATTR(disable_gesture, S_IWUSR | S_IRUGO, NULL, synaptics_show_disable_gesture, synaptics_set_disable_gesture); +PSMOUSE_DEFINE_RO_ATTR(firmware_id, S_IRUGO, NULL, synaptics_show_firmware_id); + +static struct attribute *synaptics_attrs[] = { + &psmouse_attr_board_id.dattr.attr, + &psmouse_attr_firmware_id.dattr.attr, + NULL +}; + +static struct attribute_group synaptics_attr_group = { + .attrs = synaptics_attrs, +}; + static void synaptics_disconnect(struct psmouse *psmouse) { @@ -1308,6 +1340,9 @@ static void synaptics_disconnect(struct psmouse *psmouse) device_remove_file(&psmouse->ps2dev.serio->dev, &psmouse_attr_disable_gesture.dattr); + sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, + &synaptics_attr_group); + synaptics_reset(psmouse); kfree(priv); psmouse->private = NULL; @@ -1528,6 +1563,12 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) } } + err = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj, + &synaptics_attr_group); + if (err) + psmouse_warn(psmouse, + "Failed to create sysfs attributes (%d)", err); + return 0; init_fail: