Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1577844lqp; Mon, 15 Apr 2024 10:16:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUkT53CUu3VCxgSKMv+QTpaBoO5hU3+sTOoSmROpryWjrzXE/3bY8U1Z3UBwTiilSgU7XR5gSwvEBGxAg3d19+GK64JoCLlJlxTuMFgQ== X-Google-Smtp-Source: AGHT+IGnTRh7dKHWUuUM9kazZ1pIZdejDR+vUnQ21y/PpZUhoJ5ClEUT+EVk66xwY6xhYnAjXQJP X-Received: by 2002:a05:6a00:1820:b0:6ed:1c7:8c60 with SMTP id y32-20020a056a00182000b006ed01c78c60mr10950857pfa.16.1713201383442; Mon, 15 Apr 2024 10:16:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713201383; cv=pass; d=google.com; s=arc-20160816; b=eQ+2vtWtbFd8c1x+SA2ZghCIoRXLDfaaJWNgYnAUa7oWtro77aS1sWkOqXJW1QSByQ iXOPdXBwAMzCD42zWHkD1kXU61DylO2nkaAbAfEt3rTSQjLuvAwO4quEzxqPJxRh5gOq X00nBkakEOrUsH3fk+DPc03PDaI/HdiKH63Mz1jV/n/8FC5tN4ekEqU8z3EbtHgzeB0N CAEMpt5tfelinzGJ1iex1sk5QVkl6mkZTFIw5v8jMdyNpPS7sfS6ZmTISBeyvVUuMsbb IyBTh3uFnNLfuYH84MQwmEY7kwN6luGiaxTgAKw4BodegYFc05VVW+NUjSknZQx8+8ra yEHg== 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=Fb/WuZCiCFBxtB3cKvnMCuh+1XORhT3HDmIS6d/Oqgg=; fh=Mm8hlFdBHUY0fyqKU/MWlqkizWEw7qYBWD0xRewgNf0=; b=KgCijuNi5FZ0qn61bpVGs6PBmugRpNb9YPxIHnsi+J4GZ0sTUoDuhLXY3qVEhnqE0f eM0VYi8kmDNEMs91//Agbb/17i7ABZJTKxhjjP+BBOlg1d7HneqxCTh3uAbyUaCh8sFN ld1W69xzvPwdDeXXESzEpHaeZRTBZQWs3+5GidYEV6zE1kklY/32I88tInlJHeiiZbLF y7BqgFEWsGjD65TZYxdzbQBeXmuDlkG3e2gzF3J+8u1tpSn4XaqT0T1p/6b2U2lW5O5Y jh84e3X34pbwEgxMEsjOrpbo2i56T1UfsOR2yqXH9a1uYkwRKfwzIKp3Pcp2cPTNyCkb mu3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=QgL3lZAp; 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-145627-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145627-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 a35-20020a056a001d2300b006ed03fd6ea8si8475010pfx.140.2024.04.15.10.16.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145627-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=QgL3lZAp; 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-145627-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145627-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 D3737B24299 for ; Mon, 15 Apr 2024 17:09:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF60B86AFC; Mon, 15 Apr 2024 17:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b="QgL3lZAp" Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (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 7054682D93 for ; Mon, 15 Apr 2024 17:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200753; cv=none; b=oog3cwzOExb15hAdIopTLtBJ70NS66LqfRjMKRh70Dn/U57kAw7PDgrEfNsm9HVkzjwwKUT0wAjmufX3GgpyTlncIW2xnRg8z+Gvy/zil9f8XGZFNK9ZvY35v17J4BuVQN9t9oWrjyPBbkZENgiiAE1VhrWnRCbdsZ/55609m90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200753; c=relaxed/simple; bh=TyJU+YaqvfJsyrWAilPAS5rTdJU0SPQM2vyBu+LTUow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZSelGNouHcGyoLSdz+36LoQonBSYVDUuuxlNffb7RjONDIu2uovhyj9vhM/4+ChtGAuxt1fukiZjXcp1MdwTBOuz8DSLkycS3Qdq/Gijzlr0mqO4eoHSIqWsAGlgvq3+8qsy80BlEEjjHF22sxD0bO8o2oxhmSthaOs9Asr4Mvk= 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=QgL3lZAp; arc=none smtp.client-ip=95.215.58.187 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=1713200749; 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=Fb/WuZCiCFBxtB3cKvnMCuh+1XORhT3HDmIS6d/Oqgg=; b=QgL3lZApEHhlq3uh8KkxmqpNt7l9RAlXERe2hOzpUhWRTwwckd0haPGoqnNu0JzEuRUU1w 3nNquZW3KA8w2qwOdmf4JJ0U5m9991KnS9Sasm2Abg/nFPFT3Ef2sgSRHQ8JJCjp5pyMFa SM0lXIWx+6gZfzeGV9xu7sk54NZ+no36G319DFeO89Vm3QTxDng4oZNfNvQlHnkhWcX9Q7 jMsL6MVhfj/OR4P6YkUAFM8x9vaz21PHeiSsCIZei42aV6VCwrox2evMcMU0lBZaaXthka 43QWnKN02Eh/r/Z+ijJT5MGnPOebTD5s131xcwekJjDcWOMsUdEpd8PUO0Q3GA== 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 1/3] HID: i2c-hid: Rely on HID descriptor fetch to probe Date: Mon, 15 Apr 2024 19:04:11 +0200 Message-ID: <20240415170517.18780-2-kl@kl.wtf> In-Reply-To: <20240415170517.18780-1-kl@kl.wtf> References: <20240415170517.18780-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 with EREMOTEIO. Propagate the error up so the caller can handle EREMOTEIO gracefully, and remove the probe as it is no longer necessary. Signed-off-by: Kenny Levinsen --- drivers/hid/i2c-hid/i2c-hid-core.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 2df1ab3c31cc..515a80dbf6c7 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -894,12 +894,8 @@ 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; - } + if (error) + return error; } /* Validate the length of HID descriptor, the 4 first bytes: @@ -1014,17 +1010,13 @@ 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) { + ret = i2c_hid_fetch_hid_descriptor(ihid); + if (ret == -EREMOTEIO) { i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret); return -ENXIO; - } - - ret = i2c_hid_fetch_hid_descriptor(ihid); - if (ret < 0) { + } else if (ret < 0) { dev_err(&client->dev, - "Failed to fetch the HID Descriptor\n"); + "failed to fetch HID descriptor: %d\n", ret); return ret; } -- 2.44.0