From patchwork Mon Mar 27 05:48:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9645307 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 6811A602D6 for ; Mon, 27 Mar 2017 05:49:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 573842815E for ; Mon, 27 Mar 2017 05:49:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 433F227F07; Mon, 27 Mar 2017 05:49:16 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 DF799281B7 for ; Mon, 27 Mar 2017 05:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914AbdC0FtF (ORCPT ); Mon, 27 Mar 2017 01:49:05 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35714 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034AbdC0Fst (ORCPT ); Mon, 27 Mar 2017 01:48:49 -0400 Received: by mail-pg0-f66.google.com with SMTP id g2so9877716pge.2; Sun, 26 Mar 2017 22:48:48 -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 :user-agent; bh=KRP1hiWH1VIHoMvVlX6W4DinriG4NKS2yly2ytejGLg=; b=RLdR7nBIufjuigThhwvlFSFZzDAmHjmyDgUpGoFrUZ9rEAI1s7ZSSid1jjpCa6E76a GXuQzcn0fXiWY1lSSz1DLFdMxbxoEvQtjdF49TB6BtP9WufH2GqRvS7wi6+exZSw+ULI T1uDWo8xcF+fSnuRFxBCKz0uxa8MUzKvfjDvgSOxSSadxTMT7jA4375wh1obXZfsR43S Y7jITDy5ZxBDhSd0QNcZE7KpK3mgW2r3a+ZpSjnzgcv3EH1HE5qd1MhrJATPWxHPLfdq 8FWx+oADGHDTgfRZcxDvgXFBgRF9HuJb4PMAxIU45nMFhYbNP+AubbpI05G/v5gHg6if /itQ== 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=KRP1hiWH1VIHoMvVlX6W4DinriG4NKS2yly2ytejGLg=; b=B0uvIhRLnNvuxOrDHwhRFjG0wyhAXCsXG7pe65Dyp8gFet0zhQUJGlQeIap8YJlHuh nr1AxfKuq9rr+79Hsr7ZrKAIR4X98AAiCpY5nzSl/wtCOfj1RVZ327UDkZ1ABho2kQ7I 0s/LV9OPc3ml+23NbDrZv2j5QSIoPdb3o8PZgis4uep5YtxibWdit1MXWGRV0BKttEyC aFr6O/7MCaKVXVsz24vmGqfk0BosNWekc9PAZEJOWEKAftvbxgwWQKlbPlQjleyCBXAb O5nsGfdpHmIkFj53hxdUA7hq54wjzEoCk4y060tKqIAg7H97+KRGXPq1A2TNfyIesaAx E5Ug== X-Gm-Message-State: AFeK/H0ci1P1VeXZ+OdStIfCHXgiTxMonoeCqRWwikOAE9V28naRJ8qkDTYq/5776o2Slw== X-Received: by 10.98.217.140 with SMTP id b12mr23434032pfl.136.1490593727561; Sun, 26 Mar 2017 22:48:47 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:58e5:a83e:b3b6:3175]) by smtp.gmail.com with ESMTPSA id b70sm18064095pfc.100.2017.03.26.22.48.46 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 26 Mar 2017 22:48:46 -0700 (PDT) Date: Sun, 26 Mar 2017 22:48:44 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Sangwon Jee , djkurtz@chromium.org, milton.chiang@mediatek.com, linux-kernel@vger.kernel.org Subject: [PATCH] Input: melfas_mip4 - ensure that device is present Message-ID: <20170327054844.GA35471@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Try a quick read from the device in mip4_query_device() to make sure that the device is there, as we do not consider failures to retrieve product name or resolution fatal. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/melfas_mip4.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 703d7f983d0a..05108c2fea93 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -253,10 +253,21 @@ static int mip4_get_fw_version(struct mip4_ts *ts) */ static int mip4_query_device(struct mip4_ts *ts) { + union i2c_smbus_data dummy; int error; u8 cmd[2]; u8 buf[14]; + /* + * Make sure there is something at this address as we do not + * consider subsequent failures as fatal. + */ + if (i2c_smbus_xfer(ts->client->adapter, ts->client->addr, + 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) { + dev_err(&ts->client->dev, "nothing at this address\n"); + return -ENXIO; + } + /* Product name */ cmd[0] = MIP4_R0_INFO; cmd[1] = MIP4_R1_INFO_PRODUCT_NAME;