Received: by 10.192.165.148 with SMTP id m20csp261385imm; Wed, 9 May 2018 12:12:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq7FXvc6GnZNYVnzoKTVgvJxzb45SVACja0+MQdLmqGqI3WLoOWfHPbijz0LPYMyi86anGQ X-Received: by 2002:a63:6016:: with SMTP id u22-v6mr5583551pgb.284.1525893176243; Wed, 09 May 2018 12:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525893176; cv=none; d=google.com; s=arc-20160816; b=rSmInIUdndvfjZUC9N02+yr8l4pB+pQNJaZ1g6ESwBp+I3DwnIX2vzEwV6QwYw9uEh 90lCmmSaBHapQ+vY85N/lJCIjNVuvhxLPOBJFeCYjXS39B9781AhMOYT9nW/iKsWIjkj HnQj/WN/bUE5qaz2KkM7ximjj/fjo5EtSpicJDfjCoMuV7OLNS+sWSiQLwXORg7Zxxgg 4YOpKyKAzgrqjPHF0cRGoWhzGRh7SJMe9Utj0++vkLH87lvFXSZOn3EAWPD0b0lIgJ8E 7Yq5EjiAKsFW052aQrih5aruXRpEbvB5Aae4MKWHF8SKa8MpdRxtgQAjwN5FhcEvtRUU oz/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RVOcdQctINrDeJbZYNxoLr1kIjjntQK9bYrAWPES2QE=; b=O0k2O1k+KQCzQ1sg82zGU/lgzevAp9QPYB0vbgVdxllT7ux1n5tR+NLp0K+js486Aw v3L5h3xdQ0YuhilW0utZ+ewNYy585a14KPWtqlNDbQsV2pOJj+GWE+9DnJvunL4FjuGv tQCHk9CPpNEm1d8u5GtD7V8dLXmFAxbk6RN4IrhRu5YNVQ+DvoxSjkDW878LuM7weJU+ V6h66ub4WJxmMnDKEclfaWzCx9NOry7/AHl9GDRd4dFbaMsJJ2KMufUF7MOC+dx4VoDo MT9WWd6coFATTLXdZMkvc7K99ZTyD8f/ZaIecTwrFn+84RPrp0ndqA+uyxfVSDHuPY7r eDbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WemDNRec; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si27171108pfj.178.2018.05.09.12.12.41; Wed, 09 May 2018 12:12:56 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=WemDNRec; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965177AbeEITMW (ORCPT + 99 others); Wed, 9 May 2018 15:12:22 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38116 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965026AbeEITMU (ORCPT ); Wed, 9 May 2018 15:12:20 -0400 Received: by mail-pg0-f67.google.com with SMTP id n9-v6so23091233pgq.5 for ; Wed, 09 May 2018 12:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RVOcdQctINrDeJbZYNxoLr1kIjjntQK9bYrAWPES2QE=; b=WemDNRecvf/04wYTGAzgtuVVCA/fd/1N5QrRzlXlDo/+VXD0eIEK5UcOWCoLMmqdsk DAXm/GBtmONNmt9E8i5wtp4GB+nbgg6mWyZWgCV3bwZc0roo0MYnr2uVcaDrvXFfKobT LA/l6XHBRfzT9iVm0MdiZPaE8WBEAl+5lxtZzs1VlI9Cm47NjA3Gk0wrlO9wHeFbo1VV uT1kh2XCLERd8kXA9cOLkzOzIEmaM0rMLWLzE4kLKeK7rwZg8I8moc2QePe7LavOpEse xAcuLXIXzLlZI8Bh2QEUgaK/EdEgQWOIyTnbqQrwuoxBhvq7j8r/EcpQREwg/Q6lThtV lw0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RVOcdQctINrDeJbZYNxoLr1kIjjntQK9bYrAWPES2QE=; b=B5W1DJpw3RmIBkzLIOZxmCBb70bgAFW2RMetGuXHBLol4oL0rfsfpKPFaUBOeNHwj4 WBM6OpRRQmIxXcu639/N9HUpH8AvJXYGeapz4v5iuoFD0SuFk1rJ+3mRpX1vU8jVu+sA 8IowysS7o0neY+po880o0EL3c1CXhQoUlDIeSWe93/XjRSoNZuY9YhwMRQ+sz6uKQ9zD xx/cTFhdMSMi6s2wfRTgA9crcBo4Hnwo4MHjGCSHm38P9BkWUILcaNTnbC02hKKsXVJ9 BAs0DEAXG4wPwEbtPs5SLOFI2nmn5juFR3WHFUrp2OpB7DmHce2JVMbVX4Hj2soQY5Rl 6zrg== X-Gm-Message-State: ALQs6tArG4oVIsG+TFcJm04oXPW5U1OicL/g/7qXN3JMkSa+H16Z7HXW cpiplQQgrYUC6tM+R2qZAJ9Jkg== X-Received: by 10.98.238.21 with SMTP id e21mr40621007pfi.203.1525893139548; Wed, 09 May 2018 12:12:19 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id t80sm61421262pfg.0.2018.05.09.12.12.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 12:12:18 -0700 (PDT) From: Dmitry Torokhov X-Google-Original-From: Dmitry Torokhov To: Jiri Kosina Cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Brian Norris , Douglas Anderson Subject: [PATCH] HID: i2c-hid: check if device is there before really probing Date: Wed, 9 May 2018 12:12:15 -0700 Message-Id: <20180509191215.77406-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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