From e1b18ea809a4493c316030e527d486126f3c3162 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 5 Aug 2013 15:53:32 +0800 Subject: spi: octeon: Remove my_master pointer from struct octeon_spi Pass master to platform_set_drvdata() then we can remove my_master pointer. Signed-off-by: Axel Lin Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index 24daf96..ad924a1 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -28,7 +28,6 @@ #define OCTEON_SPI_MAX_CLOCK_HZ 16000000 struct octeon_spi { - struct spi_master *my_master; u64 register_base; u64 last_cfg; u64 cs_enax; @@ -268,7 +267,6 @@ static int octeon_spi_nop_transfer_hardware(struct spi_master *master) static int octeon_spi_probe(struct platform_device *pdev) { - struct resource *res_mem; struct spi_master *master; struct octeon_spi *p; @@ -278,8 +276,7 @@ static int octeon_spi_probe(struct platform_device *pdev) if (!master) return -ENOMEM; p = spi_master_get_devdata(master); - platform_set_drvdata(pdev, p); - p->my_master = master; + platform_set_drvdata(pdev, master); res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -328,10 +325,11 @@ fail: static int octeon_spi_remove(struct platform_device *pdev) { - struct octeon_spi *p = platform_get_drvdata(pdev); + struct spi_master *master = platform_get_drvdata(pdev); + struct octeon_spi *p = spi_master_get_devdata(master); u64 register_base = p->register_base; - spi_unregister_master(p->my_master); + spi_unregister_master(master); /* Clear the CSENA* and put everything in a known state. */ cvmx_write_csr(register_base + OCTEON_SPI_CFG, 0); -- cgit v0.10.2 From fe81109b6d852cd5ff37099e2738538198c22dfd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 11 Aug 2013 23:07:29 +0800 Subject: spi: octeon: Remove empty octeon_spi_nop_transfer_hardware function Both prepare_transfer_hardware and unprepare_transfer_hardware callbacks are optional, so we don't need to implement an empty function for them. Signed-off-by: Axel Lin Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index ad924a1..983021a 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -260,11 +260,6 @@ static void octeon_spi_cleanup(struct spi_device *spi) kfree(old_setup); } -static int octeon_spi_nop_transfer_hardware(struct spi_master *master) -{ - return 0; -} - static int octeon_spi_probe(struct platform_device *pdev) { struct resource *res_mem; @@ -304,9 +299,7 @@ static int octeon_spi_probe(struct platform_device *pdev) master->setup = octeon_spi_setup; master->cleanup = octeon_spi_cleanup; - master->prepare_transfer_hardware = octeon_spi_nop_transfer_hardware; master->transfer_one_message = octeon_spi_transfer_one_message; - master->unprepare_transfer_hardware = octeon_spi_nop_transfer_hardware; master->dev.of_node = pdev->dev.of_node; err = spi_register_master(master); -- cgit v0.10.2 From a35c6bea8288d526aa0fe4180884e01945d307ab Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 11 Aug 2013 23:08:21 +0800 Subject: spi: octeon: Remove unused bits_per_word variable in octeon_spi_do_transfer Signed-off-by: Axel Lin Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index 983021a..c7c772a 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -63,7 +63,6 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, unsigned int speed_hz; int mode; bool cpha, cpol; - int bits_per_word; const u8 *tx_buf; u8 *rx_buf; int len; @@ -75,12 +74,9 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, mode = msg_setup->mode; cpha = mode & SPI_CPHA; cpol = mode & SPI_CPOL; - bits_per_word = msg_setup->bits_per_word; if (xfer->speed_hz) speed_hz = xfer->speed_hz; - if (xfer->bits_per_word) - bits_per_word = xfer->bits_per_word; if (speed_hz > OCTEON_SPI_MAX_CLOCK_HZ) speed_hz = OCTEON_SPI_MAX_CLOCK_HZ; -- cgit v0.10.2 From f79cc88e4e7a673cd1b068c46cbbed97cce5f6da Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 11 Aug 2013 23:09:43 +0800 Subject: spi: octeon: Convert to use bits_per_word_mask Since commit 543bb25 "spi: add ability to validate xfer->bits_per_word in SPI core", the driver can set bits_per_word_mask for the master then the SPI core will reject transfers that attempt to use an unsupported bits_per_word value. So we can remove octeon_spi_validate_bpw() and let SPI core handle the checking. Signed-off-by: Axel Lin Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-octeon.c b/drivers/spi/spi-octeon.c index c7c772a..5f28ddb 100644 --- a/drivers/spi/spi-octeon.c +++ b/drivers/spi/spi-octeon.c @@ -161,19 +161,6 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, return xfer->len; } -static int octeon_spi_validate_bpw(struct spi_device *spi, u32 speed) -{ - switch (speed) { - case 8: - break; - default: - dev_err(&spi->dev, "Error: %d bits per word not supported\n", - speed); - return -EINVAL; - } - return 0; -} - static int octeon_spi_transfer_one_message(struct spi_master *master, struct spi_message *msg) { @@ -192,15 +179,6 @@ static int octeon_spi_transfer_one_message(struct spi_master *master, } list_for_each_entry(xfer, &msg->transfers, transfer_list) { - if (xfer->bits_per_word) { - status = octeon_spi_validate_bpw(msg->spi, - xfer->bits_per_word); - if (status) - goto err; - } - } - - list_for_each_entry(xfer, &msg->transfers, transfer_list) { bool last_xfer = &xfer->transfer_list == msg->transfers.prev; int r = octeon_spi_do_transfer(p, msg, xfer, last_xfer); if (r < 0) { @@ -231,14 +209,9 @@ static struct octeon_spi_setup *octeon_spi_new_setup(struct spi_device *spi) static int octeon_spi_setup(struct spi_device *spi) { - int r; struct octeon_spi_setup *new_setup; struct octeon_spi_setup *old_setup = spi_get_ctldata(spi); - r = octeon_spi_validate_bpw(spi, spi->bits_per_word); - if (r) - return r; - new_setup = octeon_spi_new_setup(spi); if (!new_setup) return -ENOMEM; @@ -296,6 +269,7 @@ static int octeon_spi_probe(struct platform_device *pdev) 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); master->dev.of_node = pdev->dev.of_node; err = spi_register_master(master); -- cgit v0.10.2