i2c: rcar: bail out on zero length transfers
[firefly-linux-kernel-4.4.55.git] / drivers / i2c / busses / i2c-rcar.c
index 0282d4d42805fae9c2a6d68c3213bf0cab18f6f6..06d47aafbb79c75a18a66e12964544a9a2b3496f 100644 (file)
@@ -561,6 +561,12 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
 
        ret = -EINVAL;
        for (i = 0; i < num; i++) {
+               /* This HW can't send STOP after address phase */
+               if (msgs[i].len == 0) {
+                       ret = -EOPNOTSUPP;
+                       break;
+               }
+
                /*-------------- spin lock -----------------*/
                spin_lock_irqsave(&priv->lock, flags);
 
@@ -625,7 +631,8 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
 
 static u32 rcar_i2c_func(struct i2c_adapter *adap)
 {
-       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+       /* This HW can't do SMBUS_QUICK and NOSTART */
+       return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
 }
 
 static const struct i2c_algorithm rcar_i2c_algo = {
@@ -638,6 +645,7 @@ static const struct of_device_id rcar_i2c_dt_ids[] = {
        { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_GEN1 },
        { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_GEN1 },
        { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_GEN2 },
+       { .compatible = "renesas,i2c-r8a7791", .data = (void *)I2C_RCAR_GEN2 },
        {},
 };
 MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids);
@@ -691,7 +699,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
        adap                    = &priv->adap;
        adap->nr                = pdev->id;
        adap->algo              = &rcar_i2c_algo;
-       adap->class             = I2C_CLASS_HWMON | I2C_CLASS_SPD;
+       adap->class             = I2C_CLASS_HWMON | I2C_CLASS_SPD | I2C_CLASS_DEPRECATED;
        adap->retries           = 3;
        adap->dev.parent        = dev;
        adap->dev.of_node       = dev->of_node;