public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: Paul Fertser <fercerpav@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pcf50633: revise locking for ADC
Date: Mon, 3 Aug 2009 19:57:34 +0200	[thread overview]
Message-ID: <20090803175733.GD28606@sortiz.org> (raw)
In-Reply-To: <200907281845.n6SIjdjC025315@home.pavel.comp>

Hi Paul,

On Tue, Jul 28, 2009 at 12:58:48AM +0400, Paul Fertser wrote:
> Current implementation is prone to races, this patch attempts to remove all
> but one (in pcf50633_adc_sync_read).
> 
> The idea is that we need to guard the queue access only on inserting and
> removing items. If we insert and there're no more items in the queue it
> means that the last irq already happened and we need to trigger ADC
> manually. If not, then the next conversion will be triggered by the irq
> handler upon completion of the previous.


> @@ -136,9 +133,13 @@ int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
>  	req->callback_param = req;
>  
>  	init_completion(&req->completion);
> -	adc_enqueue_request(pcf, req);
> +	err = adc_enqueue_request(pcf, req);
> +	if (err)
> +		return err;
> +
>  	wait_for_completion(&req->completion);
>  
> +	/* FIXME by this time req might be already freed */
In fact, this is problematic.
Shouldn't the request be freed by the callback (in the async request), or by
sync_read() ?

Your patch looks fine though, I applied it to my for-next branch.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

      reply	other threads:[~2009-08-03 17:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27 20:58 [PATCH] pcf50633: revise locking for ADC Paul Fertser
2009-08-03 17:57 ` Samuel Ortiz [this message]

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=20090803175733.GD28606@sortiz.org \
    --to=sameo@linux.intel.com \
    --cc=fercerpav@gmail.com \
    --cc=linux-kernel@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