Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2347599pxk; Mon, 14 Sep 2020 10:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpqVRD/7rsfhU5EtY2wpoQIHktfkpc9M7Ve+VzX2Kd6Pvotfs2f81NxiiU0e8C6JoivgbX X-Received: by 2002:a17:906:72d2:: with SMTP id m18mr15788104ejl.220.1600105963783; Mon, 14 Sep 2020 10:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600105963; cv=none; d=google.com; s=arc-20160816; b=ZzY/J9cs1MROn2FZBvk6U48VlVh4FTN9jnddZKZiZN3jZrXR4ljIQfbZxmtJJAmqIs FGJiG6exExeoweLV//0GDG+13I/a31c5RI7QlVDuRGv7hkOcMCxC2/Zs6Uo+1MTonzNh yy8hu/QRpNHPNOHlkBa0Jrenf/LXfhCWSos2820KJ0SdC7FLB6yVNUofFeLeld9fNg8y Pe04Gn0AEQ4DsyNfhgOhB6hjoJqaaMdzTHITRtcRr0t9JDYWrCNMeZOtDrpsoGT+JyhB C9axH4d09lfVx+PQ8oT0JEZLVmFXOLy7+b+uJtJbPF6MGMWRTCEUViQ1LP93+AxYieCO j89A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=oCxGiwnFblUOdStsqywUVCRABxqKUUlGkpv5hbGrMug=; b=H5Ea98L7HODeTgKaEt2JkYgfstgwDjR83dVO3pQX9sR+7Ds0QtawnMs+agXtg9FC/9 0uDQPvMiox+Kn1rDe5C2Pv+YBLXrgM1M02ueS1QeEPi+WOmfTI6hYpfcStzPSvr32gXE MpgUnWHw3683KNOvwWvIFLwO+bBTz+JknqvOZWI7vYi7bMBt46mju1zXDT2XYEioyx7I xciOCvUgJ/YFTZOzjXpejrWEtoGKO09TiZCI0F3huuux6Ghi62HBajaZpdLayoCB54Dj fYelw5v3ahmpJ9ijeEbzv5eKR5DiQC7hKtMUMyBoAbQAIzN8YfGnm2EqnKqtNdoV3ofQ FacA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ltdQ1rxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch15si8122552ejb.52.2020.09.14.10.52.21; Mon, 14 Sep 2020 10:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ltdQ1rxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726065AbgINRvh (ORCPT + 99 others); Mon, 14 Sep 2020 13:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgINRuq (ORCPT ); Mon, 14 Sep 2020 13:50:46 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB463C06174A; Mon, 14 Sep 2020 10:50:45 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id o20so165397pfp.11; Mon, 14 Sep 2020 10:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=oCxGiwnFblUOdStsqywUVCRABxqKUUlGkpv5hbGrMug=; b=ltdQ1rxyPOmJTs5Qbw9ZYjv+MWkYYn8owPIqf4XVFXT0PonPt7PkBrwiaw8JdBOhnD CeOwzvviyv/4y82pu1Cfr/4uOdHKC5rAhOlIbbhUkSzQWNx/EHzp3GcRcfoidPGFGhar fxkbMQvEeP6YdylEWZUp5/kju8teGdBDFysae66NCi3M2tsdVmJDUQJNi7027Lg3N+6O KsyPs6XascC2w0mmuhPNUcc1nUk42rc2EsNOGNBfu3memZ+imYuEmHKE3aB/WzmX4y3P ISCUfe1ezHqM94525oXrKcQuLV+R/DnBwCq2kczjYYAwfHaEU3RETbO0oNa1WogA9Q5g G4dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=oCxGiwnFblUOdStsqywUVCRABxqKUUlGkpv5hbGrMug=; b=d1LJfhCcH2CL4NizOgZmdPC9E+mccDYs8V+oogXKWoFJa+f8XmnX0p/VF9HJDLpriL lqiE96mg6ByiP4Oun4NiN+pxTv6eL8uRuU21gkC1NeXOBLNnAHm/MBx96GFzfzXB7hhq pNmkyQ/1h4O2tPuL3il/WdMsvOBPut2FNHeABQJlWc1Cd07sLRltLf+06nFXR+zbbj0x lyjJVTR286+CEwBxvADI6sUthlUYsoIoEdR9OETKae6vs8BhyDDttjqYMYSFJxJp6f3L mHKwA/bOGNfI7ZHJJOt1LbgZHrV3Upw7+e+GeUCZjFnMvkC5EqBDoJ59p8wu7ATm/apJ kZTA== X-Gm-Message-State: AOAM533eLELj3T9DZ8AZDrVqjvK+UzN7DqatleftUvIL4iqwKr5rfdts /JMDddn9YpGPI2VpcmJaIcH8lXyU8cw= X-Received: by 2002:a17:902:8d8f:b029:d0:cc02:8527 with SMTP id v15-20020a1709028d8fb02900d0cc028527mr15212214plo.33.1600105845194; Mon, 14 Sep 2020 10:50:45 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id a13sm9310816pfi.139.2020.09.14.10.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 10:50:44 -0700 (PDT) Date: Mon, 14 Sep 2020 10:50:42 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Dan Carpenter , linux-kernel@vger.kernel.org Subject: [PATCH] Input: imx6ul_tsc - unify open/close and PM paths Message-ID: <20200914175042.GA1497032@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Open/close and resume/suspend paths are very similar, let's factor out common parts. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/imx6ul_tsc.c | 52 +++++++++++--------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c index 5e6ba5c4eca2..cd369f9ac5e6 100644 --- a/drivers/input/touchscreen/imx6ul_tsc.c +++ b/drivers/input/touchscreen/imx6ul_tsc.c @@ -315,9 +315,8 @@ static irqreturn_t adc_irq_fn(int irq, void *dev_id) 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; err = clk_prepare_enable(tsc->adc_clk); @@ -349,16 +348,29 @@ static int imx6ul_tsc_open(struct input_dev *input_dev) 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); clk_disable_unprepare(tsc->tsc_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) { 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); - if (input_dev->users) { - imx6ul_tsc_disable(tsc); - - clk_disable_unprepare(tsc->tsc_clk); - clk_disable_unprepare(tsc->adc_clk); - } + if (input_dev->users) + imx6ul_tsc_stop(tsc); mutex_unlock(&input_dev->mutex); @@ -530,27 +538,11 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev) mutex_lock(&input_dev->mutex); - if (!input_dev->users) - goto out; - - 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; - } + if (input_dev->users) + retval = imx6ul_tsc_start(tsc); - 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); + return retval; } -- 2.28.0.618.gf4bc123cb7-goog -- Dmitry