From: Richard Fitzgerald Date: Fri, 4 Aug 2017 12:31:17 +0000 (+0100) Subject: extcon: madera: Correct handling of minimum short circuit impedance X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e5694758cf8908fde0e42d626894b52de674d76d;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git extcon: madera: Correct handling of minimum short circuit impedance 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 --- diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index 852fd726d1d2..4a199c4b0a1c 100644 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -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");