From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Nuno Santos <nsantos@edigma.com>
Cc: linux-input@vger.kernel.org
Subject: Re: Interacting with a input kernel driver from user space
Date: Tue, 15 Nov 2011 10:23:31 -0800 [thread overview]
Message-ID: <20111115182331.GA6410@core.coreip.homeip.net> (raw)
In-Reply-To: <4EC23252.8030003@edigma.com>
On Tue, Nov 15, 2011 at 09:35:14AM +0000, Nuno Santos wrote:
> On 11/14/2011 06:57 PM, Dmitry Torokhov wrote:
> >On Monday, November 14, 2011 10:24:17 AM Nuno Santos wrote:
> >>Hi,
> >>
> >>I have defined my first attribute in the following way:
> >>
> >>static ssize_t usbtouchscreen_update_sensibility(struct device *dev,
> >> struct device_attribute *attr,
> >> const char *buf, size_t count)
> >>{
> >>
> >> printk(KERN_INFO "update sensibility called");
> >>
> >Updating sensibility is always a good thing but I gather you mean
> >sensitivity here...
>
> hahaahha thanks for the correction!!!! I need to do it in several
> places now! :)
> >
> >BTW this should probably be a per-user setting and belong to the X driver,
> >not kernel driver. I.e. kernel streams all data and userspace (X) decides
> >what data do discard according to current user preferences.
> didn't knew about this capability. but how do you change the
> settings thru X? where can I find the API for that?
This API is private to particular X driver. For example Synaptics X
driver (that handles all touchpads that we support in Linux, be it
actualy Synaptics, ALPS, Elantech, Sentelic, Broadcom, etc) allows user
select touch sensitivity. If device support pressure reading
(ABS_PRESSURE) then X driver will simply ignore all event packets where
pressure is less than the threshold. The kernel portion still streams
all events; the X portion is simply choses to ignore some of them,
according to user preference.
> >
> >> return 0;
Actually this shoudl be
return count;
> >>}
> >>
> >>static DEVICE_ATTR(sensibility, 0664, NULL,
> >>usbtouchscreen_update_sensibility);
> >>
> >>static struct attribute *usbtouchscreen_attrs[] = {
> >>&dev_attr_sensibility.attr,
> >> NULL
> >>};
> >>
> >>static const struct attribute_group usbtouchscreen_attr_group = {
> >> .attrs = usbtouchscreen_attrs,
> >>};
> >>
> >>In the probe function I have added:
> >>
> >>if (sysfs_create_group(&intf->dev.kobj,&usbtouchscreen_attr_group))
> >> goto out_unregister_input;
> >>
> >>
> >>Then I tried to write on the attribute in the following way:
> >>
> >>nsantos@NS-PC:~/workspaces/linux-kernel-driver$ echo 45>
> >>/sys/class/input/input7/sensibility
> >>bash: /sys/class/input/input7/sensibility: No such file or directory
> >>
> >>After digging a bit under /sys/class/input/input7 i found that the sub
> >>directory device add sensibilty listed so I tried the following:
> >>
> >>nsantos@NS-PC:~/workspaces/workspace-mtt/linux-kernel-driver$ sudo echo
> >>45> /sys/class/input/input7/device/sensibility
> >>bash: /sys/class/input/input7/device/sensibility: Permission denied
> >>
> >>With no success again...
> >>
> >>Am I doing something terribly wrong?
> >You aren't doing this as root and don't have permission to access the
> >attribute.
> sudo doesn't work in this case? Because I was suddoing.
Should have worked, something else must be wrong then.
> if I change
> the attribute to 777 will it be available to everyone? is this a
> good way of doing it?
Generally we restrict access to sysfs attributes to root since they
control behavior for all users, not only one why is changin sysfs
attribute.
BTW, please use "reply-all" on linux kernel mailing lists - it is most
preferred method. This way you ensure faster responses from people who
already participating in the thread as I scan my inbox is much more
often than folder where I save linux-input mails.
--
Dmitry
next prev parent reply other threads:[~2011-11-15 18:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 12:24 Interacting with a input kernel driver from user space Nuno Santos
2011-11-14 15:37 ` David Herrmann
2011-11-14 16:00 ` Nuno Santos
2011-11-14 16:09 ` David Herrmann
2011-11-14 16:31 ` Nuno Santos
2011-11-14 16:58 ` David Herrmann
2011-11-14 18:24 ` Nuno Santos
2011-11-14 18:57 ` Dmitry Torokhov
2011-11-14 23:17 ` Oliver Neukum
2011-11-14 23:34 ` Dmitry Torokhov
2011-11-15 9:41 ` Nuno Santos
2011-11-15 9:38 ` Nuno Santos
2011-11-15 9:35 ` Nuno Santos
2011-11-15 18:23 ` Dmitry Torokhov [this message]
2011-11-15 18:41 ` Nuno Santos
2011-11-15 19:20 ` Dmitry Torokhov
2011-11-14 17:13 ` Dmitry Torokhov
2011-11-15 10:32 ` Henrik Rydberg
2011-11-15 10:40 ` Nuno Santos
2011-11-15 19:07 ` Chase Douglas
2011-11-16 10:25 ` Nuno Santos
2011-11-16 10:28 ` Nuno Santos
2011-11-16 17:28 ` Nuno Santos
2011-11-16 19:27 ` Dmitry Torokhov
2011-11-17 15:39 ` Nuno Santos
2011-11-17 16:58 ` Nuno Santos
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=20111115182331.GA6410@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=nsantos@edigma.com \
/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;
as well as URLs for NNTP newsgroup(s).