extcon: madera: Correct handling of minimum short circuit impedance
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Fri, 4 Aug 2017 12:31:17 +0000 (13:31 +0100)
committer강신형 <s47.kang@samsung.com>
Tue, 19 Jun 2018 07:52:36 +0000 (16:52 +0900)
If there is an external resistance <= 4 ohms and the configured short
impedance had to be adjusted up to be in measurable range it was being
set too high because the adjusted threshold didn't take account that
it should be reduced by the external resistance.

Change-Id: I9b76d643b6533c3fa4f220f56c949303eaeff833
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
drivers/extcon/extcon-madera.c

index 852fd726d1d24c59ded1e0d18f6e10b06a29d7ee..4a199c4b0a1c96f23b11812d180b0964a0389f10 100644 (file)
@@ -2999,12 +2999,18 @@ static int madera_extcon_probe(struct platform_device *pdev)
                               madera_hohm_to_ohm(pdata->hpdet_ext_res_x100);
 
        if (hpdet_short_measured < MADERA_HP_SHORT_IMPEDANCE_MIN) {
+               /*
+                * increase comparison threshold to minimum we can measure
+                * taking into account that threshold does not include external
+                * resistance
+                */
+               info->hpdet_short_x100 =
+                       madera_ohm_to_hohm(MADERA_HP_SHORT_IMPEDANCE_MIN) -
+                       pdata->hpdet_ext_res_x100;
                dev_warn(info->dev,
                         "Increasing HP short circuit impedance from %d to %d\n",
                         pdata->hpdet_short_circuit_imp,
-                        MADERA_HP_SHORT_IMPEDANCE_MIN);
-               info->hpdet_short_x100 =
-                       madera_ohm_to_hohm(MADERA_HP_SHORT_IMPEDANCE_MIN);
+                        madera_hohm_to_ohm(info->hpdet_short_x100));
        }
 
        info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");