diff mbox

[4/7] spi: spi-fsl-dspi: avoid preparing the clock two times

Message ID 1422356244-15629-5-git-send-email-bhuvanchandra.dv@toradex.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bhuvanchandra DV Jan. 27, 2015, 10:57 a.m. UTC
regmap_read/regmap_write will expect the peripheral clock
to be enabled before accessing the registers of the peripheral.
Since the peripheral clock is enabled separatly, avoid redundant clock
prepare (with devm_regmap_init_mmio_clk) and use devm_regmap_init_mmio instead.

Acked-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
---
 drivers/spi/spi-fsl-dspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Brown Jan. 27, 2015, 1:01 p.m. UTC | #1
On Tue, Jan 27, 2015 at 04:27:21PM +0530, Bhuvanchandra DV wrote:
> regmap_read/regmap_write will expect the peripheral clock
> to be enabled before accessing the registers of the peripheral.
> Since the peripheral clock is enabled separatly, avoid redundant clock
> prepare (with devm_regmap_init_mmio_clk) and use devm_regmap_init_mmio instead.

What's the advantage of this?  The clock API is refcounted so there
should be no issue with this and it seems like it's opening us up to
bugs if there's a path where we interact with the registers without
enabling the clocks.
Bhuvanchandra DV Jan. 28, 2015, 6:58 a.m. UTC | #2
On 01/27/2015 06:31 PM, Mark Brown wrote:
> On Tue, Jan 27, 2015 at 04:27:21PM +0530, Bhuvanchandra DV wrote:
>> regmap_read/regmap_write will expect the peripheral clock
>> to be enabled before accessing the registers of the peripheral.
>> Since the peripheral clock is enabled separatly, avoid redundant clock
>> prepare (with devm_regmap_init_mmio_clk) and use devm_regmap_init_mmio instead.
> What's the advantage of this?  The clock API is refcounted so there
> should be no issue with this and it seems like it's opening us up to
> bugs if there's a path where we interact with the registers without
> enabling the clocks.

My initial thought was that, since regmap_mmio_init_clk() does call
clk_prepare(), to go with regmap_mmio_init() as clk_prepare_enable()
is called at a later stage in the probe().
diff mbox

Patch

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 9b80d54..5378148 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -502,7 +502,7 @@  static int dspi_probe(struct platform_device *pdev)
 		goto out_master_put;
 	}
 
-	dspi->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "dspi", base,
+	dspi->regmap = devm_regmap_init_mmio(&pdev->dev, base,
 						&dspi_regmap_config);
 	if (IS_ERR(dspi->regmap)) {
 		dev_err(&pdev->dev, "failed to init regmap: %ld\n",