From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: linux-input@vger.kernel.org, kyungmin.park@samsung.com,
m.szyprowski@samsung.com
Subject: Re: [PATCH] Input: add touchscreen driver for MELFAS MCS-5000 controller
Date: Thu, 14 May 2009 19:52:42 -0700 [thread overview]
Message-ID: <200905141952.43442.dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <4A0CBC24.2060605@samsung.com>
On Thursday 14 May 2009 17:49:40 Joonyoung Shim wrote:
> >>>> + case INPUT_TYPE_SINGLE:
> >>>> + x = (buffer[READ_X_POS_UPPER] << 8) | buffer[READ_X_POS_LOWER];
> >>>> + y = (buffer[READ_Y_POS_UPPER] << 8) | buffer[READ_Y_POS_LOWER];
> >>>> +
> >>>> + input_report_key(data->input_dev, BTN_TOUCH, 1);
> >>>> + input_report_abs(data->input_dev, ABS_X, x);
> >>>> + input_report_abs(data->input_dev, ABS_Y, y);
> >>>> + input_report_abs(data->input_dev, ABS_PRESSURE,
> >>>> + DEFAULT_PRESSURE);
> >>>
> >>> If the hardware does not support pressure reading don't fake it.
> >>> BTN_TOUCH should be enough to signal touch.
> >>
> >> MCS-5000 supports pressure reading, but the value of pressure is
> >> unstable in my target, so i used the static value defined.
> >> I will add pressure reading after more test.
> >
> > OK. Alternatively you may indicate in the platform data if pressure
> > reading is supported and set ABS_PRESSURE bit and report pressure only
> > when you know it works well.
>
> OK, i will add the thing about pressure in the platform data.
>
> >> signal touch? Do you mean single touch?
> >
> > I meant "signal" as "convey", "indicate".
>
> I see :)
>
> >>>> +
> >>>> + if (request_irq(data->irq, mcs5000_ts_interrupt,
> >>>> + IRQF_TRIGGER_LOW, "mcs5000_ts_input", data)) {
> >>>> + dev_err(&data->client->dev, "Failed to register interrupt\n");
> >>>> + ret = -EINVAL;
> >>>
> >>> Why EINVAL and not EBUSY? Or better yet, why don't you propagate what
> >>> reqiest_irq returned?
> >>
> >> Hmm, EINVAL is used in wm97xx-core.c file, but you are right.
> >
> > I am always taking patches ;))
>
> OK, i will send the patch about it.
>
> >>>> +{
> >>>> + struct mcs5000_ts_data *data = i2c_get_clientdata(client);
> >>>> +
> >>>> + cancel_work_sync(&data->ts_event_work);
> >>>
> >>> There is a race here, IRQ handler may resubmit work after
> >>> cancel_work_sync() returns. You need to make sure that
> >>> IRQ handler does not resubmit work while device is being shut down.
> >>
> >> ok, how about doing free_irq() before cancel_work_sync() call?
> >
> > Then there is a risk that your work will try to enable_irq() on irq that
> > was freed. I am not sure if IRQ core will be happy with it,
>
> Oh, i didn't think about that, then, how about the following patch?
> The work handler decides trying to enable_irq() by whether irq is NULL or
> not.
>
> @@ -179,7 +179,8 @@ static void mcs5000_ts_irq_worker(struct work_struct
> *work)
>
> mcs5000_ts_input_read(data);
>
> - enable_irq(data->irq);
> + if (data->irq)
> + enable_irq(data->irq);
> }
>
> static irqreturn_t mcs5000_ts_interrupt(int irq, void *dev_id)
> @@ -307,8 +308,9 @@ static int mcs5000_ts_remove(struct i2c_client *client)
> {
> struct mcs5000_ts_data *data = i2c_get_clientdata(client);
>
> - cancel_work_sync(&data->ts_event_work);
> free_irq(data->irq, data);
> + data->irq = 0;
Not if you want to enable IRQ 0 every once in a while. I think a separate
flag, the check in the IRQ handler as opposed to workqueue handler and a
memory barrier should work though.
> + cancel_work_sync(&data->ts_event_work);
> input_unregister_device(data->input_dev);
> input_free_device(data->input_dev);
> kfree(data);
--
Dmitry
next prev parent reply other threads:[~2009-05-15 2:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-11 12:28 [PATCH] Input: add touchscreen driver for MELFAS MCS-5000 controller Joonyoung Shim
2009-05-12 2:09 ` Dmitry Torokhov
2009-05-14 12:52 ` Joonyoung Shim
2009-05-14 15:09 ` Dmitry Torokhov
2009-05-15 0:49 ` Joonyoung Shim
2009-05-15 2:52 ` Dmitry Torokhov [this message]
2009-06-03 5:16 ` Joonyoung Shim
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=200905141952.43442.dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=jy0922.shim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=m.szyprowski@samsung.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.