Commit 9694b724421b88acf7d553a55e4a43fa4e25e7be
Committed by
Jagannadha Sutradharudu Teki
1 parent
4fbad92e73
Exists in
v2017.01-smarct4x
and in
34 other branches
dm: spi: Correct SPI claim/release_bus() methods
These methods should be passed a slave device, not a bus. This matches the old SPI interface. It is important to know which device is claiming the bus so passing a bus is not that useful. Reported-by: Haikun Wang <haikun.wang@freescale.com> Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Peng Fan <Peng.Fan@freescale.com> Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Showing 6 changed files with 17 additions and 12 deletions Side-by-side Diff
drivers/spi/exynos_spi.c
... | ... | @@ -296,8 +296,9 @@ |
296 | 296 | return 0; |
297 | 297 | } |
298 | 298 | |
299 | -static int exynos_spi_claim_bus(struct udevice *bus) | |
299 | +static int exynos_spi_claim_bus(struct udevice *dev) | |
300 | 300 | { |
301 | + struct udevice *bus = dev->parent; | |
301 | 302 | struct exynos_spi_priv *priv = dev_get_priv(bus); |
302 | 303 | |
303 | 304 | exynos_pinmux_config(priv->periph_id, PINMUX_FLAG_NONE); |
304 | 305 | |
... | ... | @@ -308,8 +309,9 @@ |
308 | 309 | return 0; |
309 | 310 | } |
310 | 311 | |
311 | -static int exynos_spi_release_bus(struct udevice *bus) | |
312 | +static int exynos_spi_release_bus(struct udevice *dev) | |
312 | 313 | { |
314 | + struct udevice *bus = dev->parent; | |
313 | 315 | struct exynos_spi_priv *priv = dev_get_priv(bus); |
314 | 316 | |
315 | 317 | spi_flush_fifo(priv->regs); |
drivers/spi/spi-uclass.c
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | if (ret) |
68 | 68 | return ret; |
69 | 69 | |
70 | - return ops->claim_bus ? ops->claim_bus(bus) : 0; | |
70 | + return ops->claim_bus ? ops->claim_bus(dev) : 0; | |
71 | 71 | } |
72 | 72 | |
73 | 73 | void spi_release_bus(struct spi_slave *slave) |
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | struct dm_spi_ops *ops = spi_get_ops(bus); |
78 | 78 | |
79 | 79 | if (ops->release_bus) |
80 | - ops->release_bus(bus); | |
80 | + ops->release_bus(dev); | |
81 | 81 | } |
82 | 82 | |
83 | 83 | int spi_xfer(struct spi_slave *slave, unsigned int bitlen, |
drivers/spi/tegra114_spi.c
... | ... | @@ -153,8 +153,9 @@ |
153 | 153 | return 0; |
154 | 154 | } |
155 | 155 | |
156 | -static int tegra114_spi_claim_bus(struct udevice *bus) | |
156 | +static int tegra114_spi_claim_bus(struct udevice *dev) | |
157 | 157 | { |
158 | + struct udevice *bus = dev->parent; | |
158 | 159 | struct tegra114_spi_priv *priv = dev_get_priv(bus); |
159 | 160 | struct spi_regs *regs = priv->regs; |
160 | 161 |
drivers/spi/tegra20_sflash.c
... | ... | @@ -125,8 +125,9 @@ |
125 | 125 | return 0; |
126 | 126 | } |
127 | 127 | |
128 | -static int tegra20_sflash_claim_bus(struct udevice *bus) | |
128 | +static int tegra20_sflash_claim_bus(struct udevice *dev) | |
129 | 129 | { |
130 | + struct udevice *bus = dev->parent; | |
130 | 131 | struct tegra20_sflash_priv *priv = dev_get_priv(bus); |
131 | 132 | struct spi_regs *regs = priv->regs; |
132 | 133 | u32 reg; |
drivers/spi/tegra20_slink.c
... | ... | @@ -141,8 +141,9 @@ |
141 | 141 | return 0; |
142 | 142 | } |
143 | 143 | |
144 | -static int tegra30_spi_claim_bus(struct udevice *bus) | |
144 | +static int tegra30_spi_claim_bus(struct udevice *dev) | |
145 | 145 | { |
146 | + struct udevice *bus = dev->parent; | |
146 | 147 | struct tegra30_spi_priv *priv = dev_get_priv(bus); |
147 | 148 | struct spi_regs *regs = priv->regs; |
148 | 149 | u32 reg; |
include/spi.h
... | ... | @@ -386,12 +386,12 @@ |
386 | 386 | * allowed to claim the same bus for several slaves without releasing |
387 | 387 | * the bus in between. |
388 | 388 | * |
389 | - * @bus: The SPI slave | |
389 | + * @dev: The SPI slave | |
390 | 390 | * |
391 | 391 | * Returns: 0 if the bus was claimed successfully, or a negative value |
392 | 392 | * if it wasn't. |
393 | 393 | */ |
394 | - int (*claim_bus)(struct udevice *bus); | |
394 | + int (*claim_bus)(struct udevice *dev); | |
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Release the SPI bus |
398 | 398 | |
... | ... | @@ -400,9 +400,9 @@ |
400 | 400 | * all transfers have finished. It may disable any SPI hardware as |
401 | 401 | * appropriate. |
402 | 402 | * |
403 | - * @bus: The SPI slave | |
403 | + * @dev: The SPI slave | |
404 | 404 | */ |
405 | - int (*release_bus)(struct udevice *bus); | |
405 | + int (*release_bus)(struct udevice *dev); | |
406 | 406 | |
407 | 407 | /** |
408 | 408 | * Set the word length for SPI transactions |
... | ... | @@ -414,7 +414,7 @@ |
414 | 414 | * |
415 | 415 | * Returns: 0 on success, -ve on failure. |
416 | 416 | */ |
417 | - int (*set_wordlen)(struct udevice *bus, unsigned int wordlen); | |
417 | + int (*set_wordlen)(struct udevice *dev, unsigned int wordlen); | |
418 | 418 | |
419 | 419 | /** |
420 | 420 | * SPI transfer |