linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 0/6] spi: omap2-mcspi: driver updates
@ 2012-03-30 10:20 Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-omap, linux-kernel, Shubhrajyoti D

The patch series does the following cleanups
- Converts the spi to module_platform_driver
- Use the devm functions so that the freeing need not 
  be done in the driver.
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from v1
- Makes the driver use autosuspend
- Folds Benoit's bus_num removal patch in the series

Changes from v2
- The tmp variable is used to write this can be optimised 
 as it is not needed if the value is directly written.
 Acknowledge  Tarun for the suggestion.

This is also available through
git     : git://gitorious.org/linus-tree/linus-tree.git
branch  : spi

This is targeted for v3.5. 

Benoit Cousson (1):
  spi/omap: Remove bus_num usage for instance index

Felipe Balbi (2):
  spi: omap2-mcspi: make it behave as a module
  spi: omap2-mcspi: convert to module_platform_driver

Shubhrajyoti D (3):
  spi: omap2-mcspi: use devm_* functions
  spi: omap2-mcspi: add support for pm_runtime autosuspend
  spi: omap2-mcspi: Trivial optimisation

 drivers/spi/spi-omap2-mcspi.c |  132 +++++++++++++++-------------------------
 1 files changed, 50 insertions(+), 82 deletions(-)


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

* [PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
@ 2012-03-30 10:20 ` Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 2/6] spi: omap2-mcspi: make it behave as a module Shubhrajyoti D
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general
  Cc: linux-omap, linux-kernel, Benoit Cousson, Shubhrajyoti D

From: Benoit Cousson <b-cousson@ti.com>

bus_num was used to reference the mcspi controller instance in a fixed array.
Remove this array and store this information directly inside drvdata structure.

bus_num is now just set if the pdev->id is present or with -1 for dynamic
allocation by SPI core, but the driver does not access it anymore.

Clean some bad comments format, and remove un-needed space.

Signed-off-by: Benoit Cousson <b-cousson@ti.com>
[Cleanup the OMAP2_MCSPI_MAX_CTRL macro as it is not needed anymore]
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |   75 ++++++++++++++++++----------------------
 1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bb9274c..7785091 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -45,9 +45,6 @@
 
 #define OMAP2_MCSPI_MAX_FREQ		48000000
 
-/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
-#define OMAP2_MCSPI_MAX_CTRL 		4
-
 #define OMAP2_MCSPI_REVISION		0x00
 #define OMAP2_MCSPI_SYSSTATUS		0x14
 #define OMAP2_MCSPI_IRQSTATUS		0x18
@@ -111,6 +108,16 @@ struct omap2_mcspi_dma {
 #define DMA_MIN_BYTES			160
 
 
+/*
+ * Used for context save and restore, structure members to be updated whenever
+ * corresponding registers are modified.
+ */
+struct omap2_mcspi_regs {
+	u32 modulctrl;
+	u32 wakeupenable;
+	struct list_head cs;
+};
+
 struct omap2_mcspi {
 	struct work_struct	work;
 	/* lock protects queue and registers */
@@ -122,8 +129,9 @@ struct omap2_mcspi {
 	unsigned long		phys;
 	/* SPI1 has 4 channels, while SPI2 has 2 */
 	struct omap2_mcspi_dma	*dma_channels;
-	struct  device		*dev;
+	struct device		*dev;
 	struct workqueue_struct *wq;
+	struct omap2_mcspi_regs ctx;
 };
 
 struct omap2_mcspi_cs {
@@ -135,17 +143,6 @@ struct omap2_mcspi_cs {
 	u32			chconf0;
 };
 
-/* used for context save and restore, structure members to be updated whenever
- * corresponding registers are modified.
- */
-struct omap2_mcspi_regs {
-	u32 modulctrl;
-	u32 wakeupenable;
-	struct list_head cs;
-};
-
-static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL];
-
 #define MOD_REG_BIT(val, mask, set) do { \
 	if (set) \
 		val |= mask; \
@@ -236,9 +233,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active)
 
 static void omap2_mcspi_set_master_mode(struct spi_master *master)
 {
+	struct omap2_mcspi	*mcspi = spi_master_get_devdata(master);
+	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
 	u32 l;
 
-	/* setup when switching from (reset default) slave mode
+	/*
+	 * Setup when switching from (reset default) slave mode
 	 * to single-channel master mode
 	 */
 	l = mcspi_read_reg(master, OMAP2_MCSPI_MODULCTRL);
@@ -247,24 +247,20 @@ static void omap2_mcspi_set_master_mode(struct spi_master *master)
 	MOD_REG_BIT(l, OMAP2_MCSPI_MODULCTRL_SINGLE, 1);
 	mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, l);
 
-	omap2_mcspi_ctx[master->bus_num - 1].modulctrl = l;
+	ctx->modulctrl = l;
 }
 
 static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
 {
-	struct spi_master *spi_cntrl;
-	struct omap2_mcspi_cs *cs;
-	spi_cntrl = mcspi->master;
+	struct spi_master	*spi_cntrl = mcspi->master;
+	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
+	struct omap2_mcspi_cs	*cs;
 
 	/* McSPI: context restore */
-	mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL,
-			omap2_mcspi_ctx[spi_cntrl->bus_num - 1].modulctrl);
+	mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_MODULCTRL, ctx->modulctrl);
+	mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
 
-	mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
-			omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
-
-	list_for_each_entry(cs, &omap2_mcspi_ctx[spi_cntrl->bus_num - 1].cs,
-			node)
+	list_for_each_entry(cs, &ctx->cs, node)
 		__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
@@ -777,7 +773,8 @@ static int omap2_mcspi_request_dma(struct spi_device *spi)
 static int omap2_mcspi_setup(struct spi_device *spi)
 {
 	int			ret;
-	struct omap2_mcspi	*mcspi;
+	struct omap2_mcspi	*mcspi = spi_master_get_devdata(spi->master);
+	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
 	struct omap2_mcspi_dma	*mcspi_dma;
 	struct omap2_mcspi_cs	*cs = spi->controller_state;
 
@@ -787,7 +784,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	mcspi = spi_master_get_devdata(spi->master);
 	mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
 	if (!cs) {
@@ -799,8 +795,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
 		cs->chconf0 = 0;
 		spi->controller_state = cs;
 		/* Link this to context save list */
-		list_add_tail(&cs->node,
-			&omap2_mcspi_ctx[mcspi->master->bus_num - 1].cs);
+		list_add_tail(&cs->node, &ctx->cs);
 	}
 
 	if (mcspi_dma->dma_rx_channel == -1
@@ -1053,8 +1048,9 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m)
 static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
 {
 	struct spi_master	*master = mcspi->master;
+	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
 	u32			tmp;
-	int ret = 0;
+	int			ret = 0;
 
 	ret = omap2_mcspi_enable_clocks(mcspi);
 	if (ret < 0)
@@ -1062,7 +1058,7 @@ static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
 
 	tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
 	mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp);
-	omap2_mcspi_ctx[master->bus_num - 1].wakeupenable = tmp;
+	ctx->wakeupenable = tmp;
 
 	omap2_mcspi_set_master_mode(master);
 	omap2_mcspi_disable_clocks(mcspi);
@@ -1109,7 +1105,6 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 	struct omap2_mcspi	*mcspi;
 	struct resource		*r;
 	int			status = 0, i;
-	char			wq_name[20];
 	u32			regs_offset = 0;
 	static int		bus_num = 1;
 	struct device_node	*node = pdev->dev.of_node;
@@ -1150,8 +1145,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 	mcspi = spi_master_get_devdata(master);
 	mcspi->master = master;
 
-	sprintf(wq_name, "omap2_mcspi/%d", master->bus_num);
-	mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1);
+	mcspi->wq = alloc_workqueue(dev_name(&pdev->dev), WQ_MEM_RECLAIM, 1);
 	if (mcspi->wq == NULL) {
 		status = -ENOMEM;
 		goto free_master;
@@ -1184,7 +1178,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 
 	spin_lock_init(&mcspi->lock);
 	INIT_LIST_HEAD(&mcspi->msg_queue);
-	INIT_LIST_HEAD(&omap2_mcspi_ctx[master->bus_num - 1].cs);
+	INIT_LIST_HEAD(&mcspi->ctx.cs);
 
 	mcspi->dma_channels = kcalloc(master->num_chipselect,
 			sizeof(struct omap2_mcspi_dma),
@@ -1291,13 +1285,12 @@ static int omap2_mcspi_resume(struct device *dev)
 {
 	struct spi_master	*master = dev_get_drvdata(dev);
 	struct omap2_mcspi	*mcspi = spi_master_get_devdata(master);
-	struct omap2_mcspi_cs *cs;
+	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
+	struct omap2_mcspi_cs	*cs;
 
 	omap2_mcspi_enable_clocks(mcspi);
-	list_for_each_entry(cs, &omap2_mcspi_ctx[master->bus_num - 1].cs,
-			    node) {
+	list_for_each_entry(cs, &ctx->cs, node) {
 		if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) {
-
 			/*
 			 * We need to toggle CS state for OMAP take this
 			 * change in account.
-- 
1.7.1


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

* [PATCHv3 2/6] spi: omap2-mcspi: make it behave as a module
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D
@ 2012-03-30 10:20 ` Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 3/6] spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-omap, linux-kernel, Felipe Balbi, Shubhrajyoti D

From: Felipe Balbi <balbi@ti.com>

move probe away from __init section and use
platform_driver_register() instead of
platform_driver_probe().

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7785091..26dd79f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1098,7 +1098,7 @@ static const struct of_device_id omap_mcspi_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
 
-static int __init omap2_mcspi_probe(struct platform_device *pdev)
+static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 {
 	struct spi_master	*master;
 	struct omap2_mcspi_platform_config *pdata;
@@ -1245,7 +1245,7 @@ free_master:
 	return status;
 }
 
-static int __exit omap2_mcspi_remove(struct platform_device *pdev)
+static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 {
 	struct spi_master	*master;
 	struct omap2_mcspi	*mcspi;
@@ -1320,13 +1320,14 @@ static struct platform_driver omap2_mcspi_driver = {
 		.pm =		&omap2_mcspi_pm_ops,
 		.of_match_table = omap_mcspi_of_match,
 	},
-	.remove =	__exit_p(omap2_mcspi_remove),
+	.probe =	omap2_mcspi_probe,
+	.remove =	__devexit_p(omap2_mcspi_remove),
 };
 
 
 static int __init omap2_mcspi_init(void)
 {
-	return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe);
+	return platform_driver_register(&omap2_mcspi_driver);
 }
 subsys_initcall(omap2_mcspi_init);
 
-- 
1.7.1


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

* [PATCHv3 3/6] spi: omap2-mcspi: convert to module_platform_driver
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 2/6] spi: omap2-mcspi: make it behave as a module Shubhrajyoti D
@ 2012-03-30 10:20 ` Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 4/6] spi: omap2-mcspi: use devm_* functions Shubhrajyoti D
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-omap, linux-kernel, Felipe Balbi, Shubhrajyoti D

From: Felipe Balbi <balbi@ti.com>

this will delete a few lines of code, no functional
changes.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |   15 +--------------
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 26dd79f..66cbf22 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1324,18 +1324,5 @@ static struct platform_driver omap2_mcspi_driver = {
 	.remove =	__devexit_p(omap2_mcspi_remove),
 };
 
-
-static int __init omap2_mcspi_init(void)
-{
-	return platform_driver_register(&omap2_mcspi_driver);
-}
-subsys_initcall(omap2_mcspi_init);
-
-static void __exit omap2_mcspi_exit(void)
-{
-	platform_driver_unregister(&omap2_mcspi_driver);
-
-}
-module_exit(omap2_mcspi_exit);
-
+module_platform_driver(omap2_mcspi_driver);
 MODULE_LICENSE("GPL");
-- 
1.7.1


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

* [PATCHv3 4/6] spi: omap2-mcspi: use devm_* functions
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
                   ` (2 preceding siblings ...)
  2012-03-30 10:20 ` [PATCHv3 3/6] spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D
@ 2012-03-30 10:20 ` Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 5/6] spi: omap2-mcspi: add support for pm_runtime autosuspend Shubhrajyoti D
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-omap, linux-kernel, Shubhrajyoti D

The various devm_* functions allocate memory that is released when a driver
detaches. This patch uses devm_request_and_ioremap
to request memory in probe function. Since the freeing is not
needed the calls are deleted from remove function.Also use
use devm_kzalloc for the cs memory allocation.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |   24 ++++--------------------
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 66cbf22..1907ed2 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -787,7 +787,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
 	mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
 	if (!cs) {
-		cs = kzalloc(sizeof *cs, GFP_KERNEL);
+		cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL);
 		if (!cs)
 			return -ENOMEM;
 		cs->base = mcspi->base + spi->chip_select * 0x14;
@@ -828,7 +828,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
 		cs = spi->controller_state;
 		list_del(&cs->node);
 
-		kfree(spi->controller_state);
 	}
 
 	if (spi->chip_select < spi->master->num_chipselect) {
@@ -1160,17 +1159,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 	r->start += regs_offset;
 	r->end += regs_offset;
 	mcspi->phys = r->start;
-	if (!request_mem_region(r->start, resource_size(r),
-				dev_name(&pdev->dev))) {
-		status = -EBUSY;
-		goto free_master;
-	}
 
-	mcspi->base = ioremap(r->start, resource_size(r));
+	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
 	if (!mcspi->base) {
 		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
 		status = -ENOMEM;
-		goto release_region;
+		goto free_master;
 	}
 
 	mcspi->dev = &pdev->dev;
@@ -1185,7 +1179,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 			GFP_KERNEL);
 
 	if (mcspi->dma_channels == NULL)
-		goto unmap_io;
+		goto free_master;
 
 	for (i = 0; i < master->num_chipselect; i++) {
 		char dma_ch_name[14];
@@ -1235,10 +1229,6 @@ disable_pm:
 	pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
 	kfree(mcspi->dma_channels);
-unmap_io:
-	iounmap(mcspi->base);
-release_region:
-	release_mem_region(r->start, resource_size(r));
 free_master:
 	kfree(master);
 	platform_set_drvdata(pdev, NULL);
@@ -1250,8 +1240,6 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 	struct spi_master	*master;
 	struct omap2_mcspi	*mcspi;
 	struct omap2_mcspi_dma	*dma_channels;
-	struct resource		*r;
-	void __iomem *base;
 
 	master = dev_get_drvdata(&pdev->dev);
 	mcspi = spi_master_get_devdata(master);
@@ -1259,12 +1247,8 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
 
 	omap2_mcspi_disable_clocks(mcspi);
 	pm_runtime_disable(&pdev->dev);
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(r->start, resource_size(r));
 
-	base = mcspi->base;
 	spi_unregister_master(master);
-	iounmap(base);
 	kfree(dma_channels);
 	destroy_workqueue(mcspi->wq);
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.1


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

* [PATCHv3 5/6] spi: omap2-mcspi: add support for pm_runtime autosuspend
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
                   ` (3 preceding siblings ...)
  2012-03-30 10:20 ` [PATCHv3 4/6] spi: omap2-mcspi: use devm_* functions Shubhrajyoti D
@ 2012-03-30 10:20 ` Shubhrajyoti D
  2012-03-30 10:20 ` [PATCHv3 6/6] spi: omap2-mcspi: Trivial optimisation Shubhrajyoti D
  2012-03-31  5:44 ` [PATCHv3 0/6] spi: omap2-mcspi: driver updates Grant Likely
  6 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-omap, linux-kernel, Shubhrajyoti D

Adds support for configuring the omap2-mcspi driver use autosuspend for
runtime power management. This can reduce the latency in starting an
spi transfer by not suspending the device immediately following
completion of a transfer. If another transfer then takes place before
the autosuspend timeout (2 secs), the call to resume the device can
return immediately saving some save/ restore cycles.

Acked-by: Govindraj.R <govindraj.raja@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 1907ed2..0b0da2f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -44,6 +44,7 @@
 #include <plat/mcspi.h>
 
 #define OMAP2_MCSPI_MAX_FREQ		48000000
+#define SPI_AUTOSUSPEND_TIMEOUT		2000
 
 #define OMAP2_MCSPI_REVISION		0x00
 #define OMAP2_MCSPI_SYSSTATUS		0x14
@@ -265,7 +266,8 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
 }
 static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
 {
-	pm_runtime_put_sync(mcspi->dev);
+	pm_runtime_mark_last_busy(mcspi->dev);
+	pm_runtime_put_autosuspend(mcspi->dev);
 }
 
 static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
@@ -1212,6 +1214,8 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 	if (status < 0)
 		goto dma_chnl_free;
 
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
 	pm_runtime_enable(&pdev->dev);
 
 	if (status || omap2_mcspi_master_setup(mcspi) < 0)
-- 
1.7.1


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

* [PATCHv3 6/6] spi: omap2-mcspi: Trivial optimisation
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
                   ` (4 preceding siblings ...)
  2012-03-30 10:20 ` [PATCHv3 5/6] spi: omap2-mcspi: add support for pm_runtime autosuspend Shubhrajyoti D
@ 2012-03-30 10:20 ` Shubhrajyoti D
  2012-03-31  5:44 ` [PATCHv3 0/6] spi: omap2-mcspi: driver updates Grant Likely
  6 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti D @ 2012-03-30 10:20 UTC (permalink / raw)
  To: spi-devel-general; +Cc: linux-omap, linux-kernel, Shubhrajyoti D

Trivial optimisation of tmp variable by directly writing the value
to the register.

Cc :  Tarun Kanti DebBarma <tarun.kanti@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/spi/spi-omap2-mcspi.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0b0da2f..f374eee 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1050,16 +1050,15 @@ static int __init omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
 {
 	struct spi_master	*master = mcspi->master;
 	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
-	u32			tmp;
 	int			ret = 0;
 
 	ret = omap2_mcspi_enable_clocks(mcspi);
 	if (ret < 0)
 		return ret;
 
-	tmp = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
-	mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, tmp);
-	ctx->wakeupenable = tmp;
+	mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE,
+				OMAP2_MCSPI_WAKEUPENABLE_WKEN);
+	ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
 
 	omap2_mcspi_set_master_mode(master);
 	omap2_mcspi_disable_clocks(mcspi);
-- 
1.7.1


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

* Re: [PATCHv3 0/6] spi: omap2-mcspi: driver updates
  2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
                   ` (5 preceding siblings ...)
  2012-03-30 10:20 ` [PATCHv3 6/6] spi: omap2-mcspi: Trivial optimisation Shubhrajyoti D
@ 2012-03-31  5:44 ` Grant Likely
  2012-03-31 11:12   ` Shubhrajyoti
  6 siblings, 1 reply; 9+ messages in thread
From: Grant Likely @ 2012-03-31  5:44 UTC (permalink / raw)
  To: Shubhrajyoti D, spi-devel-general
  Cc: Shubhrajyoti, linux-omap, linux-kernel, D

On Fri, 30 Mar 2012 15:50:16 +0530, Shubhrajyoti D <shubhrajyoti@ti.com> wrote:
> The patch series does the following cleanups
> - Converts the spi to module_platform_driver
> - Use the devm functions so that the freeing need not 
>   be done in the driver.
> - Makes the driver use autosuspend
> - Folds Benoit's bus_num removal patch in the series
> 
> Changes from v1
> - Makes the driver use autosuspend
> - Folds Benoit's bus_num removal patch in the series
> 
> Changes from v2
> - The tmp variable is used to write this can be optimised 
>  as it is not needed if the value is directly written.
>  Acknowledge  Tarun for the suggestion.
> 
> This is also available through
> git     : git://gitorious.org/linus-tree/linus-tree.git
> branch  : spi
> 
> This is targeted for v3.5. 

Okay, now is a good time to talk about git pull request workflow.  10
days ago you published a git tree and I replied that I had pulled it
into mine.  Now you've got a new branch with the patches from the old
branch rebased onto a new head.  Compairing your branch with mine now
looks like this:

$ git fetch git://gitorious.org/linus-tree/linus-tree.git spi
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 30 (delta 24), reused 6 (delta 2)
Unpacking objects: 100% (30/30), done.
>From git://gitorious.org/linus-tree/linus-tree
 * branch            spi        -> FETCH_HEAD
$ git show-branch --topic origin spi/next FETCH_HEAD
! [origin] Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
 ! [spi/next] Merge branch 'spi' of git://gitorious.org/linus-tree/linus-tree into spi/next
  ! [FETCH_HEAD] spi: omap2-mcspi: Trivial optimisation
---
  + [FETCH_HEAD] spi: omap2-mcspi: Trivial optimisation
  + [FETCH_HEAD^] spi: omap2-mcspi: add support for pm_runtime autosuspend
  + [FETCH_HEAD~2] spi: omap2-mcspi: use devm_* functions
  + [FETCH_HEAD~3] spi: omap2-mcspi: convert to module_platform_driver
  + [FETCH_HEAD~4] spi: omap2-mcspi: make it behave as a module
  + [FETCH_HEAD~5] spi/omap: Remove bus_num usage for instance index
 -  [spi/next] Merge branch 'spi' of git://gitorious.org/linus-tree/linus-tree into spi/next
 +  [spi/next^2] OMAP : SPI : use devm_* functions
 +  [spi/next^2^] spi: omap2-mcspi: convert to module_platform_driver
 +  [spi/next^2~2] spi: omap2-mcspi: make it behave as a module
+++ [origin~189] Linux 3.3

I cannot merge this branch.  If I did it would result in 2 commits for
each of the commits from the original branch.  You'll need go back and
rebase the new commits on top of the old base or on top of my current
spi/next branch[1]

[1] git://git.secretlab.ca/git/linux-2.6 spi/next

I've already published that branch, so I will not rebase it either to
remove the original commits.  The new commits must go on top.

Next time, *don't* rebase a branch that has been pulled.  It should be
left alone and new commits added on top of it.  If your in the
situation where mainline has commits that you need to bring into the
branch, then *merge* mainline into your branch (preferably at a tagged
release point), or ask me to merge in mainline to give you a new
baseline to work from.

One option I do have is to apply only the patches I'm missing to my
tree, but I'm not going to because I don't actually know if patches
1, 2, or 3 have changed since the version that I've posted.  It's
safer for me to get you to rebase back onto the proper base and post
only the new patches.  Your cover letter should state specifically
which branch the patches apply on top of.

g.

> 
> Benoit Cousson (1):
>   spi/omap: Remove bus_num usage for instance index
> 
> Felipe Balbi (2):
>   spi: omap2-mcspi: make it behave as a module
>   spi: omap2-mcspi: convert to module_platform_driver
> 
> Shubhrajyoti D (3):
>   spi: omap2-mcspi: use devm_* functions
>   spi: omap2-mcspi: add support for pm_runtime autosuspend
>   spi: omap2-mcspi: Trivial optimisation
> 
>  drivers/spi/spi-omap2-mcspi.c |  132 +++++++++++++++-------------------------
>  1 files changed, 50 insertions(+), 82 deletions(-)
> 
> 
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies,Ltd.

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

* Re: [PATCHv3 0/6] spi: omap2-mcspi: driver updates
  2012-03-31  5:44 ` [PATCHv3 0/6] spi: omap2-mcspi: driver updates Grant Likely
@ 2012-03-31 11:12   ` Shubhrajyoti
  0 siblings, 0 replies; 9+ messages in thread
From: Shubhrajyoti @ 2012-03-31 11:12 UTC (permalink / raw)
  To: Grant Likely
  Cc: spi-devel-general, Shubhrajyoti Datta, linux-omap, linux-kernel

On Saturday 31 March 2012 11:14 AM, Grant Likely wrote:
> On Fri, 30 Mar 2012 15:50:16 +0530, Shubhrajyoti D <shubhrajyoti@ti.com> wrote:
>> The patch series does the following cleanups
>> - Converts the spi to module_platform_driver
>> - Use the devm functions so that the freeing need not 
>>   be done in the driver.
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>>
>> Changes from v1
>> - Makes the driver use autosuspend
>> - Folds Benoit's bus_num removal patch in the series
>>
>> Changes from v2
>> - The tmp variable is used to write this can be optimised 
>>  as it is not needed if the value is directly written.
>>  Acknowledge  Tarun for the suggestion.
>>
>> This is also available through
>> git     : git://gitorious.org/linus-tree/linus-tree.git
>> branch  : spi
>>
>> This is targeted for v3.5. 
> Okay, now is a good time to talk about git pull request workflow.  10
> days ago you published a git tree and I replied that I had pulled it
> into mine.  Now you've got a new branch with the patches from the old
> branch rebased onto a new head.  Compairing your branch with mine now
> looks like this:
>
> $ git fetch git://gitorious.org/linus-tree/linus-tree.git spi
> remote: Counting objects: 34, done.
> remote: Compressing objects: 100% (28/28), done.
> remote: Total 30 (delta 24), reused 6 (delta 2)
> Unpacking objects: 100% (30/30), done.
> From git://gitorious.org/linus-tree/linus-tree
>  * branch            spi        -> FETCH_HEAD
> $ git show-branch --topic origin spi/next FETCH_HEAD
> ! [origin] Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
>  ! [spi/next] Merge branch 'spi' of git://gitorious.org/linus-tree/linus-tree into spi/next
>   ! [FETCH_HEAD] spi: omap2-mcspi: Trivial optimisation
> ---
>   + [FETCH_HEAD] spi: omap2-mcspi: Trivial optimisation
>   + [FETCH_HEAD^] spi: omap2-mcspi: add support for pm_runtime autosuspend
>   + [FETCH_HEAD~2] spi: omap2-mcspi: use devm_* functions
>   + [FETCH_HEAD~3] spi: omap2-mcspi: convert to module_platform_driver
>   + [FETCH_HEAD~4] spi: omap2-mcspi: make it behave as a module
>   + [FETCH_HEAD~5] spi/omap: Remove bus_num usage for instance index
>  -  [spi/next] Merge branch 'spi' of git://gitorious.org/linus-tree/linus-tree into spi/next
>  +  [spi/next^2] OMAP : SPI : use devm_* functions
>  +  [spi/next^2^] spi: omap2-mcspi: convert to module_platform_driver
>  +  [spi/next^2~2] spi: omap2-mcspi: make it behave as a module
> +++ [origin~189] Linux 3.3
>
> I cannot merge this branch.  If I did it would result in 2 commits for
> each of the commits from the original branch.  You'll need go back and
> rebase the new commits on top of the old base or on top of my current
> spi/next branch[1]
>
> [1] git://git.secretlab.ca/git/linux-2.6 spi/next
>
> I've already published that branch, so I will not rebase it either to
> remove the original commits.  The new commits must go on top.
>
> Next time, *don't* rebase a branch that has been pulled.  It should be
> left alone and new commits added on top of it.
Apologies for this time.
Yes will take care henceforth.
>   If your in the
> situation where mainline has commits that you need to bring into the
> branch, then *merge* mainline into your branch (preferably at a tagged
> release point), or ask me to merge in mainline to give you a new
> baseline to work from.
>
> One option I do have is to apply only the patches I'm missing to my
> tree, but I'm not going to because I don't actually know if patches
> 1, 2, or 3 have changed since the version that I've posted.  It's
> safer for me to get you to rebase back onto the proper base and post
> only the new patches.  Your cover letter should state specifically
> which branch the patches apply on top of.
Will send another pull request.



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

end of thread, other threads:[~2012-03-31 11:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-30 10:20 [PATCHv3 0/6] spi: omap2-mcspi: driver updates Shubhrajyoti D
2012-03-30 10:20 ` [PATCHv3 1/6] spi/omap: Remove bus_num usage for instance index Shubhrajyoti D
2012-03-30 10:20 ` [PATCHv3 2/6] spi: omap2-mcspi: make it behave as a module Shubhrajyoti D
2012-03-30 10:20 ` [PATCHv3 3/6] spi: omap2-mcspi: convert to module_platform_driver Shubhrajyoti D
2012-03-30 10:20 ` [PATCHv3 4/6] spi: omap2-mcspi: use devm_* functions Shubhrajyoti D
2012-03-30 10:20 ` [PATCHv3 5/6] spi: omap2-mcspi: add support for pm_runtime autosuspend Shubhrajyoti D
2012-03-30 10:20 ` [PATCHv3 6/6] spi: omap2-mcspi: Trivial optimisation Shubhrajyoti D
2012-03-31  5:44 ` [PATCHv3 0/6] spi: omap2-mcspi: driver updates Grant Likely
2012-03-31 11:12   ` Shubhrajyoti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).