Commit ccdabd8956936319c5f7112bf5774e839b085874

Authored by Simon Glass
Committed by Bin Meng
1 parent 86c70e9ca6

spi: Correct operations check in dm_spi_xfer()

At present we have to have an xfer() method even if it does nothing. This
is not correct, so fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Showing 3 changed files with 6 additions and 10 deletions Side-by-side Diff

... ... @@ -493,13 +493,6 @@
493 493 return 0;
494 494 }
495 495  
496   -static int ich_spi_xfer(struct udevice *dev, unsigned int bitlen,
497   - const void *dout, void *din, unsigned long flags)
498   -{
499   - printf("ICH SPI: Only supports memory operations\n");
500   - return -1;
501   -}
502   -
503 496 static int ich_spi_probe(struct udevice *dev)
504 497 {
505 498 struct ich_spi_platdata *plat = dev_get_platdata(dev);
... ... @@ -612,7 +605,7 @@
612 605 };
613 606  
614 607 static const struct dm_spi_ops ich_spi_ops = {
615   - .xfer = ich_spi_xfer,
  608 + /* xfer is not supported */
616 609 .set_speed = ich_spi_set_speed,
617 610 .set_mode = ich_spi_set_mode,
618 611 .mem_ops = &ich_controller_mem_ops,
drivers/spi/spi-uclass.c
... ... @@ -85,11 +85,14 @@
85 85 const void *dout, void *din, unsigned long flags)
86 86 {
87 87 struct udevice *bus = dev->parent;
  88 + struct dm_spi_ops *ops = spi_get_ops(bus);
88 89  
89 90 if (bus->uclass->uc_drv->id != UCLASS_SPI)
90 91 return -EOPNOTSUPP;
  92 + if (!ops->xfer)
  93 + return -ENOSYS;
91 94  
92   - return spi_get_ops(bus)->xfer(dev, bitlen, dout, din, flags);
  95 + return ops->xfer(dev, bitlen, dout, din, flags);
93 96 }
94 97  
95 98 int dm_spi_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep,
... ... @@ -224,7 +224,7 @@
224 224 int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen);
225 225  
226 226 /**
227   - * SPI transfer
  227 + * SPI transfer (optional if mem_ops is used)
228 228 *
229 229 * This writes "bitlen" bits out the SPI MOSI port and simultaneously clocks
230 230 * "bitlen" bits in the SPI MISO port. That's just the way SPI works.