X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fspi%2Fspi-uclass.c;h=58388efbc3be29e8e96e3b64d78fee632bd05a0a;hb=73f1b80c77ad0628c2ca78d3a21dafabb5761d48;hp=63a6217cc62d0085b6c4ba259415fae514651ba9;hpb=307367eaffc8638e10ba1784fc66bfe623ae79e2;p=u-boot diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index 63a6217cc6..58388efbc3 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -50,7 +50,7 @@ int spi_claim_bus(struct spi_slave *slave) struct udevice *dev = slave->dev; struct udevice *bus = dev->parent; struct dm_spi_ops *ops = spi_get_ops(bus); - struct dm_spi_bus *spi = bus->uclass_priv; + struct dm_spi_bus *spi = dev_get_uclass_priv(bus); int speed; int ret; @@ -63,11 +63,14 @@ int spi_claim_bus(struct spi_slave *slave) } if (!speed) speed = 100000; - ret = spi_set_speed_mode(bus, speed, slave->mode); - if (ret) - return ret; + if (speed != slave->speed) { + ret = spi_set_speed_mode(bus, speed, slave->mode); + if (ret) + return ret; + slave->speed = speed; + } - return ops->claim_bus ? ops->claim_bus(bus) : 0; + return ops->claim_bus ? ops->claim_bus(dev) : 0; } void spi_release_bus(struct spi_slave *slave) @@ -77,7 +80,7 @@ void spi_release_bus(struct spi_slave *slave) struct dm_spi_ops *ops = spi_get_ops(bus); if (ops->release_bus) - ops->release_bus(bus); + ops->release_bus(dev); } int spi_xfer(struct spi_slave *slave, unsigned int bitlen, @@ -92,13 +95,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, return spi_get_ops(bus)->xfer(dev, bitlen, dout, din, flags); } -int spi_post_bind(struct udevice *dev) +static int spi_post_bind(struct udevice *dev) { /* Scan the bus for devices */ return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); } -int spi_child_post_bind(struct udevice *dev) +static int spi_child_post_bind(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); @@ -108,9 +111,9 @@ int spi_child_post_bind(struct udevice *dev) return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat); } -int spi_post_probe(struct udevice *bus) +static int spi_post_probe(struct udevice *bus) { - struct dm_spi_bus *spi = bus->uclass_priv; + struct dm_spi_bus *spi = dev_get_uclass_priv(bus); spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset, "spi-max-frequency", 0); @@ -118,10 +121,10 @@ int spi_post_probe(struct udevice *bus) return 0; } -int spi_child_pre_probe(struct udevice *dev) +static int spi_child_pre_probe(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); - struct spi_slave *slave = dev_get_parentdata(dev); + struct spi_slave *slave = dev_get_parent_priv(dev); /* * This is needed because we pass struct spi_slave around the place @@ -279,7 +282,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, ret = device_probe(dev); if (ret) goto err; - slave = dev_get_parentdata(dev); + slave = dev_get_parent_priv(dev); slave->dev = dev; } @@ -288,7 +291,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode, goto err; *busp = bus; - *devp = dev_get_parentdata(dev); + *devp = dev_get_parent_priv(dev); debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp); return 0; @@ -317,7 +320,7 @@ struct spi_slave *spi_setup_slave_fdt(const void *blob, int node, ret = device_get_child_by_of_offset(bus, node, &dev); if (ret) return NULL; - return dev_get_parentdata(dev); + return dev_get_parent_priv(dev); } /* Compatibility function - to be removed */