From: Ritesh Raj Sarraf <rrs@debian.org>
To: Darren Hart <dvhart@infradead.org>,
Rafael Wysocki <rjw@rjwysocki.net>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
Ike Panhc <ike.pan@canonical.com>,
Andy Shevchenko <andy@infradead.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: ideapad-laptop: Add sysfs interface for touchpad state
Date: Fri, 17 Feb 2017 20:23:57 +0530 [thread overview]
Message-ID: <1487343237.10735.3.camel@debian.org> (raw)
In-Reply-To: <1487322305.6980.14.camel@debian.org>
[-- Attachment #1.1: Type: text/plain, Size: 664 bytes --]
On Fri, 2017-02-17 at 14:35 +0530, Ritesh Raj Sarraf wrote:
> > Please use:
> >
> > static DEVICE_ATTR_RW(touchpad_mode);
> >
> > You'll need to move the show_ and store_ prefixes to be postfixes, see
> > toshiba-acpi.c for several examples.
> >
>
> Thank you. I am building the kernel the test/verify the changes. Will post the
> revised patch soon.
I have included the changes you mentioned, built and tested locally on my Lenovo
Yoga2 13, and posted (git send-email) to all involved parties.
I have also attached the patch in this reply.
--
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
[-- Attachment #1.2: Type: text/x-patch, Size: 3205 bytes --]
From 6b874d4f786a1a10862f843da45804485b6d0e72 Mon Sep 17 00:00:00 2001
From: Ritesh Raj Sarraf <rrs@debian.org>
Date: Mon, 30 Jan 2017 15:05:48 +0530
Subject: [PATCH v3] Add sysfs interface for touchpad state
Lenovo Yoga (many variants: Yoga, Yoga2 Pro, Yoga2 13, Yoga3 Pro, Yoga 3
14 etc) has multiple modles that are a hybrid laptop, working in laptop
mode as well as tablet mode.
Currently, there is no easy interface to determine the touchpad status,
which in case of the Yoga family of machines, can also be useful to
assume tablet mode status.
Note: The ideapad-laptop driver does not provide a SW_TABLET_MODE either
For a detailed discussion on why we want either of the interfaces,
please see:
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43
This patch adds a sysfs interface for read/write access under:
/sys/bus/platform/devices/VPC2004\:00/touchpad_mode
v3:
Include Darren Hart's comments
Changed sysfs inteface from "touchpad_mode" to "touchpad"
v2:
Include Andy Shevchenko's comments
Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
---
.../ABI/testing/sysfs-platform-ideapad-laptop | 8 +++++
drivers/platform/x86/ideapad-laptop.c | 36 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
index b31e782bd985..5d24f1e8e6ef 100644
--- a/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
+++ b/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
@@ -17,3 +17,11 @@ Description:
* 2 -> Dust Cleaning
* 4 -> Efficient Thermal Dissipation Mode
+What: /sys/devices/platform/ideapad/touchpad
+Date: Feb 2017
+KernelVersion: 4.11
+Contact: "Ritesh Raj Sarraf <rrs@debian.org>"
+Description:
+ Control touchpad mode.
+ * 1 -> Switched On
+ * 0 -> Switched Off
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index f46ece2ce3c4..aff1a561c9ec 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -423,9 +423,45 @@ static ssize_t store_ideapad_fan(struct device *dev,
static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
+
+static ssize_t touchpad_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ideapad_private *priv = dev_get_drvdata(dev);
+ unsigned long result;
+
+ if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
+ return sprintf(buf, "-1\n");
+ return sprintf(buf, "%lu\n", result);
+}
+
+static ssize_t touchpad_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct ideapad_private *priv = dev_get_drvdata(dev);
+ int ret, state;
+
+ ret = kstrtoint(buf, 0, &state);
+ if (ret)
+ return ret;
+
+ if (state != 0 && state != 1)
+ return -EINVAL;
+
+ ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
+ if (ret < 0)
+ return -EIO;
+ return count;
+}
+
+static DEVICE_ATTR_RW(touchpad);
+
static struct attribute *ideapad_attributes[] = {
&dev_attr_camera_power.attr,
&dev_attr_fan_mode.attr,
+ &dev_attr_touchpad.attr,
NULL
};
--
2.11.0
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2017-02-17 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 14:16 [PATCH] platform/x86: ideapad-laptop: Add sysfs interface for touchpad state Ritesh Raj Sarraf
2017-02-17 3:33 ` Darren Hart
2017-02-17 7:39 ` Andy Shevchenko
2017-02-17 8:48 ` Dmitry Torokhov
2017-02-17 9:19 ` Ritesh Raj Sarraf
2017-02-17 19:52 ` Dmitry Torokhov
2017-02-18 9:51 ` Ritesh Raj Sarraf
2017-02-17 9:05 ` Ritesh Raj Sarraf
2017-02-17 14:53 ` Ritesh Raj Sarraf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1487343237.10735.3.camel@debian.org \
--to=rrs@debian.org \
--cc=andy@infradead.org \
--cc=dmitry.torokhov@gmail.com \
--cc=dvhart@infradead.org \
--cc=ike.pan@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox