From 3a44623d5e1404b29786f1afd225d1aa04a4ae90 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 21 Jan 2014 16:22:47 -0500 Subject: spi: delete non-required instances of include None of these files are actually using any __init type directives and hence don't need to include . Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker Signed-off-by: Mark Brown --- drivers/spi/spi-octeon.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/spi/spi-octeon.c') diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index 67249a48b391..5665ae9ed92f 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include -- cgit From 0a4e210e9965de3812df079fc70a702afc4445d2 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 15 Jan 2014 13:22:17 +0800 Subject: spi: octeon: Use list_is_last() instead of open-coded Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-octeon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/spi/spi-octeon.c') diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index 67249a48b391..862ef30853d3 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -179,7 +179,8 @@ static int octeon_spi_transfer_one_message(struct spi_master *master, } list_for_each_entry(xfer, &msg->transfers, transfer_list) { - bool last_xfer = &xfer->transfer_list == msg->transfers.prev; + bool last_xfer = list_is_last(&xfer->transfer_list, + &msg->transfers); int r = octeon_spi_do_transfer(p, msg, xfer, last_xfer); if (r < 0) { status = r; -- cgit From 0fd73763350fee019cd35d8d4c3c384f6ee493a1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 8 Feb 2014 23:12:20 +0800 Subject: spi: octeon: Remove unused bits_per_word from struct octeon_spi_setup Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-octeon.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/spi/spi-octeon.c') diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index 862ef30853d3..31b41445a85e 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -37,7 +37,6 @@ struct octeon_spi_setup { u32 max_speed_hz; u8 chip_select; u8 mode; - u8 bits_per_word; }; static void octeon_spi_wait_ready(struct octeon_spi *p) @@ -204,7 +203,6 @@ static struct octeon_spi_setup *octeon_spi_new_setup(struct spi_device *spi) setup->max_speed_hz = spi->max_speed_hz; setup->chip_select = spi->chip_select; setup->mode = spi->mode; - setup->bits_per_word = spi->bits_per_word; return setup; } -- cgit From 85fe414d3228bdecc52366692c6f70c750f687aa Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 19 Feb 2014 17:30:52 +0800 Subject: spi: octeon: Remove struct octeon_spi_setup usage Current code uses struct octeon_spi_setup to store max_speed_hz, chip_select and mode settings of current spi device. We can always get the same settings in octeon_spi_do_transfer() by msg->spi. So this patch removes struct octeon_spi_setup and octeon_spi_setup, octeon_spi_cleanup functions. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-octeon.c | 69 +++++------------------------------------------- 1 file changed, 7 insertions(+), 62 deletions(-) (limited to 'drivers/spi/spi-octeon.c') diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index 31b41445a85e..a51458985ccf 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -33,12 +33,6 @@ struct octeon_spi { u64 cs_enax; }; -struct octeon_spi_setup { - u32 max_speed_hz; - u8 chip_select; - u8 mode; -}; - static void octeon_spi_wait_ready(struct octeon_spi *p) { union cvmx_mpi_sts mpi_sts; @@ -56,6 +50,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, struct spi_transfer *xfer, bool last_xfer) { + struct spi_device *spi = msg->spi; union cvmx_mpi_cfg mpi_cfg; union cvmx_mpi_tx mpi_tx; unsigned int clkdiv; @@ -67,16 +62,11 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, int len; int i; - struct octeon_spi_setup *msg_setup = spi_get_ctldata(msg->spi); - - speed_hz = msg_setup->max_speed_hz; - mode = msg_setup->mode; + mode = spi->mode; cpha = mode & SPI_CPHA; cpol = mode & SPI_CPOL; - if (xfer->speed_hz) - speed_hz = xfer->speed_hz; - + speed_hz = xfer->speed_hz ? : spi->max_speed_hz; if (speed_hz > OCTEON_SPI_MAX_CLOCK_HZ) speed_hz = OCTEON_SPI_MAX_CLOCK_HZ; @@ -92,8 +82,8 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, mpi_cfg.s.cslate = cpha ? 1 : 0; mpi_cfg.s.enable = 1; - if (msg_setup->chip_select < 4) - p->cs_enax |= 1ull << (12 + msg_setup->chip_select); + if (spi->chip_select < 4) + p->cs_enax |= 1ull << (12 + spi->chip_select); mpi_cfg.u64 |= p->cs_enax; if (mpi_cfg.u64 != p->last_cfg) { @@ -113,7 +103,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, cvmx_write_csr(p->register_base + OCTEON_SPI_DAT0 + (8 * i), d); } mpi_tx.u64 = 0; - mpi_tx.s.csid = msg_setup->chip_select; + mpi_tx.s.csid = spi->chip_select; mpi_tx.s.leavecs = 1; mpi_tx.s.txnum = tx_buf ? OCTEON_SPI_MAX_BYTES : 0; mpi_tx.s.totnum = OCTEON_SPI_MAX_BYTES; @@ -138,7 +128,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, } mpi_tx.u64 = 0; - mpi_tx.s.csid = msg_setup->chip_select; + mpi_tx.s.csid = spi->chip_select; if (last_xfer) mpi_tx.s.leavecs = xfer->cs_change; else @@ -168,15 +158,6 @@ static int octeon_spi_transfer_one_message(struct spi_master *master, int status = 0; struct spi_transfer *xfer; - /* - * We better have set the configuration via a call to .setup - * before we get here. - */ - if (spi_get_ctldata(msg->spi) == NULL) { - status = -EINVAL; - goto err; - } - list_for_each_entry(xfer, &msg->transfers, transfer_list) { bool last_xfer = list_is_last(&xfer->transfer_list, &msg->transfers); @@ -194,40 +175,6 @@ err: return status; } -static struct octeon_spi_setup *octeon_spi_new_setup(struct spi_device *spi) -{ - struct octeon_spi_setup *setup = kzalloc(sizeof(*setup), GFP_KERNEL); - if (!setup) - return NULL; - - setup->max_speed_hz = spi->max_speed_hz; - setup->chip_select = spi->chip_select; - setup->mode = spi->mode; - return setup; -} - -static int octeon_spi_setup(struct spi_device *spi) -{ - struct octeon_spi_setup *new_setup; - struct octeon_spi_setup *old_setup = spi_get_ctldata(spi); - - new_setup = octeon_spi_new_setup(spi); - if (!new_setup) - return -ENOMEM; - - spi_set_ctldata(spi, new_setup); - kfree(old_setup); - - return 0; -} - -static void octeon_spi_cleanup(struct spi_device *spi) -{ - struct octeon_spi_setup *old_setup = spi_get_ctldata(spi); - spi_set_ctldata(spi, NULL); - kfree(old_setup); -} - static int octeon_spi_probe(struct platform_device *pdev) { struct resource *res_mem; @@ -265,8 +212,6 @@ static int octeon_spi_probe(struct platform_device *pdev) SPI_LSB_FIRST | SPI_3WIRE; - master->setup = octeon_spi_setup; - master->cleanup = octeon_spi_cleanup; master->transfer_one_message = octeon_spi_transfer_one_message; master->bits_per_word_mask = SPI_BPW_MASK(8); -- cgit From 7984b5ca5c6245e332adcb8a8c2aefb2732b40bf Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 19 Feb 2014 17:34:47 +0800 Subject: spi: octeon: Convert to let spi core validate transfer speed Set master->max_speed_hz then spi core will handle checking transfer speed. The behavior is different from current code when the speed_hz is greater than the maximum transfer speed supported by the controller. Unless there is other good reason, I think we had better make the behavior consistent with what spi core does. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-octeon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/spi/spi-octeon.c') diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index a51458985ccf..1ed259449c7f 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -67,8 +67,6 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, cpol = mode & SPI_CPOL; speed_hz = xfer->speed_hz ? : spi->max_speed_hz; - if (speed_hz > OCTEON_SPI_MAX_CLOCK_HZ) - speed_hz = OCTEON_SPI_MAX_CLOCK_HZ; clkdiv = octeon_get_io_clock_rate() / (2 * speed_hz); @@ -214,6 +212,7 @@ static int octeon_spi_probe(struct platform_device *pdev) master->transfer_one_message = octeon_spi_transfer_one_message; master->bits_per_word_mask = SPI_BPW_MASK(8); + master->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ; master->dev.of_node = pdev->dev.of_node; err = devm_spi_register_master(&pdev->dev, master); -- cgit