Skip to content

Commit

Permalink
spi: omap2-mcspi: Call pm_runtime_* functions directly
Browse files Browse the repository at this point in the history
Call the pm_runtime functions directly making room for possible
pm optimisations. Also the runtime functions aren't just about
enabling and disabling of clocks though it does enable clocks also.

Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Shubhrajyoti D authored and Mark Brown committed Aug 22, 2012
1 parent af4e944 commit 034d3dc
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions drivers/spi/spi-omap2-mcspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,6 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
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)
{
pm_runtime_mark_last_busy(mcspi->dev);
pm_runtime_put_autosuspend(mcspi->dev);
}

static int omap2_mcspi_enable_clocks(struct omap2_mcspi *mcspi)
{
return pm_runtime_get_sync(mcspi->dev);
}

static int omap2_prepare_transfer(struct spi_master *master)
{
Expand Down Expand Up @@ -848,12 +838,13 @@ static int omap2_mcspi_setup(struct spi_device *spi)
return ret;
}

ret = omap2_mcspi_enable_clocks(mcspi);
ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;

ret = omap2_mcspi_setup_transfer(spi, NULL);
omap2_mcspi_disable_clocks(mcspi);
pm_runtime_mark_last_busy(mcspi->dev);
pm_runtime_put_autosuspend(mcspi->dev);

return ret;
}
Expand Down Expand Up @@ -1067,7 +1058,7 @@ static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
int ret = 0;

ret = omap2_mcspi_enable_clocks(mcspi);
ret = pm_runtime_get_sync(mcspi->dev);
if (ret < 0)
return ret;

Expand All @@ -1076,7 +1067,8 @@ static int __devinit omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;

omap2_mcspi_set_master_mode(master);
omap2_mcspi_disable_clocks(mcspi);
pm_runtime_mark_last_busy(mcspi->dev);
pm_runtime_put_autosuspend(mcspi->dev);
return 0;
}

Expand Down Expand Up @@ -1253,7 +1245,8 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
mcspi = spi_master_get_devdata(master);
dma_channels = mcspi->dma_channels;

omap2_mcspi_disable_clocks(mcspi);
pm_runtime_mark_last_busy(mcspi->dev);
pm_runtime_put_autosuspend(mcspi->dev);
pm_runtime_disable(&pdev->dev);

spi_unregister_master(master);
Expand All @@ -1278,7 +1271,7 @@ static int omap2_mcspi_resume(struct device *dev)
struct omap2_mcspi_regs *ctx = &mcspi->ctx;
struct omap2_mcspi_cs *cs;

omap2_mcspi_enable_clocks(mcspi);
pm_runtime_get_sync(mcspi->dev);
list_for_each_entry(cs, &ctx->cs, node) {
if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE) == 0) {
/*
Expand All @@ -1291,7 +1284,8 @@ static int omap2_mcspi_resume(struct device *dev)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
}
}
omap2_mcspi_disable_clocks(mcspi);
pm_runtime_mark_last_busy(mcspi->dev);
pm_runtime_put_autosuspend(mcspi->dev);
return 0;
}
#else
Expand Down

0 comments on commit 034d3dc

Please sign in to comment.