mxs_nand: don't check zero count when ECC reading with randomizer
[oweals/u-boot.git] / drivers / i2c / i2c-cdns.c
index 2c0301ad083a0dbc4b7146f9e3a3c640f314960b..ac15da2c67ffea715dc5b3ece1c4b032dcd9f44b 100644 (file)
@@ -213,7 +213,7 @@ static int cdns_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
        unsigned long speed_p = speed;
        int ret = 0;
 
-       if (speed > 400000) {
+       if (speed > I2C_SPEED_FAST_RATE) {
                debug("%s, failed to set clock speed to %u\n", __func__,
                      speed);
                return -EINVAL;
@@ -265,7 +265,7 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,
 
        while (len-- && !is_arbitration_lost(regs)) {
                writel(*(cur_data++), &regs->data);
-               if (readl(&regs->transfer_size) == CDNS_I2C_FIFO_DEPTH) {
+               if (len && readl(&regs->transfer_size) == CDNS_I2C_FIFO_DEPTH) {
                        ret = cdns_i2c_wait(regs, CDNS_I2C_INTERRUPT_COMP |
                                            CDNS_I2C_INTERRUPT_ARBLOST);
                        if (ret & CDNS_I2C_INTERRUPT_ARBLOST)