spi: dw: bug fix and clean up series
Subsystems (2)
cover spi: dw: bug fix and clean up series
The first patch is a regression fix, second one a little fix(no need to backport). The rest is clean up part, in particularly follow up to what previously Jarkko started.
The driver has been tested on Intel MID platform in DMA and PIO modes.
Andy Shevchenko (10):
spi: dw: explicitly free IRQ handler in dw_spi_remove_host()
spi: dw: use plain struct device * at earlier ->probe()
spi: dw: remove unneeded cr0 member of struct chip_data
spi: dw: remove a NULL check when call ->remove()
spi: dw: remove bits_per_word member of struct chip_data
spi: dw: eliminate speed variable in ->transfer_one()
spi: dw: eliminate unused threshold variables
spi: dw: introduce spi_shutdown_chip()
spi: dw-pci: remove unused pdev member from struct dw_spi_pci
spi: dw-mmio: convert to unified device property API
drivers/spi/spi-dw-mmio.c | 7 +++-- drivers/spi/spi-dw-pci.c | 29 +++++++------------- drivers/spi/spi-dw.c | 68 +++++++++++++---------------------------------- drivers/spi/spi-dw.h | 6 +++++ 4 files changed, 37 insertions(+), 73 deletions(-)
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/10 spi: dw: explicitly free IRQ handler in dw_spi_remove_host()
In reply to a message not in the archiveThe following warning occurs when DW SPI is compiled as module and it's a PCI device. On removal stage pcibios_free_irq() called earlier than free_irq() due to the latter is called at managed resources free strage.
------------[ cut here ]------------ WARNING: CPU: 1 PID: 1003 at /home/andy/prj/linux/fs/proc/generic.c:575 remove_proc_entry+0x118/0x150() remove_proc_entry: removing non-empty directory 'irq/38', leaking at least 'dw_spi1' Modules linked in: spi_dw_midpci(-) spi_dw [last unloaded: dw_dmac_core] CPU: 1 PID: 1003 Comm: modprobe Not tainted 4.3.0-rc5-next-20151013+ #32 00000000 00000000 f5535d70 c12dc220 f5535db0 f5535da0 c104e912 c198a6bc f5535dcc 000003eb c198a638 0000023f c11b4098 c11b4098 f54f1ec8 f54f1ea0 f642ba20 f5535db8 c104e96e 00000009 f5535db0 c198a6bc f5535dcc f5535df0 Call Trace: [<c12dc220>] dump_stack+0x41/0x61 [<c104e912>] warn_slowpath_common+0x82/0xb0 [<c11b4098>] ? remove_proc_entry+0x118/0x150 [<c11b4098>] ? remove_proc_entry+0x118/0x150 [<c104e96e>] warn_slowpath_fmt+0x2e/0x30 [<c11b4098>] remove_proc_entry+0x118/0x150 [<c109b96a>] unregister_irq_proc+0xaa/0xc0 [<c109575e>] free_desc+0x1e/0x60 [<c10957d2>] irq_free_descs+0x32/0x70 [<c109b1a0>] irq_domain_free_irqs+0x120/0x150 [<c1039e8c>] mp_unmap_irq+0x5c/0x60 [<c16277b0>] intel_mid_pci_irq_disable+0x20/0x40 [<c1627c7f>] pcibios_free_irq+0xf/0x20 [<c13189f2>] pci_device_remove+0x52/0xb0 [<c13f6367>] __device_release_driver+0x77/0x100 [<c13f6da7>] driver_detach+0x87/0x90 [<c13f5eaa>] bus_remove_driver+0x4a/0xc0 [<c128bf0d>] ? selinux_capable+0xd/0x10 [<c13f7483>] driver_unregister+0x23/0x60 [<c10bad8a>] ? find_module_all+0x5a/0x80 [<c1317413>] pci_unregister_driver+0x13/0x60 [<f80ac654>] dw_spi_driver_exit+0xd/0xf [spi_dw_midpci] [<c10bce9a>] SyS_delete_module+0x17a/0x210
Explicitly call free_irq() at removal stage of the DW SPI driver.
--- drivers/spi/spi-dw.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/spi/spi-dw.c +4 -0
@@ -571,10 +571,14 @@ EXPORT_SYMBOL_GPL(dw_spi_add_host);void dw_spi_remove_host (struct dw_spi *dws) { +struct spi_master *master = dws->master; +if (!dws)return ;dw_spi_debugfs_remove (dws); +devm_free_irq (master->dev.parent, dws->irq, master); +if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit (dws);spi_enable_chip (dws,0 );
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/10 spi: dw: use plain struct device * at earlier ->probe()
In reply to a message not in the archiveThe name of the master device is set during registrationg which happens after we issue the error message. Change it to plain struct device * to see which device registration failed.
--- drivers/spi/spi-dw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-dw.c +1 -1
@@ -520,7 +520,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) ret =devm_request_irq (dev, dws->irq, dw_spi_irq,IRQF_SHARED , dws->name, master);if (ret <0 ) { -dev_err (&master->dev,"can not get IRQ\n" ); +dev_err (dev,"can not get IRQ\n" ); goto err_free_master; }
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/10 spi: dw: remove unneeded cr0 member of struct chip_data
In reply to a message not in the archiveSince we recalculate cr0 each time we start a transfer the chip_data->cr0 becomes redundant. Remove it and related pieces.
This is a follow up to commit 0ed36990a93b (spi: dw: Remove needless if statements).
--- drivers/spi/spi-dw.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/spi/spi-dw.c +2 -12
@@ -30,7 +30,6 @@/* Slave spi_dev related */ struct chip_data { -u16 cr0;u8 cs;/* chip select pin */ u8 n_bytes;/* current is a 1/2/4 byte op */ u8 tmode;/* TR/TO/RO/EEPROM */
@@ -291,7 +290,7 @@ static int dw_spi_transfer_one(struct spi_master *master,u16 txlevel =0 ;u16 clk_div =0 ;u32 speed =0 ; -u32 cr0 =0 ; +u32 cr0;int ret; dws->dma_mapped =0 ;
@@ -306,8 +305,6 @@ static int dw_spi_transfer_one(struct spi_master *master,spi_enable_chip (dws,0 ); - cr0 = chip->cr0; -/* Handle per transfer options for bpw and speed */ speed = chip->speed_hz;if ((transfer->speed_hz != speed) || !chip->clk_div) {
@@ -328,6 +325,7 @@ static int dw_spi_transfer_one(struct spi_master *master, dws->n_bytes =2 ; dws->dma_width =2 ; } +/* Default SPI mode is SCPOL = 0, SCPH = 0 */ cr0 = (transfer->bits_per_word -1 ) | (chip->type <<SPI_FRF_OFFSET ) | (spi->mode <<SPI_MODE_OFFSET )
@@ -449,14 +447,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->bits_per_word = spi->bits_per_word; chip->tmode =0 ;/* Tx & Rx */ -/* Default SPI mode is SCPOL = 0, SCPH = 0 */ - chip->cr0 = (chip->bits_per_word -1 ) - | (chip->type <<SPI_FRF_OFFSET ) - | (spi->mode <<SPI_MODE_OFFSET ) - | (chip->tmode <<SPI_TMOD_OFFSET ); - -if (spi->mode &SPI_LOOP ) - chip->cr0 |=1 <<SPI_SRL_OFFSET ;if (gpio_is_valid (spi->cs_gpio)) { ret = gpio_direction_output(spi->cs_gpio,
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/10 spi: dw: remove a NULL check when call ->remove()
In reply to a message not in the archiveCurrently all users aware about calling dw_spi_remove_host() with properly set parameter. Remove unneeded check.
--- drivers/spi/spi-dw.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-dw.c +0 -2
@@ -563,8 +563,6 @@ void dw_spi_remove_host(struct dw_spi *dws) {struct spi_master *master = dws->master; -if (!dws) -return ;dw_spi_debugfs_remove (dws);devm_free_irq (master->dev.parent, dws->irq, master);
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/10 spi: dw: remove bits_per_word member of struct chip_data
In reply to a message not in the archiveThere is no need to carry over spi->bits_per_word and Co from ->setup() in struct chip_data since ->transfer_one() will anyway take the transfer parameters from struct spi_transfer. This is since SPI core validates both bits_per_word transfer parameter and defaults to spi->bits_per_word in case that per transfer parameter is not set.
--- drivers/spi/spi-dw.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/spi/spi-dw.c +2 -14
@@ -31,17 +31,14 @@/* Slave spi_dev related */ struct chip_data {u8 cs;/* chip select pin */ -u8 n_bytes;/* current is a 1/2/4 byte op */ u8 tmode;/* TR/TO/RO/EEPROM */ u8 type;/* SPI/SSP/MicroWire */ u8 poll_mode;/* 1 means use poll mode */ -u32 dma_width;u32 rx_threshold;u32 tx_threshold;u8 enable_dma; -u8 bits_per_word;u16 clk_div;/* baud rate divider */ u32 speed_hz;/* baud rate */ void (*cs_control)(u32 command);
@@ -294,8 +291,6 @@ static int dw_spi_transfer_one(struct spi_master *master,int ret; dws->dma_mapped =0 ; - dws->n_bytes = chip->n_bytes; - dws->dma_width = chip->dma_width; dws->tx = (void *)transfer->tx_buf; dws->tx_end = dws->tx + transfer->len;
@@ -324,6 +319,8 @@ static int dw_spi_transfer_one(struct spi_master *master, }else if (transfer->bits_per_word ==16 ) { dws->n_bytes =2 ; dws->dma_width =2 ; + }else { +return -EINVAL ; }/* Default SPI mode is SCPOL = 0, SCPH = 0 */ cr0 = (transfer->bits_per_word -1 )
@@ -437,15 +434,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->tx_threshold =0 ; } -if (spi->bits_per_word ==8 ) { - chip->n_bytes =1 ; - chip->dma_width =1 ; - }else if (spi->bits_per_word ==16 ) { - chip->n_bytes =2 ; - chip->dma_width =2 ; - } - chip->bits_per_word = spi->bits_per_word; - chip->tmode =0 ;/* Tx & Rx */ if (gpio_is_valid (spi->cs_gpio)) {
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/10 spi: dw: eliminate speed variable in ->transfer_one()
In reply to a message not in the archiveThere is no point to have a separate variable for speed in ->transfer_one().
While here, remove !chip->clk_div from a condition since it is assigned simultaneously with chip->speed_hz. We can do this safely because
a) transfer speed can't be higher than max_freq and therefore chip->clk_div
can be 0 only when chip->speed_hz is 0, and
b) transfer speed can't be 0, otherwise we will get division by zero exception.
--- drivers/spi/spi-dw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/spi/spi-dw.c +4 -8
@@ -285,8 +285,7 @@ static int dw_spi_transfer_one(struct spi_master *master,struct chip_data *chip =spi_get_ctldata (spi);u8 imask =0 ;u16 txlevel =0 ; -u16 clk_div =0 ; -u32 speed =0 ; +u16 clk_div;u32 cr0;int ret;
@@ -301,14 +300,11 @@ static int dw_spi_transfer_one(struct spi_master *master,spi_enable_chip (dws,0 );/* Handle per transfer options for bpw and speed */ - speed = chip->speed_hz; -if ((transfer->speed_hz != speed) || !chip->clk_div) { - speed = transfer->speed_hz; - +if (transfer->speed_hz != chip->speed_hz) {/* clk_div doesn't support odd number */ - clk_div = (dws->max_freq / speed +1 ) &0xfffe ; + clk_div = (dws->max_freq / transfer->speed_hz +1 ) &0xfffe ; - chip->speed_hz = speed; + chip->speed_hz = transfer->speed_hz; chip->clk_div = clk_div;spi_set_clk (dws, chip->clk_div);
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/10 spi: dw: eliminate unused threshold variables
In reply to a message not in the archiveThe tx_threshold and rx_threshold variables are not used anywhere. Remove them.
--- drivers/spi/spi-dw.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/spi/spi-dw.c +0 -5
@@ -36,8 +36,6 @@ struct chip_data {u8 poll_mode;/* 1 means use poll mode */ -u32 rx_threshold; -u32 tx_threshold;u8 enable_dma;u16 clk_div;/* baud rate divider */ u32 speed_hz;/* baud rate */
@@ -425,9 +423,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->poll_mode = chip_info->poll_mode; chip->type = chip_info->type; - - chip->rx_threshold =0 ; - chip->tx_threshold =0 ; } chip->tmode =0 ;/* Tx & Rx */
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/10 spi: dw: introduce spi_shutdown_chip()
In reply to a message not in the archiveThis helper disables SPI controller and sets clock to 0.
--- drivers/spi/spi-dw.c | 13 ++++++------- drivers/spi/spi-dw.h | 6 ++++++ 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/spi/spi-dw.c +6 -7
@@ -548,22 +548,21 @@ void dw_spi_remove_host(struct dw_spi *dws)if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit (dws); -spi_enable_chip (dws,0 ); -/* Disable clk */ -spi_set_clk (dws,0 ); + +spi_shutdown_chip (dws); }EXPORT_SYMBOL_GPL (dw_spi_remove_host);int dw_spi_suspend_host (struct dw_spi *dws) { -int ret =0 ; +int ret; ret =spi_master_suspend (dws->master);if (ret)return ret; -spi_enable_chip (dws,0 ); -spi_set_clk (dws,0 ); -return ret; + +spi_shutdown_chip (dws); +return 0 ; }EXPORT_SYMBOL_GPL (dw_spi_suspend_host);
drivers/spi/spi-dw.h +6 -0
@@ -225,6 +225,12 @@ static inline void spi_reset_chip(struct dw_spi *dws)spi_enable_chip (dws,1 ); } +static inline void spi_shutdown_chip (struct dw_spi *dws) +{ +spi_enable_chip (dws,0 ); +spi_set_clk (dws,0 ); +} +/* * Each SPI slave device to work with dw_api controller should * has such a structure claiming its working mode (poll or PIO/DMA),
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/10 spi: dw-pci: remove unused pdev member from struct dw_spi_pci
In reply to a message not in the archiveThe pdev member is not used anywhere, thus remove it. Moreover struct dw_spi_pci becomes an equivalent of struct dw_spi and therefore remove entire struct dw_spi_pci.
--- drivers/spi/spi-dw-pci.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/spi/spi-dw-pci.c +9 -20
@@ -23,11 +23,6 @@#define DRIVER_NAME "dw_spi_pci" -struct dw_spi_pci { -struct pci_dev *pdev; -struct dw_spi dws; -}; -struct spi_pci_desc {int (*setup)(struct dw_spi *);u16 num_cs;
@@ -48,7 +43,6 @@ static struct spi_pci_desc spi_pci_mid_desc_2 = {static int spi_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { -struct dw_spi_pci *dwpci;struct dw_spi *dws;struct spi_pci_desc *desc = (struct spi_pci_desc *)ent->driver_data;int pci_bar =0 ;
@@ -58,14 +52,10 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret)return ret; - dwpci =devm_kzalloc (&pdev->dev,sizeof (struct dw_spi_pci ), -GFP_KERNEL ); -if (!dwpci) + dws =devm_kzalloc (&pdev->dev,sizeof (*dws),GFP_KERNEL ); +if (!dws)return -ENOMEM ; - dwpci->pdev = pdev; - dws = &dwpci->dws; -/* Get basic io resource and map it */ dws->paddr =pci_resource_start (pdev, pci_bar);
@@ -74,7 +64,6 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return ret; dws->regs =pcim_iomap_table (pdev)[pci_bar]; - dws->irq = pdev->irq;/*
@@ -99,7 +88,7 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return ret;/* PCI hook and SPI hook use the same drv data */ -pci_set_drvdata (pdev, dwpci); +pci_set_drvdata (pdev, dws);dev_info (&pdev->dev,"found PCI SPI controller(ID: %04x:%04x)\n" , pdev->vendor, pdev->device);
@@ -122,26 +111,26 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)static void spi_pci_remove (struct pci_dev *pdev) { -struct dw_spi_pci *dwpci =pci_get_drvdata (pdev); +struct dw_spi *dws =pci_get_drvdata (pdev); -dw_spi_remove_host (&dwpci->dws); +dw_spi_remove_host (dws); }#ifdef CONFIG_PM_SLEEP static int spi_suspend (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev); -struct dw_spi_pci *dwpci =pci_get_drvdata (pdev); +struct dw_spi *dws =pci_get_drvdata (pdev); -return dw_spi_suspend_host (&dwpci->dws); +return dw_spi_suspend_host (dws); }static int spi_resume (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev); -struct dw_spi_pci *dwpci =pci_get_drvdata (pdev); +struct dw_spi *dws =pci_get_drvdata (pdev); -return dw_spi_resume_host (&dwpci->dws); +return dw_spi_resume_host (dws); }#endif
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/10 spi: dw-mmio: convert to unified device property API
In reply to a message not in the archiveConvert the driver to use unfied device property API instead of OF one.
--- drivers/spi/spi-dw-mmio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-mmio.c +3 -4
@@ -19,6 +19,7 @@#include <linux/of.h> #include <linux/of_gpio.h> #include <linux/of_platform.h> +#include <linux/property.h> #include "spi-dw.h"
@@ -74,13 +75,11 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->max_freq =clk_get_rate (dwsmmio->clk); -of_property_read_u32 (pdev->dev.of_node,"reg-io-width" , - &dws->reg_io_width); +device_property_read_u32 (&pdev->dev,"reg-io-width" , &dws->reg_io_width); num_cs =4 ; -if (pdev->dev.of_node) -of_property_read_u32 (pdev->dev.of_node,"num-cs" , &num_cs); +device_property_read_u32 (&pdev->dev,"num-cs" , &num_cs); dws->num_cs = num_cs;
Signature · 6 lines
2.5.3 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v1 01/10] spi: dw: explicitly free IRQ handler in dw_spi_remove_host()
In reply to a message not in the archiveQuoted 3 lines · Andy Shevchenko
The following warning occurs when DW SPI is compiled as module and it's a PCI device. On removal stage
pcibios_free_irq()called earlier thanfree_irq()due to the latter is called at managed resources free strage.
Seems better to just convert to request_irq()?
Re: [PATCH v1 04/10] spi: dw: remove a NULL check when call ->remove()
In reply to a message not in the archiveQuoted 2 lines · Andy Shevchenko
Currently all users aware about calling
dw_spi_remove_host()with properly set parameter. Remove unneeded check.
This looks good but depends on patch 1.
Applied "spi: dw-mmio: convert to unified device property API" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw-mmio: convert to unified device property API
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
9899995e98a4bc670a07e28ff91e3d0dbe08bea9Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:25 +0300
Subject: [PATCH] spi: dw-mmio: convert to unified device property API
Convert the driver to use unfied device property API instead of OF one.
--- drivers/spi/spi-dw-mmio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/spi/spi-dw-mmio.c +3 -4
@@ -19,6 +19,7 @@#include <linux/of.h> #include <linux/of_gpio.h> #include <linux/of_platform.h> +#include <linux/property.h> #include "spi-dw.h"
@@ -74,13 +75,11 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->max_freq =clk_get_rate (dwsmmio->clk); -of_property_read_u32 (pdev->dev.of_node,"reg-io-width" , - &dws->reg_io_width); +device_property_read_u32 (&pdev->dev,"reg-io-width" , &dws->reg_io_width); num_cs =4 ; -if (pdev->dev.of_node) -of_property_read_u32 (pdev->dev.of_node,"num-cs" , &num_cs); +device_property_read_u32 (&pdev->dev,"num-cs" , &num_cs); dws->num_cs = num_cs;
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw-pci: remove unused pdev member from struct dw_spi_pci" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw-pci: remove unused pdev member from struct dw_spi_pci
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
1c2df965387f9a5a657a644bab5a1b5b535365b2Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:24 +0300
Subject: [PATCH] spi: dw-pci: remove unused pdev member from struct dw_spi_pci
The pdev member is not used anywhere, thus remove it. Moreover struct dw_spi_pci becomes an equivalent of struct dw_spi and therefore remove entire struct dw_spi_pci.
--- drivers/spi/spi-dw-pci.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/spi/spi-dw-pci.c +9 -20
@@ -23,11 +23,6 @@#define DRIVER_NAME "dw_spi_pci" -struct dw_spi_pci { -struct pci_dev *pdev; -struct dw_spi dws; -}; -struct spi_pci_desc {int (*setup)(struct dw_spi *);u16 num_cs;
@@ -48,7 +43,6 @@ static struct spi_pci_desc spi_pci_mid_desc_2 = {static int spi_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { -struct dw_spi_pci *dwpci;struct dw_spi *dws;struct spi_pci_desc *desc = (struct spi_pci_desc *)ent->driver_data;int pci_bar =0 ;
@@ -58,14 +52,10 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret)return ret; - dwpci =devm_kzalloc (&pdev->dev,sizeof (struct dw_spi_pci ), -GFP_KERNEL ); -if (!dwpci) + dws =devm_kzalloc (&pdev->dev,sizeof (*dws),GFP_KERNEL ); +if (!dws)return -ENOMEM ; - dwpci->pdev = pdev; - dws = &dwpci->dws; -/* Get basic io resource and map it */ dws->paddr =pci_resource_start (pdev, pci_bar);
@@ -74,7 +64,6 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return ret; dws->regs =pcim_iomap_table (pdev)[pci_bar]; - dws->irq = pdev->irq;/*
@@ -99,7 +88,7 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return ret;/* PCI hook and SPI hook use the same drv data */ -pci_set_drvdata (pdev, dwpci); +pci_set_drvdata (pdev, dws);dev_info (&pdev->dev,"found PCI SPI controller(ID: %04x:%04x)\n" , pdev->vendor, pdev->device);
@@ -109,26 +98,26 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)static void spi_pci_remove (struct pci_dev *pdev) { -struct dw_spi_pci *dwpci =pci_get_drvdata (pdev); +struct dw_spi *dws =pci_get_drvdata (pdev); -dw_spi_remove_host (&dwpci->dws); +dw_spi_remove_host (dws); }#ifdef CONFIG_PM_SLEEP static int spi_suspend (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev); -struct dw_spi_pci *dwpci =pci_get_drvdata (pdev); +struct dw_spi *dws =pci_get_drvdata (pdev); -return dw_spi_suspend_host (&dwpci->dws); +return dw_spi_suspend_host (dws); }static int spi_resume (struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev); -struct dw_spi_pci *dwpci =pci_get_drvdata (pdev); +struct dw_spi *dws =pci_get_drvdata (pdev); -return dw_spi_resume_host (&dwpci->dws); +return dw_spi_resume_host (dws); }#endif
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw: eliminate unused threshold variables" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw: eliminate unused threshold variables
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
d53c0ef319eb5ceb5a089ff3050a2e6808c9adb9Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:22 +0300
Subject: [PATCH] spi: dw: eliminate unused threshold variables
The tx_threshold and rx_threshold variables are not used anywhere. Remove them.
--- drivers/spi/spi-dw.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/spi/spi-dw.c +0 -5
@@ -36,8 +36,6 @@ struct chip_data {u8 poll_mode;/* 1 means use poll mode */ -u32 rx_threshold; -u32 tx_threshold;u8 enable_dma;u16 clk_div;/* baud rate divider */ u32 speed_hz;/* baud rate */
@@ -425,9 +423,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->poll_mode = chip_info->poll_mode; chip->type = chip_info->type; - - chip->rx_threshold =0 ; - chip->tx_threshold =0 ; } chip->tmode =0 ;/* Tx & Rx */
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw: introduce spi_shutdown_chip()" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw: introduce spi_shutdown_chip()
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
1cc3f141f0cb5a822cdef30fb1d92ae6f4176bfaMon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:23 +0300
Subject: [PATCH] spi: dw: introduce spi_shutdown_chip()
This helper disables SPI controller and sets clock to 0.
--- drivers/spi/spi-dw.c | 13 ++++++------- drivers/spi/spi-dw.h | 6 ++++++ 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/spi/spi-dw.c +6 -7
@@ -546,22 +546,21 @@ void dw_spi_remove_host(struct dw_spi *dws)if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit (dws); -spi_enable_chip (dws,0 ); -/* Disable clk */ -spi_set_clk (dws,0 ); + +spi_shutdown_chip (dws); }EXPORT_SYMBOL_GPL (dw_spi_remove_host);int dw_spi_suspend_host (struct dw_spi *dws) { -int ret =0 ; +int ret; ret =spi_master_suspend (dws->master);if (ret)return ret; -spi_enable_chip (dws,0 ); -spi_set_clk (dws,0 ); -return ret; + +spi_shutdown_chip (dws); +return 0 ; }EXPORT_SYMBOL_GPL (dw_spi_suspend_host);
drivers/spi/spi-dw.h +6 -0
@@ -225,6 +225,12 @@ static inline void spi_reset_chip(struct dw_spi *dws)spi_enable_chip (dws,1 ); } +static inline void spi_shutdown_chip (struct dw_spi *dws) +{ +spi_enable_chip (dws,0 ); +spi_set_clk (dws,0 ); +} +/* * Each SPI slave device to work with dw_api controller should * has such a structure claiming its working mode (poll or PIO/DMA),
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw: eliminate speed variable in ->transfer_one()" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw: eliminate speed variable in ->transfer_one()
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
de6feda884b0079f5f232a41d94da23d198ff230Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:21 +0300
Subject: [PATCH] spi: dw: eliminate speed variable in ->transfer_one()
There is no point to have a separate variable for speed in ->transfer_one().
While here, remove !chip->clk_div from a condition since it is assigned simultaneously with chip->speed_hz. We can do this safely because
a) transfer speed can't be higher than max_freq and therefore chip->clk_div
can be 0 only when chip->speed_hz is 0, and
b) transfer speed can't be 0, otherwise we will get division by zero exception.
--- drivers/spi/spi-dw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/spi/spi-dw.c +4 -8
@@ -285,8 +285,7 @@ static int dw_spi_transfer_one(struct spi_master *master,struct chip_data *chip =spi_get_ctldata (spi);u8 imask =0 ;u16 txlevel =0 ; -u16 clk_div =0 ; -u32 speed =0 ; +u16 clk_div;u32 cr0;int ret;
@@ -301,14 +300,11 @@ static int dw_spi_transfer_one(struct spi_master *master,spi_enable_chip (dws,0 );/* Handle per transfer options for bpw and speed */ - speed = chip->speed_hz; -if ((transfer->speed_hz != speed) || !chip->clk_div) { - speed = transfer->speed_hz; - +if (transfer->speed_hz != chip->speed_hz) {/* clk_div doesn't support odd number */ - clk_div = (dws->max_freq / speed +1 ) &0xfffe ; + clk_div = (dws->max_freq / transfer->speed_hz +1 ) &0xfffe ; - chip->speed_hz = speed; + chip->speed_hz = transfer->speed_hz; chip->clk_div = clk_div;spi_set_clk (dws, chip->clk_div);
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw: remove bits_per_word member of struct chip_data" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw: remove bits_per_word member of struct chip_data
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
863cb2f72e636c8721482fd88e256facb59c5737Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:20 +0300
Subject: [PATCH] spi: dw: remove bits_per_word member of struct chip_data
There is no need to carry over spi->bits_per_word and Co from ->setup() in struct chip_data since ->transfer_one() will anyway take the transfer parameters from struct spi_transfer. This is since SPI core validates both bits_per_word transfer parameter and defaults to spi->bits_per_word in case that per transfer parameter is not set.
--- drivers/spi/spi-dw.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/spi/spi-dw.c +2 -14
@@ -31,17 +31,14 @@/* Slave spi_dev related */ struct chip_data {u8 cs;/* chip select pin */ -u8 n_bytes;/* current is a 1/2/4 byte op */ u8 tmode;/* TR/TO/RO/EEPROM */ u8 type;/* SPI/SSP/MicroWire */ u8 poll_mode;/* 1 means use poll mode */ -u32 dma_width;u32 rx_threshold;u32 tx_threshold;u8 enable_dma; -u8 bits_per_word;u16 clk_div;/* baud rate divider */ u32 speed_hz;/* baud rate */ void (*cs_control)(u32 command);
@@ -294,8 +291,6 @@ static int dw_spi_transfer_one(struct spi_master *master,int ret; dws->dma_mapped =0 ; - dws->n_bytes = chip->n_bytes; - dws->dma_width = chip->dma_width; dws->tx = (void *)transfer->tx_buf; dws->tx_end = dws->tx + transfer->len;
@@ -324,6 +319,8 @@ static int dw_spi_transfer_one(struct spi_master *master, }else if (transfer->bits_per_word ==16 ) { dws->n_bytes =2 ; dws->dma_width =2 ; + }else { +return -EINVAL ; }/* Default SPI mode is SCPOL = 0, SCPH = 0 */ cr0 = (transfer->bits_per_word -1 )
@@ -437,15 +434,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->tx_threshold =0 ; } -if (spi->bits_per_word ==8 ) { - chip->n_bytes =1 ; - chip->dma_width =1 ; - }else if (spi->bits_per_word ==16 ) { - chip->n_bytes =2 ; - chip->dma_width =2 ; - } - chip->bits_per_word = spi->bits_per_word; - chip->tmode =0 ;/* Tx & Rx */ if (gpio_is_valid (spi->cs_gpio)) {
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw: remove unneeded cr0 member of struct chip_data" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw: remove unneeded cr0 member of struct chip_data
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
4adb1f8f880081ee9921ebd399786387e0cd6f52Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:18 +0300
Subject: [PATCH] spi: dw: remove unneeded cr0 member of struct chip_data
Since we recalculate cr0 each time we start a transfer the chip_data->cr0 becomes redundant. Remove it and related pieces.
This is a follow up to commit 0ed36990a93b (spi: dw: Remove needless if statements).
--- drivers/spi/spi-dw.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/spi/spi-dw.c +2 -12
@@ -30,7 +30,6 @@/* Slave spi_dev related */ struct chip_data { -u16 cr0;u8 cs;/* chip select pin */ u8 n_bytes;/* current is a 1/2/4 byte op */ u8 tmode;/* TR/TO/RO/EEPROM */
@@ -291,7 +290,7 @@ static int dw_spi_transfer_one(struct spi_master *master,u16 txlevel =0 ;u16 clk_div =0 ;u32 speed =0 ; -u32 cr0 =0 ; +u32 cr0;int ret; dws->dma_mapped =0 ;
@@ -306,8 +305,6 @@ static int dw_spi_transfer_one(struct spi_master *master,spi_enable_chip (dws,0 ); - cr0 = chip->cr0; -/* Handle per transfer options for bpw and speed */ speed = chip->speed_hz;if ((transfer->speed_hz != speed) || !chip->clk_div) {
@@ -328,6 +325,7 @@ static int dw_spi_transfer_one(struct spi_master *master, dws->n_bytes =2 ; dws->dma_width =2 ; } +/* Default SPI mode is SCPOL = 0, SCPH = 0 */ cr0 = (transfer->bits_per_word -1 ) | (chip->type <<SPI_FRF_OFFSET ) | (spi->mode <<SPI_MODE_OFFSET )
@@ -449,14 +447,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->bits_per_word = spi->bits_per_word; chip->tmode =0 ;/* Tx & Rx */ -/* Default SPI mode is SCPOL = 0, SCPH = 0 */ - chip->cr0 = (chip->bits_per_word -1 ) - | (chip->type <<SPI_FRF_OFFSET ) - | (spi->mode <<SPI_MODE_OFFSET ) - | (chip->tmode <<SPI_TMOD_OFFSET ); - -if (spi->mode &SPI_LOOP ) - chip->cr0 |=1 <<SPI_SRL_OFFSET ;if (gpio_is_valid (spi->cs_gpio)) { ret = gpio_direction_output(spi->cs_gpio,
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "spi: dw: use plain struct device * at earlier ->probe()" to the spi tree
In reply to a message not in the archiveThe patch
spi: dw: use plain struct device * at earlier ->probe()
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
5f0966e61f0a65bef26b9fedbc1a4ab22a6f918bMon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Date: Wed, 14 Oct 2015 23:12:17 +0300
Subject: [PATCH] spi: dw: use plain struct device * at earlier ->probe()
The name of the master device is set during registrationg which happens after we issue the error message. Change it to plain struct device * to see which device registration failed.
--- drivers/spi/spi-dw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-dw.c +1 -1
@@ -520,7 +520,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) ret =devm_request_irq (dev, dws->irq, dw_spi_irq,IRQF_SHARED , dws->name, master);if (ret <0 ) { -dev_err (&master->dev,"can not get IRQ\n" ); +dev_err (dev,"can not get IRQ\n" ); goto err_free_master; }
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html