Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d077197 authored by David Brownell's avatar David Brownell Committed by Linus Torvalds
Browse files

spi: move common spi_setup() functionality into core



Start moving some spi_setup() functionality into the SPI core from the
various spi_master controller drivers:

 - Make that function stop being an inline;

 - Move two common idioms from drivers into that new function:
    * Default bits_per_word to 8 if that field isn't set
    * Issue a standardized dev_dbg() message

This is a net minor source code shrink, and supports enhancments found in
some follow-up patches.

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b4bd2aba
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -555,8 +555,6 @@ static int atmel_spi_setup(struct spi_device *spi)
		return -EINVAL;
	}

	if (bits == 0)
		bits = 8;
	if (bits < 8 || bits > 16) {
		dev_dbg(&spi->dev,
				"setup: invalid bits_per_word %u (8 to 16)\n",
+0 −2
Original line number Diff line number Diff line
@@ -291,8 +291,6 @@ static int au1550_spi_setup(struct spi_device *spi)
{
	struct au1550_spi *hw = spi_master_get_devdata(spi->master);

	if (spi->bits_per_word == 0)
		spi->bits_per_word = 8;
	if (spi->bits_per_word < 4 || spi->bits_per_word > 24) {
		dev_err(&spi->dev, "setup: invalid bits_per_word=%d\n",
			spi->bits_per_word);
+1 −3
Original line number Diff line number Diff line
@@ -619,9 +619,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
		return -EINVAL;
	}

	if (spi->bits_per_word == 0)
		spi->bits_per_word = 8;
	else if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
	if (spi->bits_per_word < 4 || spi->bits_per_word > 32) {
		dev_dbg(&spi->dev, "setup: unsupported %d bit words\n",
			spi->bits_per_word);
		return -EINVAL;
+0 −2
Original line number Diff line number Diff line
@@ -339,8 +339,6 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
	bits = spi->bits_per_word;
	if (t != NULL && t->bits_per_word)
		bits = t->bits_per_word;
	if (!bits)
		bits = 8;

	if (bits > 16) {
		pr_debug("%s: wordsize %d?\n", dev_name(&spi->dev), bits);
+0 −3
Original line number Diff line number Diff line
@@ -369,9 +369,6 @@ static int orion_spi_setup(struct spi_device *spi)
		orion_spi_setbits(orion_spi, ORION_SPI_IF_CONFIG_REG,
				  (1 << 14));

	if (spi->bits_per_word == 0)
		spi->bits_per_word = 8;

	if ((spi->max_speed_hz == 0)
			|| (spi->max_speed_hz > orion_spi->max_speed))
		spi->max_speed_hz = orion_spi->max_speed;
Loading