From: "Ahmed S. Darwish" <darwish.07@gmail.com> To: Bryan Wu <cooloney.lkml@gmail.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>, bryan.wu@analog.com, Andrey Panin <pazke@donpac.ru>, Roel Kluin <12o3l@tiscali.nl>, linux-input@atrey.karlin.mff.cuni.cz, linux-joystick@atrey.karlin.mff.cuni.cz, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Jean Delvare <khali@linux-fr.org> Subject: Re: [PATCH try #3] Input/Joystick Driver: add support AD7142 joystick driver Date: Tue, 16 Oct 2007 18:40:51 +0200 Message-ID: <20071016164051.GC2528@Ahmed> (raw) In-Reply-To: <386072610710152308o3d4a04bfgfcecafc9c345286b@mail.gmail.com> On Tue, Oct 16, 2007 at 02:08:04PM +0800, Bryan Wu wrote: > On 10/16/07, Ahmed S. Darwish <darwish.07@gmail.com> wrote: > > On Mon, Oct 15, 2007 at 11:48:17AM -0400, Dmitry Torokhov wrote: > > > Hi Bryan, > > > > > > On 10/15/07, Bryan Wu <bryan.wu@analog.com> wrote: > > > > + > > > > +static int ad7142_thread(void *nothing) > > > > +{ > > > > + do { > > > > + wait_for_completion(&ad7142_completion); > > > > + ad7142_decode(); > > > > + enable_irq(CONFIG_BFIN_JOYSTICK_IRQ_PFX); > > > > + } while (!kthread_should_stop()); > > > > + > > > > > > No, this is not going to work well: > > > - you at least need to reinitialize the completion before enabling > > > IRQ, otherwise you will spin in a very tight loop > > > - if noone would touch the joystick ad7142_clsoe would() block > > > infinitely because noone would signal the completion and > > > ad7142_thread() would never stop. > > > > > > Completion is just not a good abstraction here... Please use work > > > abstraction and possibly a separate workqueue. > > > > > > > Bryan, I'm very interested in the technical advantage of using a completion > > here. > > > You are welcome, I'd like to discuss these things here. > > > In my _not-experienced_ opinion, I remember completions was created mainly for > > "create_task, wait till task got finished, go on" case. Why using it in a > > different context while workqueues was created for a similar situation to > > ad7142 one (non-irq context bottom-half) ? > > I like completion because it is simple to use and understand. Your > understanding is right. But there is no limit for using different > context with completion. completion is a wrapper of waitqueue+done > flag. For some drivers, in process context call > wait_for_completetion(), then schedule out and in irq handler call > complete(). This is very simple and helpful for driver design (For > example, you call dma function to transfer data, then you schedule out > and then DMA IRQ handler will call complete() to wakeup you). > Thank you for such a useful information. > But in this driver, a) can not call ad7142_decode() in IRQ handler, > because it will sleep in IRQ context by calling some i2c API, b) in > original design, creating a new kthread and using some waitqueue API > is the same way as using workqueue, c) cannot use completion as Dmitry > said. > > I am going to use workqueue here. > > Any idea? > I have no better thoughts than the ones provided by Dmitry actually. > Thanks > -Bryan Wu Regards :), -- Ahmed S. Darwish HomePage: http://darwish.07.googlepages.com Blog: http://darwish-07.blogspot.com
next prev parent reply index Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-10-15 14:47 Bryan Wu 2007-10-15 15:48 ` Dmitry Torokhov 2007-10-15 17:24 ` Bryan Wu 2007-10-15 17:40 ` Dmitry Torokhov 2007-10-16 5:51 ` Bryan Wu 2007-10-16 16:53 ` Dmitry Torokhov 2007-10-15 18:27 ` Ahmed S. Darwish 2007-10-16 6:08 ` Bryan Wu 2007-10-16 16:40 ` Ahmed S. Darwish [this message] 2007-10-15 19:35 ` Jean Delvare
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=20071016164051.GC2528@Ahmed \ --to=darwish.07@gmail.com \ --cc=12o3l@tiscali.nl \ --cc=akpm@linux-foundation.org \ --cc=bryan.wu@analog.com \ --cc=cooloney.lkml@gmail.com \ --cc=dmitry.torokhov@gmail.com \ --cc=khali@linux-fr.org \ --cc=linux-input@atrey.karlin.mff.cuni.cz \ --cc=linux-joystick@atrey.karlin.mff.cuni.cz \ --cc=linux-kernel@vger.kernel.org \ --cc=pazke@donpac.ru \ /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
LKML Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lkml.kernel.org/lkml/0 lkml/git/0.git git clone --mirror https://lkml.kernel.org/lkml/1 lkml/git/1.git git clone --mirror https://lkml.kernel.org/lkml/2 lkml/git/2.git git clone --mirror https://lkml.kernel.org/lkml/3 lkml/git/3.git git clone --mirror https://lkml.kernel.org/lkml/4 lkml/git/4.git git clone --mirror https://lkml.kernel.org/lkml/5 lkml/git/5.git git clone --mirror https://lkml.kernel.org/lkml/6 lkml/git/6.git git clone --mirror https://lkml.kernel.org/lkml/7 lkml/git/7.git git clone --mirror https://lkml.kernel.org/lkml/8 lkml/git/8.git git clone --mirror https://lkml.kernel.org/lkml/9 lkml/git/9.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 lkml lkml/ https://lkml.kernel.org/lkml \ linux-kernel@vger.kernel.org public-inbox-index lkml Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git