Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4042682imm; Mon, 14 May 2018 01:31:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo1xS3s/nIVwNt4HHEDWVUQsSL3H1f6NOu0VbG0wgNrvUi3MLU31izkgiWwA7KRmC0NS8lj X-Received: by 2002:a62:c15:: with SMTP id u21-v6mr9481788pfi.218.1526286712852; Mon, 14 May 2018 01:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526286712; cv=none; d=google.com; s=arc-20160816; b=TcUrF3p9/5ZlKL/BfeylIR1bjwjme5HMttmPUNIFhB6vGO8AudXT4QnvPiBjkHHGE1 Lnikp8WvwNxmpExxs2jwrGn4GP84pOwAbY9nZAdd4n7FufHhoTwamuHw3UmzRgX6U7TB +w+B4snkqsr9rFLtN9Rbq8HphQTuWJQt9Ar5KDsEZcoGoFqb2KiAXQnE+w+WfzXxVIdx Rd+EPpOFJ1FXCQ/ZMHPoKWl2YtWC/1RKFTEeB7tyyBynHqftVNhNx+bNWj5s1EGaBIw9 tD8MYainrxD2TU3bfIrDaMmM6BXZu7g0H30u5eUI0ecb4GYpO64kT2eipTye+4O1jUJs /RRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=4uAQUQ4aAV8iBXcdbjblbaqjlOSLFXRtBzw0MFqZaiw=; b=uJzO3X4LbbB1203Coqq2P57075y7VbNfgjfBL3S3P+5h5SZln8A4EiiF4gDEDR4AUE L9qLO4aGZGeF+iIkyJxvvdlCUe3Jo19gGs1IEbBIen4m0G/YbIPA7JGpWjt146QWUu4d 9hoAdXt6IFSWheziNLtwyISVGx4k/lEGx/40jd3+IowvRV5ZJn/dkJ5INFycKWmUPWOj lbv5IpE27d5fmw5Q0F9EI7NgY1E0yhJ3iyCM9rWrLQxWFoRy5cMKQ3CkyFXYUwNei1cp iaCDHpGps9i4jrIsjIaNkZbcoKWqZkORZnaNc2eajTcQzSnWkH62+olvlUhc7SePAwWu SYcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc2-v6si8821845plb.43.2018.05.14.01.31.37; Mon, 14 May 2018 01:31:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbeENIaA (ORCPT + 99 others); Mon, 14 May 2018 04:30:00 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:35106 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbeENI36 (ORCPT ); Mon, 14 May 2018 04:29:58 -0400 Received: by mail-qk0-f196.google.com with SMTP id c137-v6so9292177qkg.2 for ; Mon, 14 May 2018 01:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4uAQUQ4aAV8iBXcdbjblbaqjlOSLFXRtBzw0MFqZaiw=; b=dw5WOnVtGi/BWvJgOtNCltYLt3SFqhiJc//KPGqfue0wT2Ra1jkFIxS9m3qPhHp83O 0C+Akk+N59MXsfZpNdvPdcIX9GemQCgWIW8d2ZbOdH70gAoYesqEct5OKOwv1HGu8URK +B2TeWpPO1astiDQXU2BgPHYqtBkcfX9kmfDkRURd+2fHCZ5p91R1qCFYTJH+tyiuWMu oxqBYHn4tWgaN3931gRMV1nF5ecXQVJOcuPsmVMK2DNwMF+bxuwx+iKLF+FPEMP/+aHZ XSjqR3x0UJnx1Zx1MOoI9Gx6yWI9ZnZzN3nW0hoIagtwTF+07VYVsJ0/SgYSE64fog6K rrPw== X-Gm-Message-State: ALKqPwfUH4dqUup/uUyro+T8YBTGxhsdFzDI1nRAazRJv3EaV6t47Vdo mSV0J6T8JtmjdHQASl4Xs5ZLkhRZLDc72AIp3Bn9GQ== X-Received: by 2002:a37:c918:: with SMTP id q24-v6mr7719169qki.146.1526286597447; Mon, 14 May 2018 01:29:57 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:1683:0:0:0:0:0 with HTTP; Mon, 14 May 2018 01:29:56 -0700 (PDT) In-Reply-To: <20180509191215.77406-1-dmitry.torokhov@gmail.com> References: <20180509191215.77406-1-dmitry.torokhov@gmail.com> From: Benjamin Tissoires Date: Mon, 14 May 2018 10:29:56 +0200 Message-ID: Subject: Re: [PATCH] HID: i2c-hid: check if device is there before really probing To: Dmitry Torokhov Cc: Jiri Kosina , "open list:HID CORE LAYER" , lkml , Brian Norris , Douglas Anderson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 9, 2018 at 9:12 PM, Dmitry Torokhov wrote: > From: Dmitry Torokhov > > On many Chromebooks touch devices are multi-sourced; the components are > electrically compatible and one can be freely swapped for another without > changing the OS image or firmware. > > To avoid bunch of scary messages when device is not actually present in the > system let's try testing basic communication with it and if there is no > response terminate probe early with -ENXIO. > > Signed-off-by: Dmitry Torokhov > --- Looks good. Tested on a Dell XPS with an i2c-hid touchpad: Reviewed-by: Benjamin Tissoires Cheers, Benjamin > drivers/hid/i2c-hid/i2c-hid.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c > index 7230243b94d30..a59d483ff316a 100644 > --- a/drivers/hid/i2c-hid/i2c-hid.c > +++ b/drivers/hid/i2c-hid/i2c-hid.c > @@ -1048,6 +1048,14 @@ static int i2c_hid_probe(struct i2c_client *client, > pm_runtime_enable(&client->dev); > device_enable_async_suspend(&client->dev); > > + /* Make sure there is something at this address */ > + ret = i2c_smbus_read_byte(client); > + if (ret < 0) { > + dev_dbg(&client->dev, "nothing at this address: %d\n", ret); > + ret = -ENXIO; > + goto err_pm; > + } > + > ret = i2c_hid_fetch_hid_descriptor(ihid); > if (ret < 0) > goto err_pm; > -- > 2.17.0.441.gb46fe60e1d-goog >