From patchwork Thu May 4 06:29:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9710825 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 B91D260235 for ; Thu, 4 May 2017 06:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA89228616 for ; Thu, 4 May 2017 06:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E0BE2861C; Thu, 4 May 2017 06:29:54 +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 4E8F928616 for ; Thu, 4 May 2017 06:29:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932093AbdEDG3x (ORCPT ); Thu, 4 May 2017 02:29:53 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34723 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932087AbdEDG3v (ORCPT ); Thu, 4 May 2017 02:29:51 -0400 Received: by mail-pg0-f68.google.com with SMTP id t7so919015pgt.1; Wed, 03 May 2017 23:29:46 -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=yDcic0jYXbn9uGKadRj2h0jVB3vp1lLOdDtdPv20m8M=; b=VvR5gRjJvneZsK1aHBJtrdcxfmox+uBLaWp85mWPfxSFXSNhiOK9OkvgchtIQtl1HS CklZPKgMp8iJ3c8kUNnFKEHP9Zc4A3mBCe/Fd2SG4oDBLD1QArbgENgHTeKBS+on/gqh Rq26tQaADva3Q7B1ioWijdiu4ACw6BP4Q8VjOhEITJbV8moQTZoKiFScv2cYrWNYkC8u W+4kkPfnwMxSHpQo7FSDxHoHSCzxXhF9lUJLZE+t5s/5g0dr1Ufd2+mu59DlCc+dDYzg 8YDlWTTeyQVRm7VKF5n3GA86MrfdnxJxoFlhfKwIDgf+ZIbQmui+sfBKC7aoBEQ4IBql 7elA== 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=yDcic0jYXbn9uGKadRj2h0jVB3vp1lLOdDtdPv20m8M=; b=YmBcTO7xtMOTydop60GiUfZKRFkDj65SAK8hXeVvrOFS6vAMc6GrS7uLsoAR548npS Dv5tphMANknxFW/Ra/3Iue2TU98wn5cGp4mbwLTYPSXPrdmE1ogCIa6NwrEJBPTeq1SU fNQby7XO1dLunoa42yLrLP5hJe33CW3sXqT+NwhR8mlUM6kle9A6d6X6+A1OgE2nZ1n7 h3tSbifYQ4Se88ZGSh5eJdgW3LEWDOklDCiX/YHy2BX7h11XeAOJT64TXn5M1xtJspw2 Twh2AWfW36sS3qk1TFjX/8ch1p+7YXe8zTsoaWgJ2W76KWPPd1zsN3aNFoT1oRcVYqsn Hmfg== X-Gm-Message-State: AN3rC/4e6LmwYnZkbPnahUTdeqAJDgvhkAKpcK2hMkJJLj7/Qc1CL1N4 UmZ3b2gGOESjUA== X-Received: by 10.84.215.15 with SMTP id k15mr13107186pli.104.1493879381213; Wed, 03 May 2017 23:29:41 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:55f0:633e:79b3:8340]) by smtp.gmail.com with ESMTPSA id d76sm1842794pfj.68.2017.05.03.23.29.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 03 May 2017 23:29:40 -0700 (PDT) Date: Wed, 3 May 2017 23:29:38 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: KT Liao , Guenter Roeck , linux-kernel@vger.kernel.org Subject: [PATCH] Input: elan_i2c - check if device is there before really probing Message-ID: <20170504062938.GA30771@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 Before trying to properly initialize the touchpad and generate bunch of errors, let's first see it there is anything at the given address. If we get error, fail silently with -ENXIO. Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/elan_i2c_core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 5d3b53dd2fa2..0479730e7c5c 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -1040,6 +1040,7 @@ static int elan_probe(struct i2c_client *client, const struct elan_transport_ops *transport_ops; struct device *dev = &client->dev; struct elan_tp_data *data; + union i2c_smbus_data dummy; unsigned long irqflags; int error; @@ -1091,6 +1092,14 @@ static int elan_probe(struct i2c_client *client, return error; } + /* Make sure there is something at this address */ + error = i2c_smbus_xfer(client->adapter, client->addr, 0, + I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy); + if (error) { + dev_dbg(&client->dev, "nothing at this address: %d\n", error); + return -ENXIO; + } + /* Initialize the touchpad. */ error = elan_initialize(data); if (error)