lkml.org 
[lkml]   [2017]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3] Add sysfs interface for touchpad state
On Fri, Feb 17, 2017 at 4:48 PM, Ritesh Raj Sarraf <rrs@debian.org> wrote:
> 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



> +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 it's intended to be boolean, better to use kstrtobool()

> +
> + 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
>



--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2017-02-17 17:13    [W:0.358 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site