Hi Sylvain,
On Mon, Mar 15, 2010 at 01:06:33PM +0000, Centelles, Sylvain wrote:
> Thx for your fast answer.
> I had seen this piece of code. But if this is the only purpose of the
> msg->status, then it means it's only used to give return status of the
> transfer after the completion.
> That mean that the only possible value will be an error code or success.
> The EINPROGRESS (used in the pxa2xx_spi.c for example) will never have a
> chance to be returned at this place, as any completion will overwrite it.
> Right? That what was confusing me...
No. Any caller of the spi_async() routine must check the msg->status field on
return. See for example the spidev_sync() function in drivers/spi/spidev.c.
Snippet follows:
spin_lock_irq(&spidev->spi_lock);
if (spidev->spi == NULL)
status = -ESHUTDOWN;
else
status = spi_async(spidev->spi, message);
spin_unlock_irq(&spidev->spi_lock);
if (status == 0) {
wait_for_completion(&done);
status = message->status;
if (status == 0)
status = message->actual_length;
}
baruch
> -----Original Message-----
> From: Baruch Siach [mailto:[email protected]]
> Sent: Monday, March 15, 2010 12:06 PM
> To: Centelles, Sylvain
> Cc: [email protected]
> Subject: Re: [spi-devel-general] Purpose of the "msg->status"
>
> Hi Sylvain,
>
> On Mon, Mar 15, 2010 at 10:13:52AM +0000, Centelles, Sylvain wrote:
> > I'm currently working on a spi driver for Intel platform, and when reading
> > the various other spi drivers available in the kernel, I saw the
> > msg->status
> > was often updated (EINPROGRESS for example), but could not figure out who
> > checks this status. I would have thought it would be needed to prevent
> > concurrent access for example, but I didn't see anything in the core, nore
> > in any driver. If it's not needed, then I would not like to carry some
> > useless status updates in the driver I'm currently working on.
> > Maybe I missed something... So if someone can please give some info on
> > this, it would be great!
>
> See the spi_sync() function in drivers/spi/spi.c. Following is a snippet from
> this function:
>
> if (status == 0) {
> wait_for_completion(&done);
> status = message->status;
> }
> message->context = NULL;
> return status;
>
> baruch
>
> --
> ~. .~ Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
> - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
> ---------------------------------------------------------------------
> Intel Corporation SAS (French simplified joint stock company)
> Registered headquarters: "Les Montalets"- 2, rue de Paris,
> 92196 Meudon Cedex, France
> Registration Number: 302 456 199 R.C.S. NANTERRE
> Capital: 4,572,000 Euros
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
spi-devel-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general