spi: dw: various clean ups and a bug fix
cover spi: dw: various clean ups and a bug fix
There is a set of few clean ups and one bug fix in the dw spi driver.
Andy Shevchenko (6):
spi: dw: don't use mrst prefix anymore
spi: dw: remove FSF address
spi: dw-mid: check that DMA was inited before exit
spi: dw-mid: remove Moorestown support
spi: dw-mid: remove redundant dmac member
spi: dw-mid: remove FSF address and update copyright
drivers/spi/Kconfig | 2 +- drivers/spi/spi-dw-mid.c | 26 +++++++++++++------------- drivers/spi/spi-dw.c | 36 +++++++++++++++--------------------- drivers/spi/spi-dw.h | 7 +++---- 4 files changed, 32 insertions(+), 39 deletions(-)
Signature · 6 lines
2.1.0 -- 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
A message that is not in the archive (sent off-list or not yet received): 1410523921-16732-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]
PATCH 1/6 spi: dw: don't use mrst prefix anymore
Since driver is used on other platforms and debugfs stuff would be useful there as well let's substitute mrst_ by dw_ where it suits. Additionally let's use SPI master device name when print registers dump.
--- drivers/spi/spi-dw.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
drivers/spi/spi-dw.c +15 -17
@@ -59,22 +59,20 @@ struct chip_data {#ifdef CONFIG_DEBUG_FS #define SPI_REGS_BUFSIZE 1024 -static ssize_t spi_show_regs (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t dw_spi_show_regs (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) { -struct dw_spi *dws; +struct dw_spi *dws = file->private_data;char *buf;u32 len =0 ;ssize_t ret; - dws = file->private_data; - buf =kzalloc (SPI_REGS_BUFSIZE ,GFP_KERNEL );if (!buf)return 0 ; len +=snprintf (buf + len,SPI_REGS_BUFSIZE - len, -"MRST SPI0 registers:\n" ); +"%s registers:\n" ,dev_name (&dws->master->dev)); len +=snprintf (buf + len,SPI_REGS_BUFSIZE - len,"=================================\n" ); len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
@@ -110,41 +108,41 @@ static ssize_t spi_show_regs(struct file *file, char __user *user_buf, len +=snprintf (buf + len,SPI_REGS_BUFSIZE - len,"=================================\n" ); - ret =simple_read_from_buffer (user_buf, count, ppos, buf, len); + ret =simple_read_from_buffer (user_buf, count, ppos, buf, len);kfree (buf);return ret; } -static const struct file_operations mrst_spi_regs_ops = { +static const struct file_operations dw_spi_regs_ops = { .owner =THIS_MODULE , .open = simple_open, - .read = spi_show_regs, + .read = dw_spi_show_regs, .llseek = default_llseek, }; -static int mrst_spi_debugfs_init (struct dw_spi *dws) +static int dw_spi_debugfs_init (struct dw_spi *dws) { - dws->debugfs =debugfs_create_dir ("mrst_spi" ,NULL ); + dws->debugfs =debugfs_create_dir ("dw_spi" ,NULL );if (!dws->debugfs)return -ENOMEM ;debugfs_create_file ("registers" ,S_IFREG |S_IRUGO , - dws->debugfs, (void *)dws, &mrst_spi_regs_ops); + dws->debugfs, (void *)dws, &dw_spi_regs_ops);return 0 ; } -static void mrst_spi_debugfs_remove (struct dw_spi *dws) +static void dw_spi_debugfs_remove (struct dw_spi *dws) {debugfs_remove_recursive (dws->debugfs); }#else -static inline int mrst_spi_debugfs_init (struct dw_spi *dws) +static inline int dw_spi_debugfs_init (struct dw_spi *dws) {return 0 ; } -static inline void mrst_spi_debugfs_remove (struct dw_spi *dws) +static inline void dw_spi_debugfs_remove (struct dw_spi *dws) { }#endif /* CONFIG_DEBUG_FS */
@@ -694,7 +692,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) goto err_dma_exit; } -mrst_spi_debugfs_init (dws); +dw_spi_debugfs_init (dws);return 0 ; err_dma_exit:
@@ -711,7 +709,7 @@ void dw_spi_remove_host(struct dw_spi *dws) {if (!dws)return ; -mrst_spi_debugfs_remove (dws); +dw_spi_debugfs_remove (dws);if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit (dws);
Signature · 6 lines
2.1.0 -- 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
A message that is not in the archive (sent off-list or not yet received): 1410523921-16732-2-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]
Re: [PATCH v1 1/6] spi: dw: don't use mrst prefix anymore
Quoted 3 lines · Andy Shevchenko
Since driver is used on other platforms and debugfs stuff would be useful there as well let's substitute
mrst_bydw_where it suits. Additionally let's use SPI master device name when print registers dump.
Could the driver use regmap and get the register dump functionality for free?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v1 1/6] spi: dw: don't use mrst prefix anymore
Quoted 7 lines · Mark Brown
Quoted 3 lines · Andy Shevchenko
Since driver is used on other platforms and debugfs stuff would be useful there as well let's substitute
mrst_bydw_where it suits. Additionally let's use SPI master device name when print registers dump.Could the driver use regmap and get the register dump functionality for free?
I didn't check that, probably yes, but this is not my intention right now.
Signature · 7 lines
Andy Shevchenko <[email protected]> Intel Finland Oy -- 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/6 spi: dw: remove FSF address
In reply to a message not in the archiveThere is no need to keep FSF address in the head of the file. While here, fix few typos in the header.
There is no functional change.
--- drivers/spi/spi-dw.c | 4 ---- drivers/spi/spi-dw.h | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/spi/spi-dw.c +0 -4
@@ -11,10 +11,6 @@* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ #include <linux/dma-mapping.h>
drivers/spi/spi-dw.h +3 -3
@@ -217,11 +217,11 @@ static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)* Each SPI slave device to work with dw_api controller should * has such a structure claiming its working mode (PIO/DMA etc), * which can be save in the "controller_data" member of the -* struct spi_device +* struct spi_device. */ struct dw_spi_chip { -u8 poll_mode;/* 0 for contoller polling mode */ -u8 type;/* SPI/SSP/Micrwire */ +u8 poll_mode;/* 1 for controller polling mode */ +u8 type;/* SPI/SSP/MicroWire */ u8 enable_dma;void (*cs_control)(u32 command); };
Signature · 6 lines
2.1.0 -- 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/6 spi: dw-mid: check that DMA was inited before exit
In reply to a message not in the archiveIf the driver was compiled with DMA support, but DMA channels weren't acquired by some reason, mid_spi_dma_exit() will crash the kernel.
--- drivers/spi/spi-dw-mid.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-dw-mid.c +2 -0
@@ -89,6 +89,8 @@ err_exit:static void mid_spi_dma_exit (struct dw_spi *dws) { +if (!dws->dma_inited) +return ;dma_release_channel (dws->txchan);dma_release_channel (dws->rxchan); }
Signature · 6 lines
2.1.0 -- 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/6 spi: dw-mid: remove Moorestown support
In reply to a message not in the archiveThe support of the Moorestown was removed [1] from kernel long time ago. This is just a follow up of that change.
[1] http://www.spinics.net/lists/platform-driver-x86/msg02948.html
--- drivers/spi/Kconfig | 2 +- drivers/spi/spi-dw-mid.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/spi/Kconfig +1 -1
@@ -600,7 +600,7 @@ config SPI_DW_PCI depends on SPI_DESIGNWARE && PCI config SPI_DW_MID_DMA - bool "DMA support for DW SPI controller on Intel Moorestown platform" + bool "DMA support for DW SPI controller on Intel MID platform" depends on SPI_DW_PCI && INTEL_MID_DMAC config SPI_DW_MMIO
drivers/spi/spi-dw-mid.c +3 -5
@@ -50,11 +50,9 @@ static int mid_spi_dma_init(struct dw_spi *dws)/* * Get pci device for DMA controller, currently it could only -* be the DMA controller of either Moorestown or Medfield +* be the DMA controller of Medfield */ - dws->dmac =pci_get_device (PCI_VENDOR_ID_INTEL ,0x0813 ,NULL ); -if (!dws->dmac) - dws->dmac =pci_get_device (PCI_VENDOR_ID_INTEL ,0x0827 ,NULL ); + dws->dmac =pci_get_device (PCI_VENDOR_ID_INTEL ,0x0827 ,NULL );dma_cap_zero (mask);dma_cap_set (DMA_SLAVE , mask);
@@ -192,7 +190,7 @@ static struct dw_spi_dma_ops mid_dma_ops = { };#endif -/* Some specific info for SPI0 controller on Moorestown */ +/* Some specific info for SPI0 controller on Intel MID */ /* HW info for MRST CLk Control Unit, one 32b reg */ #define MRST_SPI_CLK_BASE 100000000/* 100m */
Signature · 6 lines
2.1.0 -- 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/6 spi: dw-mid: remove redundant dmac member
In reply to a message not in the archiveInstead of using that member we prefer to use dma_dev which represents actual struct device of the DMA device.
--- drivers/spi/spi-dw-mid.c | 12 ++++++++---- drivers/spi/spi-dw.h | 1 - 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/spi/spi-dw-mid.c +8 -4
@@ -39,12 +39,13 @@ static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param) {struct dw_spi *dws = param; -return dws->dmac && (&dws->dmac->dev == chan->device->dev); +return dws->dma_dev == chan->device->dev; }static int mid_spi_dma_init (struct dw_spi *dws) {struct mid_dma *dw_dma = dws->dma_priv; +struct pci_dev *dma_dev;struct intel_mid_dma_slave *rxs, *txs;dma_cap_mask_t mask;
@@ -52,7 +53,11 @@ static int mid_spi_dma_init(struct dw_spi *dws)* Get pci device for DMA controller, currently it could only * be the DMA controller of Medfield */ - dws->dmac =pci_get_device (PCI_VENDOR_ID_INTEL ,0x0827 ,NULL ); + dma_dev =pci_get_device (PCI_VENDOR_ID_INTEL ,0x0827 ,NULL ); +if (!dma_dev) +return -ENODEV ; + + dws->dma_dev = &dma_dev->dev;dma_cap_zero (mask);dma_cap_set (DMA_SLAVE , mask);
@@ -81,8 +86,7 @@ static int mid_spi_dma_init(struct dw_spi *dws) free_rxchan:dma_release_channel (dws->rxchan); err_exit: -return -1 ; - +return -EBUSY ; }static void mid_spi_dma_exit (struct dw_spi *dws)
drivers/spi/spi-dw.h +0 -1
@@ -140,7 +140,6 @@ struct dw_spi {dma_addr_t dma_addr;/* phy address of the Data register */ struct dw_spi_dma_ops *dma_ops;void *dma_priv;/* platform relate info */ -struct pci_dev *dmac;/* Bus interface info */ void *priv;
Signature · 6 lines
2.1.0 -- 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/6 spi: dw-mid: remove FSF address and update copyright
In reply to a message not in the archiveThe FSF address is subject to change, thus remove it from the file. While here, update a copyright line.
--- drivers/spi/spi-dw-mid.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/spi/spi-dw-mid.c +1 -5
@@ -1,7 +1,7 @@/* * Special handling for DW core on Intel MID platform * -* Copyright (c) 2009, Intel Corporation. +* Copyright (c) 2009, 2014 Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License,
@@ -11,10 +11,6 @@* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, write to the Free Software Foundation, -* Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. */ #include <linux/dma-mapping.h>
Signature · 6 lines
2.1.0 -- 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
Mark Brown
AppliedQuoted 1 line · Andy Shevchenko
There is a set of few clean ups and one bug fix in the dw spi driver.
Applied all, thanks.