Input: imx6ul_tsc - unify open/close and PM paths
Open/close and resume/suspend paths are very similar, let's factor out common parts. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
@@ -315,9 +315,8 @@ static irqreturn_t adc_irq_fn(int irq, void *dev_id)
|
|||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int imx6ul_tsc_open(struct input_dev *input_dev)
|
static int imx6ul_tsc_start(struct imx6ul_tsc *tsc)
|
||||||
{
|
{
|
||||||
struct imx6ul_tsc *tsc = input_get_drvdata(input_dev);
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = clk_prepare_enable(tsc->adc_clk);
|
err = clk_prepare_enable(tsc->adc_clk);
|
||||||
@@ -349,16 +348,29 @@ disable_adc_clk:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void imx6ul_tsc_close(struct input_dev *input_dev)
|
static void imx6ul_tsc_stop(struct imx6ul_tsc *tsc)
|
||||||
{
|
{
|
||||||
struct imx6ul_tsc *tsc = input_get_drvdata(input_dev);
|
|
||||||
|
|
||||||
imx6ul_tsc_disable(tsc);
|
imx6ul_tsc_disable(tsc);
|
||||||
|
|
||||||
clk_disable_unprepare(tsc->tsc_clk);
|
clk_disable_unprepare(tsc->tsc_clk);
|
||||||
clk_disable_unprepare(tsc->adc_clk);
|
clk_disable_unprepare(tsc->adc_clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int imx6ul_tsc_open(struct input_dev *input_dev)
|
||||||
|
{
|
||||||
|
struct imx6ul_tsc *tsc = input_get_drvdata(input_dev);
|
||||||
|
|
||||||
|
return imx6ul_tsc_start(tsc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void imx6ul_tsc_close(struct input_dev *input_dev)
|
||||||
|
{
|
||||||
|
struct imx6ul_tsc *tsc = input_get_drvdata(input_dev);
|
||||||
|
|
||||||
|
imx6ul_tsc_stop(tsc);
|
||||||
|
}
|
||||||
|
|
||||||
static int imx6ul_tsc_probe(struct platform_device *pdev)
|
static int imx6ul_tsc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
@@ -509,12 +521,8 @@ static int __maybe_unused imx6ul_tsc_suspend(struct device *dev)
|
|||||||
|
|
||||||
mutex_lock(&input_dev->mutex);
|
mutex_lock(&input_dev->mutex);
|
||||||
|
|
||||||
if (input_dev->users) {
|
if (input_dev->users)
|
||||||
imx6ul_tsc_disable(tsc);
|
imx6ul_tsc_stop(tsc);
|
||||||
|
|
||||||
clk_disable_unprepare(tsc->tsc_clk);
|
|
||||||
clk_disable_unprepare(tsc->adc_clk);
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_unlock(&input_dev->mutex);
|
mutex_unlock(&input_dev->mutex);
|
||||||
|
|
||||||
@@ -530,27 +538,11 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev)
|
|||||||
|
|
||||||
mutex_lock(&input_dev->mutex);
|
mutex_lock(&input_dev->mutex);
|
||||||
|
|
||||||
if (!input_dev->users)
|
if (input_dev->users)
|
||||||
goto out;
|
retval = imx6ul_tsc_start(tsc);
|
||||||
|
|
||||||
retval = clk_prepare_enable(tsc->adc_clk);
|
|
||||||
if (retval)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
retval = clk_prepare_enable(tsc->tsc_clk);
|
|
||||||
if (retval) {
|
|
||||||
clk_disable_unprepare(tsc->adc_clk);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = imx6ul_tsc_init(tsc);
|
|
||||||
if (retval) {
|
|
||||||
clk_disable_unprepare(tsc->tsc_clk);
|
|
||||||
clk_disable_unprepare(tsc->adc_clk);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
out:
|
|
||||||
mutex_unlock(&input_dev->mutex);
|
mutex_unlock(&input_dev->mutex);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user