Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp95550lqa; Fri, 26 Apr 2024 15:58:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmM3yVlvVI64jf5U7Wd4m7Abr+gAHuQhqQThNrJyNp4zXsOEPTUuQPtWD6nALErFzVk1Sw1+NUl+A6i0GxuLfWZ0xhVFatfOgrz/pv8w== X-Google-Smtp-Source: AGHT+IETBCuarXZxPqCa5j5Xj3mFYbnduBjLmswN6KJEAVVNWfm4b6X4dUcuY7Z78kCgtIfDmzne X-Received: by 2002:a17:90a:69a1:b0:2ac:513b:b314 with SMTP id s30-20020a17090a69a100b002ac513bb314mr4244835pjj.1.1714172306474; Fri, 26 Apr 2024 15:58:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714172306; cv=pass; d=google.com; s=arc-20160816; b=Uhk4qOglZT9iOijOWaDqMo473gyTCveTtlKQTI6YpNiqSyWtsUkSnw74DkgruJ6my8 R239h7xN1cz63IfnmPwO61uLKMnkDVC7IhNLKG6jlZJrwGZBm0IVUZTZQMzij5nKLlHa Z51TxU/yh+elTk1Q22nKRqlYyx1d9NmUxaJ8DXgDwll/gzMF8w9M9BN0nXYtvQx6VvXt OGutU8MizH3VWKTUfMb4HcbVV3yKc4cocE1MCEBTkuWQHO3pTEHOWEs1uwn2sRzeRSC+ Fi3pFgKwq/NVfmGEn5LzdfADeFWOu8Mx+B1ID4wk1DtjJoU61Uy966Gc2Aepe8zHiFzX JIDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7SXRaVoQrN/XQKemgL4uLkkyAHkvGBUXAQSxAzF5ceM=; fh=Mm8hlFdBHUY0fyqKU/MWlqkizWEw7qYBWD0xRewgNf0=; b=SK/Eu7rGbNuxUx9fMIZCb4/txohmuiumEJ0s04mqjhH45uSdCuIp8h/JY/4rHBB/M2 Nwb/DSMMbXjL3rqAm9HI93iKiBH3GbcXIQPfiw9wlwRqW9HblLhc/p2Iq22OXVb2+y33 IEWiUubTWbwnR4xVbJ8ibUdE+MUdAIRnEOuj2SqVcJoQVstUyAqWviVCNIsF43FC9IFR p7kF6Rm2VsX2Jo9iwW+er33NJwcmPrewpyCMHD6ylblNjS7J5f7NaZ2bzWKE93P5Q+yO sg5x0w/MaVPFa3KJ5z49k2LxpHXcBeZPCnx0byd0VHTSD1ztQ9XhVuQKlP4yepbm4px6 RJMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=RYZd9Zxo; arc=pass (i=1 spf=pass spfdomain=kl.wtf dkim=pass dkdomain=kl.wtf dmarc=pass fromdomain=kl.wtf); spf=pass (google.com: domain of linux-kernel+bounces-160756-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kl.wtf Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f5-20020a17090aa78500b002abe1800a99si15461393pjq.74.2024.04.26.15.58.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 15:58:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160756-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=RYZd9Zxo; arc=pass (i=1 spf=pass spfdomain=kl.wtf dkim=pass dkdomain=kl.wtf dmarc=pass fromdomain=kl.wtf); spf=pass (google.com: domain of linux-kernel+bounces-160756-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kl.wtf Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5F8EBB21F1C for ; Fri, 26 Apr 2024 22:58:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2ACAF3BBE6; Fri, 26 Apr 2024 22:58:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b="RYZd9Zxo" Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68C1D3987D for ; Fri, 26 Apr 2024 22:57:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714172279; cv=none; b=kVVqSzfSBrdpQi2tCOZCdiVl6L+sZCA716r6kFKBr5gTIXC3e6pDC+0rfTAmRf+djy0s1mhmig026ZpNrjlW4CW5K4jAEDZJH6kM2UKGSVhsFmViYTgSwwfM5Ud/fbl4qJwz90ah43UQ8Vv83Wg0enYjcnudxVcvus9Vupz9Q6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714172279; c=relaxed/simple; bh=bmGxBMb81JYd9eJGESmHcK3CwPvy/AwmJGpMgmU9o2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OTJmkEydr7r37qQAjuv5xgv5KKreECVjV9K1ZqM/juZ198kdkBrrDzPmLFzfQU4CWXMXJfW8lsRBnhP6iI5Y02sXmiCeG6P8aHiNMYfuiWCMmAk1lNMaZ7ug4N9AV3E+17T2Ud2hPZTPOM47Z/OzISRmRvmDUZinkfl495Mn0V0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kl.wtf; spf=pass smtp.mailfrom=kl.wtf; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b=RYZd9Zxo; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kl.wtf Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kl.wtf X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kl.wtf; s=key1; t=1714172275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SXRaVoQrN/XQKemgL4uLkkyAHkvGBUXAQSxAzF5ceM=; b=RYZd9ZxoUP/vsNRSnoVMy0oEicyeddd/AkpJaaufnVB6kHdY6p1HJu/+AViwPfVDSWe2OS qTys5Nsel+rb7n9QeVjXfPsCtOatVvY7aGzf3BpHs7wdBwDMgwihn9O7Gef4D7FgdVOqwr wqfwLbGQOjS5W2TRZLvvzUJaCS/Nm5kGcShoLULJV8ahkebSFZBClnPX6w+Tiu3iiotpVW k7V2N93qk6659A0WXxyOk/gqzdp8PRBjUfzEp3roOpfSN0vxxxYWcfVEbfm+/7HU0gbVcQ CZ1MRvJSbuLqNQvFyAjVcowytTBsFXoUhwaCH2s+LROJS8L08WRrwMTqa3VGzw== From: Kenny Levinsen To: Jiri Kosina , Dmitry Torokhov , Benjamin Tissoires , Douglas Anderson , Hans de Goede , Maxime Ripard , Kai-Heng Feng , Johan Hovold , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Radoslaw Biernacki , Lukasz Majczak Cc: Kenny Levinsen Subject: [PATCH v3 1/3] HID: i2c-hid: Rely on HID descriptor fetch to probe Date: Sat, 27 Apr 2024 00:47:07 +0200 Message-ID: <20240426225739.2166-2-kl@kl.wtf> In-Reply-To: <20240426225739.2166-1-kl@kl.wtf> References: <20240426225739.2166-1-kl@kl.wtf> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT To avoid error messages when a device is not present, b3a81b6c4fc6 added an initial bus probe using a dummy i2c_smbus_read_byte() call. Without this probe, i2c_hid_fetch_hid_descriptor() will fail internally on a bus error and log. Treat the bus error as a missing device and remove the error log so we can do away with the probe. Tested-by: Lukasz Majczak Reviewed-by: Lukasz Majczak Signed-off-by: Kenny Levinsen --- drivers/hid/i2c-hid/i2c-hid-core.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index d965382196c6..6ffa43d245b4 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -872,12 +872,11 @@ static int i2c_hid_fetch_hid_descriptor(struct i2c_hid *ihid) ihid->wHIDDescRegister, &ihid->hdesc, sizeof(ihid->hdesc)); - if (error) { - dev_err(&ihid->client->dev, - "failed to fetch HID descriptor: %d\n", - error); - return -ENODEV; - } + + /* The i2c drivers are a bit inconsistent with their error + * codes, so treat everything as -ENXIO for now. */ + if (error) + return -ENXIO; } /* Validate the length of HID descriptor, the 4 first bytes: @@ -992,17 +991,9 @@ static int __i2c_hid_core_probe(struct i2c_hid *ihid) struct hid_device *hid = ihid->hid; int ret; - /* Make sure there is something at this address */ - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret); - return -ENXIO; - } - ret = i2c_hid_fetch_hid_descriptor(ihid); if (ret < 0) { - dev_err(&client->dev, - "Failed to fetch the HID Descriptor\n"); + i2c_hid_dbg(ihid, "failed to fetch HID descriptor: %d\n", ret); return ret; } -- 2.44.0