Commit 6cc527b0 authored by Fabio Estevam's avatar Fabio Estevam Committed by Dmitry Torokhov

Input: imx6ul_tsc - propagate the errors

imx6ul_adc_init() may fail in two cases, so we should better
propagate the errors and make sure that the callers of
this function also check and propagate the errors accordingly.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 46b018fa
...@@ -94,7 +94,7 @@ struct imx6ul_tsc { ...@@ -94,7 +94,7 @@ struct imx6ul_tsc {
* TSC module need ADC to get the measure value. So * TSC module need ADC to get the measure value. So
* before config TSC, we should initialize ADC module. * before config TSC, we should initialize ADC module.
*/ */
static void imx6ul_adc_init(struct imx6ul_tsc *tsc) static int imx6ul_adc_init(struct imx6ul_tsc *tsc)
{ {
int adc_hc = 0; int adc_hc = 0;
int adc_gc; int adc_gc;
...@@ -122,17 +122,23 @@ static void imx6ul_adc_init(struct imx6ul_tsc *tsc) ...@@ -122,17 +122,23 @@ static void imx6ul_adc_init(struct imx6ul_tsc *tsc)
timeout = wait_for_completion_timeout timeout = wait_for_completion_timeout
(&tsc->completion, ADC_TIMEOUT); (&tsc->completion, ADC_TIMEOUT);
if (timeout == 0) if (timeout == 0) {
dev_err(tsc->dev, "Timeout for adc calibration\n"); dev_err(tsc->dev, "Timeout for adc calibration\n");
return -ETIMEDOUT;
}
adc_gs = readl(tsc->adc_regs + REG_ADC_GS); adc_gs = readl(tsc->adc_regs + REG_ADC_GS);
if (adc_gs & ADC_CALF) if (adc_gs & ADC_CALF) {
dev_err(tsc->dev, "ADC calibration failed\n"); dev_err(tsc->dev, "ADC calibration failed\n");
return -EINVAL;
}
/* TSC need the ADC work in hardware trigger */ /* TSC need the ADC work in hardware trigger */
adc_cfg = readl(tsc->adc_regs + REG_ADC_CFG); adc_cfg = readl(tsc->adc_regs + REG_ADC_CFG);
adc_cfg |= ADC_HARDWARE_TRIGGER; adc_cfg |= ADC_HARDWARE_TRIGGER;
writel(adc_cfg, tsc->adc_regs + REG_ADC_CFG); writel(adc_cfg, tsc->adc_regs + REG_ADC_CFG);
return 0;
} }
/* /*
...@@ -188,11 +194,17 @@ static void imx6ul_tsc_set(struct imx6ul_tsc *tsc) ...@@ -188,11 +194,17 @@ static void imx6ul_tsc_set(struct imx6ul_tsc *tsc)
writel(start, tsc->tsc_regs + REG_TSC_FLOW_CONTROL); writel(start, tsc->tsc_regs + REG_TSC_FLOW_CONTROL);
} }
static void imx6ul_tsc_init(struct imx6ul_tsc *tsc) static int imx6ul_tsc_init(struct imx6ul_tsc *tsc)
{ {
imx6ul_adc_init(tsc); int err;
err = imx6ul_adc_init(tsc);
if (err)
return err;
imx6ul_tsc_channel_config(tsc); imx6ul_tsc_channel_config(tsc);
imx6ul_tsc_set(tsc); imx6ul_tsc_set(tsc);
return 0;
} }
static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc)
...@@ -311,9 +323,7 @@ static int imx6ul_tsc_open(struct input_dev *input_dev) ...@@ -311,9 +323,7 @@ static int imx6ul_tsc_open(struct input_dev *input_dev)
return err; return err;
} }
imx6ul_tsc_init(tsc); return imx6ul_tsc_init(tsc);
return 0;
} }
static void imx6ul_tsc_close(struct input_dev *input_dev) static void imx6ul_tsc_close(struct input_dev *input_dev)
...@@ -491,7 +501,7 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev) ...@@ -491,7 +501,7 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev)
goto out; goto out;
} }
imx6ul_tsc_init(tsc); retval = imx6ul_tsc_init(tsc);
} }
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment