linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Magnus Damm" <magnus.damm@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-input@vger.kernel.org, lethal@linux-sh.org,
	dmitry.torokhov@gmail.com, linux-sh@vger.kernel.org
Subject: Re: [PATCH] Touch screen driver for the SuperH MigoR board
Date: Wed, 26 Mar 2008 13:03:09 +0900	[thread overview]
Message-ID: <aec7e5c30803252103x1534e43dv3f31a3bc731fc9bf@mail.gmail.com> (raw)
In-Reply-To: <20080321155515.bb9f945e.akpm@linux-foundation.org>

On Sat, Mar 22, 2008 at 7:55 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Fri, 21 Mar 2008 20:16:30 +0900
>  Magnus Damm <magnus.damm@gmail.com> wrote:
>
>  > This patch adds a touch screen driver for the MigoR board. The chip we
>  > interface to is unfortunately a custom designed microcontroller speaking
>  > some undocumented protocol over i2c.

[snip]

>  > +static irqreturn_t migor_ts_isr(int irq, void *dev_id)
>  > +{
>  > +     struct migor_ts_priv *priv = dev_id;
>  > +
>  > +     disable_irq_nosync(irq);
>  > +     schedule_delayed_work(&priv->work, HZ / 20);
>  > +     return IRQ_HANDLED;
>  > +}
>
>  eww.  Doing a disable_irq() on each interrupt and reenabling interrupts
>  later isn't very nice.  And it might cause havoc if that interrupt is
>  shared.
>
>  Why is this code like this?

The code is more or less doing the same thing as the ads7846 driver,
except this one is communicating over i2c instead of spi. This means
is because of great hardware design with interrupts that needs to be
acked over an extremely slow serial bus. So we just disable the
interrupt and handle everything from a different context. Apart from
avoiding serious latency issues, doing things from interrupt context
simply won't work since the i2c bus driver may be interrupt driven and
may sleep while waiting for the serial bus data to be sent.

And you are right, this won't work with shared interrupts.

>  No, don't answer that question.  If I wanted to know this when reading
>  the code, then others will want to know it also.  It needs to be fully
>  explained in code comments, please.

Yeah, having a comment in there would certainly help.

>  Can we not pull the data out of the hardware at interrupt time and then
>  queue that data up for the keventd processing?

No can do, the serial bus is too slow.

>  > +static int migor_ts_remove(struct i2c_client *client)
>  > +{
>  > +     struct migor_ts_priv *priv = dev_get_drvdata(&client->dev);
>  > +
>  > +     /* disable controller */
>  > +     i2c_master_send(client, migor_ts_dis_seq, sizeof(migor_ts_dis_seq));
>  > +
>  > +     free_irq(priv->irq, priv);
>  > +     input_unregister_device(priv->input);
>  > +     kfree(priv);
>  > +     return 0;
>  > +}
>
>  Might a delayed work still be scheduled when we run this?  A
>  cancel_delayed_work_sync() would set minds at rest.

Good catch. I'll fix this up and repost.

Thanks!

/ magnus

  reply	other threads:[~2008-03-26  4:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-21 11:16 [PATCH] Touch screen driver for the SuperH MigoR board Magnus Damm
2008-03-21 22:55 ` Andrew Morton
2008-03-26  4:03   ` Magnus Damm [this message]
2008-03-26 11:29     ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2008-07-01 10:33 Nicholas Beck
2008-07-01 11:22 ` Magnus Damm

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=aec7e5c30803252103x1534e43dv3f31a3bc731fc9bf@mail.gmail.com \
    --to=magnus.damm@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    /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).