extcon: madera: Ensure micd read failures are caught
authorStuart Henderson <stuarth@opensource.cirrus.com>
Wed, 1 Nov 2017 15:07:46 +0000 (15:07 +0000)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:28 +0000 (20:22 +0300)
The use of madera_ohm_to_hohm was causing an error code to be lost when
passed to the .reading function.

Change-Id: Ie1741b47fb7491ba33d1dd5f9580dc975c130d9b
Signed-off-by: Stuart Henderson <stuarth@opensource.cirrus.com>
drivers/extcon/extcon-madera.c

index f85370d215cba1effcbfe8f23aa37d254373d5e0..e01caf272f6df17e59a9538347df4189e950b747 100644 (file)
@@ -2117,9 +2117,12 @@ static void madera_micd_handler(struct work_struct *work)
        if (ret == -EAGAIN)
                goto out;
 
-       dev_dbg(info->dev, "Mic impedance %d ohms\n", ret);
+       if (ret >= 0) {
+               dev_dbg(info->dev, "Mic impedance %d ohms\n", ret);
+               ret = madera_ohm_to_hohm((unsigned int)ret);
+       }
 
-       madera_jds_reading(info, madera_ohm_to_hohm((unsigned int)ret));
+       madera_jds_reading(info, ret);
 
 out:
        madera_jds_start_timeout(info);