From f5ff46f6e5f88e1ee276963105d328a1bda6269a Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Thu, 15 Mar 2018 17:03:22 +0530 Subject: [PATCH] spi: kirkwood: Get drvdata in .ofdata_to_platdata Get the is_errata_50mhz_ac in .ofdata_to_platdata, and reuse it in .set_mode this can eventually initialized dt code at once and adding room to add platdata. Signed-off-by: Jagan Teki --- drivers/spi/kirkwood_spi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index d6944af..4aa2c54 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -248,6 +248,7 @@ struct mvebu_spi_dev { struct mvebu_spi_platdata { struct kwspi_registers *spireg; + bool is_errata_50mhz_ac; }; struct mvebu_spi_priv { @@ -309,7 +310,6 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode) { struct mvebu_spi_platdata *plat = dev_get_platdata(bus); struct kwspi_registers *reg = plat->spireg; - const struct mvebu_spi_dev *drvdata; u32 data = readl(®->cfg); data &= ~(KWSPI_CPHA | KWSPI_CPOL | KWSPI_RXLSBF | KWSPI_TXLSBF); @@ -323,8 +323,7 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode) writel(data, ®->cfg); - drvdata = (struct mvebu_spi_dev *)dev_get_driver_data(bus); - if (drvdata->is_errata_50mhz_ac) + if (plat->is_errata_50mhz_ac) mvebu_spi_50mhz_ac_timing_erratum(bus, mode); return 0; @@ -367,8 +366,11 @@ static int mvebu_spi_probe(struct udevice *bus) static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) { struct mvebu_spi_platdata *plat = dev_get_platdata(bus); + const struct mvebu_spi_dev *drvdata = + (struct mvebu_spi_dev *)dev_get_driver_data(bus); plat->spireg = (struct kwspi_registers *)devfdt_get_addr(bus); + plat->is_errata_50mhz_ac = drvdata->is_errata_50mhz_ac; return 0; } -- 2.7.4