From patchwork Tue May 9 00:45:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9716901 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 4EF5160385 for ; Tue, 9 May 2017 00:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 362CE269DA for ; Tue, 9 May 2017 00:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 292CA282E8; Tue, 9 May 2017 00:46:00 +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 D1FCC269DA for ; Tue, 9 May 2017 00:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752984AbdEIAp6 (ORCPT ); Mon, 8 May 2017 20:45:58 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35372 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586AbdEIAp5 (ORCPT ); Mon, 8 May 2017 20:45:57 -0400 Received: by mail-pf0-f194.google.com with SMTP id u26so11706785pfd.2; Mon, 08 May 2017 17:45:57 -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=6pE0KhrFKO3T63qJPGZPbeHAQaXjjCdmCW274t9Nr0A=; b=mmlHLDmut873rplID5eoanu25S4XUcpQp+mfKVZ/8V3IhBQYgEnHwCQmdDmc5g4vSa /AVb+Fb7ykkEMJjEishfxuBeDJUin0xzLf5R1wxPSqdrxP0gGzydyno7tQiXL6u5bUG7 vKd0vpijGMmI5x6UKwd+KxMGZ995KXRQlsDzeJvRpmOgFv2DAWcdNA8AmczLN4/dYJKj vmjGmD3X+xoH53lSyp4MpZQzN1g34LZf7ZfJ6IrtEHU93LKyXDXx3f2HrVXdmzUy/+Yo W8ZI/TVg3uUYVFiD+2tGWfLxafoY8NWI7VbAhHV9wAYal5f98r+KAhiw64zS98Sl1zeq oiew== 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=6pE0KhrFKO3T63qJPGZPbeHAQaXjjCdmCW274t9Nr0A=; b=K8swMrp8jzBsQdgrQozQSmu+zAotxoyHI68Fg99/TW3ZaeOsutud2z/SYQM10qceOi XN6KauW75Vk7L0HnHH7czQUdk3Oqd5tccptg3JZadc1vBiMTvFsjHfoPpcnDow86uoZr ObecPfV8lqvfSGEWzafiopMhVtcbldU4kBresHKCC3iBQlTSDnNzzoR+F6Do1aE3JZ/T wBqZ2LahP5q7R7jNVzI4nPS/wozfPbpc41GB4eI+IO0FsKt/SjkxRDWgggBrjdCcHnyO 6VRdK5VvuOhjYXc1NBSR5qohed8IHH0DJZ5Vw4Chgmg5DdumdvjF4xgZCjQ2MgAjZ3S2 YIWg== X-Gm-Message-State: AODbwcA2i9lHdPjYZFtcCDKHRVb9gw5L8s1BWeBaxvaxQCtc6X+EC/m4 DgcmqGvv15s+/g== X-Received: by 10.84.216.30 with SMTP id m30mr2925551pli.65.1494290756846; Mon, 08 May 2017 17:45:56 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:50ea:e8ed:86d6:e48b]) by smtp.gmail.com with ESMTPSA id g71sm25943881pfc.41.2017.05.08.17.45.55 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 08 May 2017 17:45:56 -0700 (PDT) Date: Mon, 8 May 2017 17:45:53 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: KT Liao , Benjamin Tissoires , Guenter Roeck , linux-kernel@vger.kernel.org Subject: [PATCH v2] Input: elan_i2c - check if device is there before really probing Message-ID: <20170509004553.GA21295@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 Reviewed-by: Guenter Roeck --- v2: switched over to i2c_smbus_read_byte() as Guenter suggested drivers/input/mouse/elan_i2c_core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 5d3b53dd2fa2..3b616cb7c67f 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -1091,6 +1091,13 @@ static int elan_probe(struct i2c_client *client, return error; } + /* Make sure there is something at this address */ + error = i2c_smbus_read_byte(client); + if (error < 0) { + dev_dbg(&client->dev, "nothing at this address: %d\n", error); + return -ENXIO; + } + /* Initialize the touchpad. */ error = elan_initialize(data); if (error)