All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] spi: dw-pci: cleanup the driver
@ 2014-08-29  9:41 Andy Shevchenko
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29  9:41 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Andy Shevchenko

This set of small clean ups of the driver.

Changelog v3:
- rebase on top of recent linux-next keeping in mind NAck of "spi: dw-mid:
  don't leak memory on exit"

Changelog v2:
- add patch 4/5

Andy Shevchenko (5):
  spi: dw-pci: move info message at the end of probe
  spi: dw-pci: apply pci_bar and re-use pci_name
  spi: dw-pci: convert to use dev_pm_ops
  spi: dw-pci: provide platform specific data via driver_data
  spi: dw-pci: remove FSF address and update copyright

 drivers/spi/spi-dw-pci.c | 67 ++++++++++++++++++++++--------------------------
 1 file changed, 30 insertions(+), 37 deletions(-)

-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/5] spi: dw-pci: move info message at the end of probe
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2014-08-29  9:41   ` Andy Shevchenko
  2014-08-29  9:41   ` [PATCH v3 2/5] spi: dw-pci: apply pci_bar and re-use pci_name Andy Shevchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29  9:41 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Andy Shevchenko

Let's print info message when controller is found and properly initialized.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/spi/spi-dw-pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index e149604..6123e37 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -40,9 +40,6 @@ static int spi_pci_probe(struct pci_dev *pdev,
 	int pci_bar = 0;
 	int ret;
 
-	dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n",
-		pdev->vendor, pdev->device);
-
 	ret = pcim_enable_device(pdev);
 	if (ret)
 		return ret;
@@ -85,6 +82,9 @@ static int spi_pci_probe(struct pci_dev *pdev,
 	/* PCI hook and SPI hook use the same drv data */
 	pci_set_drvdata(pdev, dwpci);
 
+	dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n",
+		pdev->vendor, pdev->device);
+
 	return 0;
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/5] spi: dw-pci: apply pci_bar and re-use pci_name
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2014-08-29  9:41   ` [PATCH v3 1/5] spi: dw-pci: move info message at the end of probe Andy Shevchenko
@ 2014-08-29  9:41   ` Andy Shevchenko
  2014-08-29  9:41   ` [PATCH v3 3/5] spi: dw-pci: convert to use dev_pm_ops Andy Shevchenko
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29  9:41 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Andy Shevchenko

Nevertheless pci_bar is 0 let's explicitly use it when map IO regions. While
here, use pci_name instead of dev_name.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/spi/spi-dw-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index 6123e37..473bd52 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -55,7 +55,7 @@ static int spi_pci_probe(struct pci_dev *pdev,
 	/* Get basic io resource and map it */
 	dws->paddr = pci_resource_start(pdev, pci_bar);
 
-	ret = pcim_iomap_regions(pdev, 1, dev_name(&pdev->dev));
+	ret = pcim_iomap_regions(pdev, 1 << pci_bar, pci_name(pdev));
 	if (ret)
 		return ret;
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/5] spi: dw-pci: convert to use dev_pm_ops
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2014-08-29  9:41   ` [PATCH v3 1/5] spi: dw-pci: move info message at the end of probe Andy Shevchenko
  2014-08-29  9:41   ` [PATCH v3 2/5] spi: dw-pci: apply pci_bar and re-use pci_name Andy Shevchenko
@ 2014-08-29  9:41   ` Andy Shevchenko
  2014-08-29  9:41   ` [PATCH v3 4/5] spi: dw-pci: provide platform specific data via driver_data Andy Shevchenko
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29  9:41 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Andy Shevchenko

Convert system PM callbacks to use dev_pm_ops. In addition remove the PCI calls
related to a power state since the bus code cares about this already.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/spi/spi-dw-pci.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index 473bd52..3774261 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -95,38 +95,26 @@ static void spi_pci_remove(struct pci_dev *pdev)
 	dw_spi_remove_host(&dwpci->dws);
 }
 
-#ifdef CONFIG_PM
-static int spi_suspend(struct pci_dev *pdev, pm_message_t state)
+#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);
-	int ret;
 
-	ret = dw_spi_suspend_host(&dwpci->dws);
-	if (ret)
-		return ret;
-	pci_save_state(pdev);
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
-	return ret;
+	return dw_spi_suspend_host(&dwpci->dws);
 }
 
-static int spi_resume(struct pci_dev *pdev)
+static int spi_resume(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
-	int ret;
 
-	pci_set_power_state(pdev, PCI_D0);
-	pci_restore_state(pdev);
-	ret = pci_enable_device(pdev);
-	if (ret)
-		return ret;
 	return dw_spi_resume_host(&dwpci->dws);
 }
-#else
-#define spi_suspend	NULL
-#define spi_resume	NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(dw_spi_pm_ops, spi_suspend, spi_resume);
+
 static const struct pci_device_id pci_ids[] = {
 	/* Intel MID platform SPI controller 0 */
 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
@@ -138,8 +126,9 @@ static struct pci_driver dw_spi_driver = {
 	.id_table =	pci_ids,
 	.probe =	spi_pci_probe,
 	.remove =	spi_pci_remove,
-	.suspend =	spi_suspend,
-	.resume	=	spi_resume,
+	.driver         = {
+		.pm     = &dw_spi_pm_ops,
+	},
 };
 
 module_pci_driver(dw_spi_driver);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/5] spi: dw-pci: provide platform specific data via driver_data
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2014-08-29  9:41   ` [PATCH v3 3/5] spi: dw-pci: convert to use dev_pm_ops Andy Shevchenko
@ 2014-08-29  9:41   ` Andy Shevchenko
  2014-08-29  9:41   ` [PATCH v3 5/5] spi: dw-pci: remove FSF address and update copyright Andy Shevchenko
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29  9:41 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Andy Shevchenko

Instead of checking for device and vendor IDs inside probe function let's
provide a helper function via driver_data.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/spi/spi-dw-pci.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index 3774261..3c2b0d9 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -32,11 +32,19 @@ struct dw_spi_pci {
 	struct dw_spi	dws;
 };
 
-static int spi_pci_probe(struct pci_dev *pdev,
-	const struct pci_device_id *ent)
+struct spi_pci_desc {
+	int	(*setup)(struct dw_spi *);
+};
+
+static struct spi_pci_desc spi_pci_mid_desc = {
+	.setup = dw_spi_mid_init,
+};
+
+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;
 	int ret;
 
@@ -66,11 +74,11 @@ static int spi_pci_probe(struct pci_dev *pdev,
 	dws->irq = pdev->irq;
 
 	/*
-	 * Specific handling for Intel MID paltforms, like dma setup,
+	 * Specific handling for paltforms, like dma setup,
 	 * clock rate, FIFO depth.
 	 */
-	if (pdev->device == 0x0800) {
-		ret = dw_spi_mid_init(dws);
+	if (desc && desc->setup) {
+		ret = desc->setup(dws);
 		if (ret)
 			return ret;
 	}
@@ -117,7 +125,7 @@ static SIMPLE_DEV_PM_OPS(dw_spi_pm_ops, spi_suspend, spi_resume);
 
 static const struct pci_device_id pci_ids[] = {
 	/* Intel MID platform SPI controller 0 */
-	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
+	{ PCI_VDEVICE(INTEL, 0x0800), (kernel_ulong_t)&spi_pci_mid_desc},
 	{},
 };
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 5/5] spi: dw-pci: remove FSF address and update copyright
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2014-08-29  9:41   ` [PATCH v3 4/5] spi: dw-pci: provide platform specific data via driver_data Andy Shevchenko
@ 2014-08-29  9:41   ` Andy Shevchenko
  2014-08-29 10:56   ` [PATCH v3 0/5] spi: dw-pci: cleanup the driver Mark Brown
  2014-09-01 10:29   ` Mark Brown
  6 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29  9:41 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA; +Cc: Andy Shevchenko

The FSF address is subject to change, thus remove it from the file. While here,
update a copyright line.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/spi/spi-dw-pci.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
index 3c2b0d9..ba68da1 100644
--- a/drivers/spi/spi-dw-pci.c
+++ b/drivers/spi/spi-dw-pci.c
@@ -1,7 +1,7 @@
 /*
  * PCI interface driver for DW SPI Core
  *
- * 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/interrupt.h>
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 0/5] spi: dw-pci: cleanup the driver
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2014-08-29  9:41   ` [PATCH v3 5/5] spi: dw-pci: remove FSF address and update copyright Andy Shevchenko
@ 2014-08-29 10:56   ` Mark Brown
       [not found]     ` <20140829105635.GM29327-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  2014-09-01 10:29   ` Mark Brown
  6 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2014-08-29 10:56 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

On Fri, Aug 29, 2014 at 12:41:38PM +0300, Andy Shevchenko wrote:
> This set of small clean ups of the driver.
> 
> Changelog v3:
> - rebase on top of recent linux-next keeping in mind NAck of "spi: dw-mid:
>   don't leak memory on exit"

Who nacked it?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 0/5] spi: dw-pci: cleanup the driver
       [not found]     ` <20140829105635.GM29327-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2014-08-29 11:14       ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-08-29 11:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

On Fri, 2014-08-29 at 11:56 +0100, Mark Brown wrote:
> On Fri, Aug 29, 2014 at 12:41:38PM +0300, Andy Shevchenko wrote:
> > This set of small clean ups of the driver.
> > 
> > Changelog v3:
> > - rebase on top of recent linux-next keeping in mind NAck of "spi: dw-mid:
> >   don't leak memory on exit"
> 
> Who nacked it?

Me for now. I would like to send it as a part of improving spi-dw-mid.c.

-- 
Andy Shevchenko <andriy.shevchenko-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 0/5] spi: dw-pci: cleanup the driver
       [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
                     ` (5 preceding siblings ...)
  2014-08-29 10:56   ` [PATCH v3 0/5] spi: dw-pci: cleanup the driver Mark Brown
@ 2014-09-01 10:29   ` Mark Brown
  6 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2014-09-01 10:29 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 131 bytes --]

On Fri, Aug 29, 2014 at 12:41:38PM +0300, Andy Shevchenko wrote:
> This set of small clean ups of the driver.

Applid all, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-09-01 10:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-29  9:41 [PATCH v3 0/5] spi: dw-pci: cleanup the driver Andy Shevchenko
     [not found] ` <1409305303-32631-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-08-29  9:41   ` [PATCH v3 1/5] spi: dw-pci: move info message at the end of probe Andy Shevchenko
2014-08-29  9:41   ` [PATCH v3 2/5] spi: dw-pci: apply pci_bar and re-use pci_name Andy Shevchenko
2014-08-29  9:41   ` [PATCH v3 3/5] spi: dw-pci: convert to use dev_pm_ops Andy Shevchenko
2014-08-29  9:41   ` [PATCH v3 4/5] spi: dw-pci: provide platform specific data via driver_data Andy Shevchenko
2014-08-29  9:41   ` [PATCH v3 5/5] spi: dw-pci: remove FSF address and update copyright Andy Shevchenko
2014-08-29 10:56   ` [PATCH v3 0/5] spi: dw-pci: cleanup the driver Mark Brown
     [not found]     ` <20140829105635.GM29327-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-08-29 11:14       ` Andy Shevchenko
2014-09-01 10:29   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.