From: Simon Budig <simon.budig@kernelconcepts.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, agust@denx.de, yanok@emcraft.com
Subject: Re: [PATCH] Touchscreen driver for FT5x06 based EDT displays
Date: Wed, 04 Apr 2012 22:52:30 +0200 [thread overview]
Message-ID: <4F7CB48E.9060305@kernelconcepts.de> (raw)
In-Reply-To: <20120404191043.GA11042@core.coreip.homeip.net>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Dmitry.
On 04/04/2012 09:10 PM, Dmitry Torokhov wrote:
> On Wed, Apr 04, 2012 at 08:27:59PM +0200, simon.budig@kernelconcepts.de wrote:
>> + if (!have_abs) {
>> + input_report_key(tsdata->input, BTN_TOUCH, 1);
>> + input_report_abs(tsdata->input, ABS_PRESSURE, 1);
>> + input_report_abs(tsdata->input, ABS_X,
>> + ((rdbuf[i*4+5] << 8) |
>> + rdbuf[i*4+6]) & 0x0fff);
>> + input_report_abs(tsdata->input, ABS_Y,
>> + ((rdbuf[i*4+7] << 8) |
>> + rdbuf[i*4+8]) & 0x0fff);
>> + have_abs = 1;
>
>
> The mt pointer emulation should do this for you.
Can you point me to some documentation on that? Do I need to enable this?
[...]
>> + mutex_lock(&tsdata->mutex);
>> +
>> + if (tsdata->factory_mode) {
>> + dev_err(dev,
>> + "setting register not available in factory mode\n");
>
> This will spam logs, just return error silently.
Hmm, the idea was to give the user a hint for an attempt to read the
attribute values in factory mode instead of just silently failing.
Where would be a proper place to document such device-specific behaviour?
[...]
> See if you could wrap an attribute into your own structure that will
> allow you to get to the address, field and limits without matching on
> attribute name.
will try.
>> + mutex_lock(&tsdata->mutex);
>
> Instead of taking mutex why don't you disable IRQ?
Does the Linux kernel guarantee that there is just one attribute access
at a time?
Otherwise:
The reason for this locking is two fold.
First, the touch sensor has two modes, a "operation mode" and a "factory
mode". The problem is, that the register numbering in the two modes is
mostly disjunct. I.e. reading the "gain" register in factory mode gives
a number, which has no real connection to the actual gain value. Since
the mode can be changed via a sysfs file I have a potential race
condition when e.g. concurrent access to the sysfs entries happen:
Lets say I want to read the gain value, while something else tries to
switch to factory mode.
1) edt_ft5x06_i2c_setting_show checks for factory_mode == 0
2) edt_ft5x06_i2c_mode_store changes factory_mode to 1
3) edt_ft5x06_i2c_setting_show reads register 0x30, reading and
returning a bogus value.
Also reading raw values is a series of i2c transactions (for each column
of the sensor) and I need to avoid at least a mode change inbetween.
That is the purpose of the mutex.
[...]
>> +static int edt_ft5x06_i2c_ts_probe(struct i2c_client *client,
>> + const struct i2c_device_id *id)
>> +{
>> +
>> + struct edt_ft5x06_i2c_ts_data *tsdata;
>> + struct edt_ft5x06_platform_data *pdata;
>
> const.
What do you mean?
[..]
>> + /* request IRQ pin */
>> + tsdata->irq_pin = pdata->irq_pin;
>> + tsdata->irq = gpio_to_irq(tsdata->irq_pin);
>
> Take from the client.
[...]
> Should this GPIO configuration be done by the driver or by the board
> code that configures i2c client? I think latter is better.
I got conflicting opinions when I asked for advice on this last december
(before changing it to a pin-based configuration). Why do you think that
your suggestion is better?
>> + mutex_lock(&tsdata->mutex);
>
> Why are you taking this lock here?
Paranoia. I wanted to ensure that the controller stays in
non-factory-mode because I am about to read some configuration
registers- However, the attributes are probably not yet available to
userspace, so I can probably skip the mutex in _probe.
>> + input->name = kstrdup(model_name, GFP_NOIO);
>
> Why don't you just allocate a few bytes in tsdata structure instead of
> allocating and managing this separately. You'll also avoid race when
> freeing it.
Yeah, I guess that is simpler.
Thanks for the review.
Simon
- --
Simon Budig kernel concepts GmbH
simon.budig@kernelconcepts.de Sieghuetter Hauptweg 48
+49-271-771091-17 D-57072 Siegen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk98tI4ACgkQO2O/RXesiHAopwCfTnRzBEiFbN/tGcRl/TLBl7yR
KpwAn13Bzx+Q6Avj0edwwC+6qkPjAhfq
=Zg0q
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2012-04-04 20:52 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1326413229-30282-1-git-send-email-simon.budig@kernelconcepts.de>
2012-01-13 0:13 ` [PATCH v3] Touchscreen driver for FT5x06 based EDT displays simon.budig
2012-01-13 0:13 ` [PATCH] " simon.budig
2012-03-06 16:15 ` [PATCH v4] " simon.budig
2012-03-06 16:15 ` simon.budig
2012-03-07 10:42 ` Simon Budig
2012-03-07 13:36 ` Anatolij Gustschin
2012-03-07 14:50 ` Simon Budig
2012-04-04 18:27 ` [PATCH v5] " simon.budig
2012-04-04 18:27 ` [PATCH] " simon.budig
2012-04-04 19:10 ` Dmitry Torokhov
2012-04-04 20:52 ` Simon Budig [this message]
2012-04-04 21:09 ` Dmitry Torokhov
2012-04-05 10:27 ` Simon Budig
2012-04-05 12:54 ` Simon Budig
2012-05-07 6:57 ` Dmitry Torokhov
2012-06-22 23:48 ` [PATCH v6] " simon.budig
2012-06-22 23:48 ` simon.budig
2012-06-25 7:20 ` Dmitry Torokhov
2012-06-25 8:53 ` Henrik Rydberg
2012-06-25 8:51 ` Henrik Rydberg
2012-06-25 9:27 ` Simon Budig
2012-06-25 11:34 ` Henrik Rydberg
2012-06-26 1:36 ` Dmitry Torokhov
2012-06-26 5:37 ` Olivier Sobrie
2012-06-26 2:06 ` Dmitry Torokhov
2012-06-26 9:06 ` Simon Budig
2012-06-26 18:21 ` Henrik Rydberg
2012-06-26 19:17 ` Henrik Rydberg
2012-06-24 12:31 ` Simon Budig
2012-07-01 20:36 ` [PATCH v7] " simon.budig
2012-07-01 20:36 ` simon.budig
2012-07-02 9:31 ` Henrik Rydberg
2012-07-02 9:55 ` Simon Budig
2012-07-08 16:05 ` [PATCH v8] " simon.budig
2012-07-08 16:05 ` simon.budig
2012-07-09 8:06 ` Henrik Rydberg
2012-07-19 4:16 ` Dmitry Torokhov
2012-07-19 13:50 ` Henrik Rydberg
2012-07-19 13:56 ` Simon Budig
2012-07-22 15:02 ` [PATCH v9] " simon.budig
2012-07-23 16:54 ` Dmitry Torokhov
2012-07-23 17:45 ` Henrik Rydberg
2012-07-24 20:06 ` Simon Budig
2012-07-24 20:26 ` Dmitry Torokhov
2011-09-26 16:06 Touch screen driver for the EDT FT5x06 based "polytouch" touchscreens simon.budig
2011-09-26 16:06 ` [PATCH] Touchscreen driver for FT5x06 based EDT displays simon.budig
2011-09-26 16:14 ` Simon Budig
2011-09-28 5:47 ` Dmitry Torokhov
2011-09-29 15:46 ` Simon Budig
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=4F7CB48E.9060305@kernelconcepts.de \
--to=simon.budig@kernelconcepts.de \
--cc=agust@denx.de \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=yanok@emcraft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.