linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Takashi Yoshii <takasi-y-nDL5PR/MsHhHfZP73Gtkiw@public.gmane.org>,
	Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Geert Uytterhoeven
	<geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Subject: [PATCH 09/10] spi: sh-msiof: Convert to let spi core validate xfer->bits_per_word
Date: Thu, 20 Feb 2014 14:43:08 +0000	[thread overview]
Message-ID: <1392907389-21798-10-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1392907389-21798-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>

From: Geert Uytterhoeven <geert+renesas@linux-m68k.org>

Set bits_per_word_mask so the spi core will reject transfers that attempt
to use an unsupported bits_per_word value.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
 drivers/spi/spi-sh-msiof.c |   19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 7add4be37987..bd300fcb7116 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -441,22 +441,6 @@ static u32 sh_msiof_spi_hz(struct spi_device *spi, struct spi_transfer *t)
 	return hz;
 }
 
-static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
-				       struct spi_transfer *t)
-{
-	int bits;
-
-	/* noting to check hz values against since parent clock is disabled */
-
-	bits = sh_msiof_spi_bits(spi, t);
-	if (bits < 8)
-		return -EINVAL;
-	if (bits > 32)
-		return -EINVAL;
-
-	return spi_bitbang_setup_transfer(spi, t);
-}
-
 static int sh_msiof_spi_setup(struct spi_device *spi)
 {
 	struct device_node	*np = spi->master->dev.of_node;
@@ -822,10 +806,11 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 	master->cleanup = spi_bitbang_cleanup;
 	master->prepare_message = sh_msiof_prepare_message;
 	master->unprepare_message = sh_msiof_unprepare_message;
+	master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
 
 	p->bitbang.master = master;
 	p->bitbang.chipselect = sh_msiof_spi_chipselect;
-	p->bitbang.setup_transfer = sh_msiof_spi_setup_transfer;
+	p->bitbang.setup_transfer = spi_bitbang_setup_transfer;
 	p->bitbang.txrx_bufs = sh_msiof_spi_txrx;
 	p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word;
 	p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word;
-- 
1.7.9.5


  parent reply	other threads:[~2014-02-20 14:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20 14:42 [PATCH 00/10] spi: sh-msiof: Add support for R-Car H2 and M2 Geert Uytterhoeven
2014-02-20 14:43 ` [PATCH 01/10] spi: sh-msiof: Fix SPI bus population from DT Geert Uytterhoeven
2014-02-22  3:10   ` Mark Brown
2014-02-20 14:43 ` [PATCH 02/10] spi: sh-msiof: Typo in comment s/tx/rx/ Geert Uytterhoeven
2014-02-22  3:10   ` Mark Brown
2014-02-20 14:43 ` [PATCH 03/10] spi: sh-msiof: Change hz from unsigned long to u32 Geert Uytterhoeven
2014-02-22  3:11   ` Mark Brown
     [not found] ` <1392907389-21798-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-02-20 14:43   ` [PATCH 04/10] spi: sh-msiof: Add more register documentation Geert Uytterhoeven
2014-02-22  3:11     ` Mark Brown
2014-02-20 14:43   ` Geert Uytterhoeven [this message]
2014-02-20 14:43 ` [PATCH 05/10] spi: sh-msiof: Use the core cs_gpio field, and make it optional Geert Uytterhoeven
2014-02-22  3:12   ` Mark Brown
2014-02-20 14:43 ` [PATCH 06/10] spi: sh-msiof: Improve binding documentation Geert Uytterhoeven
2014-02-20 14:43 ` [PATCH 07/10] spi: sh-msiof: Add support for R-Car H2 and M2 Geert Uytterhoeven
     [not found]   ` <1392907389-21798-8-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-02-20 15:41     ` Magnus Damm
2014-02-20 16:13       ` Geert Uytterhoeven
     [not found]         ` <CAMuHMdUByWPcYM8M_m5NVM4QP5cQE_tOLGQg=2fTNF7gqkUhig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-22  3:14           ` Mark Brown
2014-02-24  2:45         ` Magnus Damm
2014-02-24  7:39           ` Geert Uytterhoeven
2014-02-24  8:09             ` Magnus Damm
2014-02-20 14:43 ` [PATCH 08/10] spi: sh-msiof: Move clock management to (un)prepare_message() Geert Uytterhoeven
2014-02-22  3:27   ` Mark Brown
2014-02-24  9:48     ` Geert Uytterhoeven
2014-02-24 13:07       ` Mark Brown
2014-02-25  1:43       ` Magnus Damm
2014-02-20 14:43 ` [PATCH 10/10] spi: sh-msiof: Use core message handling instead of spi-bitbang Geert Uytterhoeven

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=1392907389-21798-10-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=takasi-y-nDL5PR/MsHhHfZP73Gtkiw@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).