regulator: hi6421: Fix getting wrong drvdata
[linux-2.6-microblaze.git] / drivers / regulator / stpmic1_regulator.c
index cf10fdb..2d7597c 100644 (file)
@@ -32,7 +32,8 @@ struct stpmic1_regulator_cfg {
 
 static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode);
 static unsigned int stpmic1_get_mode(struct regulator_dev *rdev);
-static int stpmic1_set_icc(struct regulator_dev *rdev);
+static int stpmic1_set_icc(struct regulator_dev *rdev, int lim, int severity,
+                          bool enable);
 static unsigned int stpmic1_map_mode(unsigned int mode);
 
 enum {
@@ -491,11 +492,26 @@ static int stpmic1_set_mode(struct regulator_dev *rdev, unsigned int mode)
                                  STPMIC1_BUCK_MODE_LP, value);
 }
 
-static int stpmic1_set_icc(struct regulator_dev *rdev)
+static int stpmic1_set_icc(struct regulator_dev *rdev, int lim, int severity,
+                          bool enable)
 {
        struct stpmic1_regulator_cfg *cfg = rdev_get_drvdata(rdev);
        struct regmap *regmap = rdev_get_regmap(rdev);
 
+       /*
+        * The code seems like one bit in a register controls whether OCP is
+        * enabled. So we might be able to turn it off here is if that
+        * was requested. I won't support this because I don't have the HW.
+        * Feel free to try and implement if you have the HW and need kernel
+        * to disable this.
+        *
+        * Also, I don't know if limit can be configured or if we support
+        * error/warning instead of protect. So I just keep existing logic
+        * and assume no.
+        */
+       if (lim || severity != REGULATOR_SEVERITY_PROT || !enable)
+               return -EINVAL;
+
        /* enable switch off in case of over current */
        return regmap_update_bits(regmap, cfg->icc_reg, cfg->icc_mask,
                                  cfg->icc_mask);