From patchwork Tue Jan 23 18:52:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 10180961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A369602B7 for ; Tue, 23 Jan 2018 18:52:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0167D26E97 for ; Tue, 23 Jan 2018 18:52:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA26C287B7; Tue, 23 Jan 2018 18:52:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AADE287AC for ; Tue, 23 Jan 2018 18:52:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751721AbeAWSwl (ORCPT ); Tue, 23 Jan 2018 13:52:41 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:45558 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751474AbeAWSwk (ORCPT ); Tue, 23 Jan 2018 13:52:40 -0500 Received: by mail-pg0-f66.google.com with SMTP id m136so888770pga.12; Tue, 23 Jan 2018 10:52:40 -0800 (PST) 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 :user-agent; bh=Lfj3frZ49Zunh62jejykp2bDtmjy/zE37D2Gh+ALO28=; b=eb9lGSA47oxuOnQTQE0CbhQMn+3x+4+hA1YapEMQGRmnBxdrzerawabnfZnouDF91r kpRJtNrZQpqwPniNu6ce/KAmNiRPHdE3LDw6C0Xas6mwidsVur05r1GJmuYZaLglpWFA HPZro5hCwOu0CFNGS9jr/f01SXJPdmDggO/D7Nlx12NWTHFz7lE4vc30FXRT3UK5YpdF mhEAmiU2qz2ye7S88Up2qrj2Fi4c5yZJzbhkFBY0a09/hERgCKkS3j45yaDYVsBQJdVz dl33BmpA9FKNhEfi7iTvKpgnr+f01Tgi0Q69LcE+ssRxDl0g3yUTfQwat9AS4BkZUxiE p4NA== 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:user-agent; bh=Lfj3frZ49Zunh62jejykp2bDtmjy/zE37D2Gh+ALO28=; b=gGEVZWd15oPMdGLFi8rJRCv26NB4+qaJ22CNcHWUFREjgeBSdCNvqaqo8hwlSujEKa CZoj1JViNh66wzyxwW5dCuMVxe8kZRD7YFzoEwu2jmYWxNZkuAy96eJnpSqyGDfcVQEm 3QirA1/jc2R5n+D20gIxGamTCb9M1ATHwmZWrPPwd2a7feof0qHGEzu0ul3L6y88YE6m hr9YSsD0zjDL75vhbqibmqsUjFb0cqFuRuiH1e7TiAjB0Sk1o6TN3l4BokE8pHpgb8C2 TyGJm721vHUc85IMRKJRJTjNAtG1uXQukKO34klWq5NRi4Ya2VjEuJSpa1QnolcL3ALT Qxrg== X-Gm-Message-State: AKwxytfjuvZKISK2EoHAfW+ZrDsJ4SXXbRxAiaF9Va9jgtQxHsGrzzxM TCUzB5wxb77kZWHOjMamJlfarct7 X-Google-Smtp-Source: AH8x224GXvJ8QFa5zK4bLps6B9DRMYkF7cee3gj0gf3wnIcfFY8rnAM5/MDk5AvetD4VBC9Ir74LGw== X-Received: by 2002:a17:902:62:: with SMTP id 89-v6mr6002679pla.284.1516733558966; Tue, 23 Jan 2018 10:52:38 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1611:da80:8749:c06f:9515]) by smtp.gmail.com with ESMTPSA id 13sm6781971pfk.93.2018.01.23.10.52.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 10:52:38 -0800 (PST) Date: Tue, 23 Jan 2018 10:52:36 -0800 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Simon Budig , Andi Shyti , Lothar =?iso-8859-1?Q?Wa=DFmann?= , Mylene Josserand , linux-kernel@vger.kernel.org Subject: [PATCH] Input: edt-ft5x06 - fix error handling for factory mode on non-M06 Message-ID: <20180123185236.fxjqpnscgx42s5lf@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When attempting enter factory mode on firmware that does not support it, we'd error out, but leave the device with interrupts disabled, and thus touch not working. Fix it by moving the check before we disable interrupts/allocate memory for debug buffers. Fixes: fd335ab04b3f ("Input: edt-ft5x06 - add support for M09 firmware version") Signed-off-by: Dmitry Torokhov Reviewed-by: Andi Shyti --- drivers/input/touchscreen/edt-ft5x06.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index c53a3d7239e72..1e18ca0d1b4e1 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -511,6 +511,12 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) int ret; int error; + if (tsdata->version != EDT_M06) { + dev_err(&client->dev, + "No factory mode support for non-M06 devices\n"); + return -EINVAL; + } + disable_irq(client->irq); if (!tsdata->raw_buffer) { @@ -524,9 +530,6 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) } /* mode register is 0x3c when in the work mode */ - if (tsdata->version != EDT_M06) - goto m09_out; - error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03); if (error) { dev_err(&client->dev, @@ -559,11 +562,6 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) enable_irq(client->irq); return error; - -m09_out: - dev_err(&client->dev, "No factory mode support for M09/M12/GENERIC_FT\n"); - return -EINVAL; - } static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)