linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <sebastian-E0PNVn5OA6ohrxcnuTQ+TQ@public.gmane.org>
To: David Brownell
	<dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [RFC] SPI transfer with (count % bpw >> 3) != 0
Date: Fri, 16 Oct 2009 22:37:08 +0200	[thread overview]
Message-ID: <20091016203708.GB9552@Chamillionaire.breakpoint.cc> (raw)

Just stumbled over this one: for instance bpw = 16 and len = 1.
I've found a few possible results:
- no transfer at all and return 0 (spi_gpio)
- no transfer at all and return with -EINVAL (spi_mpc8xxx)
- transfer two bytes and overwrite one probably unallocated byte in the
  read case. Return 1 (amba-pl022)
- write until an exception stops it (orion_spi)

Variant three and four is obviously wrong and should be fixed. However
I'm torn between variant one and two as the correct way to deal with
this. This problem is not just an in-kernel thing but also exposed to
user space via spidev. The man page for read() and write() says that the
function might return less than the number of requested bytes if more
data is not available. In this case there is more data available but
due to an programming error (?) we don't get anything. From that angle
-EINVAL sounds good.
David?

Sebastian

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference

                 reply	other threads:[~2009-10-16 20:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20091016203708.GB9552@Chamillionaire.breakpoint.cc \
    --to=sebastian-e0pnvn5oa6ohrxcnutq+tq@public.gmane.org \
    --cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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).