Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2903622lqt; Tue, 23 Apr 2024 05:26:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUTXNogyFISntAv+tELhC5I2/3543f47pr7jyyxKbdtsB2+Nm6zxx5FCPk7ECvg+nUb6ltt1/k9e00cyhk72ttD0qwmOUtYPHoZ7IUllQ== X-Google-Smtp-Source: AGHT+IG4VqXaFFw/pFW2okG4obT4F045rDAONh0n7ETCRtx9jzf4Bcib7oE7bvsQAcI2xI3Cgp9E X-Received: by 2002:a17:906:a8f:b0:a58:8662:1f06 with SMTP id y15-20020a1709060a8f00b00a5886621f06mr341070ejf.56.1713875182680; Tue, 23 Apr 2024 05:26:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713875182; cv=pass; d=google.com; s=arc-20160816; b=hRz6P+hqqU+Z+gHFAgeOOV/RfOrvMAZLUsmuQViL+c0Xeu8RGK4CXbbHDa+ZYQcsJc VzPHvxFtLcpsVu2zlxKR+Lp8uBDa+/8vSOsd4knFsEanVMHgo1SI4Sk7w9YLsERBlbyT cIZcHZaQ5kQJfpM4mD2qzKg2HJFjQnblIENAaVvW61gwkGLngCcyEIqQgzmUWvmp6VsZ YBGvRD3p1bXsZnyzvwJoAxgyFDrce25g0s0sJ8OojcTZp66ZwCFc5viT3mnJ81IqM8nv 7bkW53kW/nN2fOcwmptK4Pe90knWXvT4D4a5QX0dISEwJPcMtNeljsnf/D7ncfWSLZzW uEVw== 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=sIcRg07SbC9eGobnCDGhujuOpvRi91tn7rJ0+VCmsCYBn4UNrG7OkdKdoEwOGVzVLL 8tqkG47oU0UAB3Ejx/+foft381iNAzo9+hvbtbF6BbtWolmgCgEeuKhW0ybJMlBd0tGO UHB6fUuEQRwP2axE8/0qi9yaU2FlhkAV3EW/mXhdnNjdqoCNW55c26FWefosGyXH63sa lPvnDa15oWCrisEnr/eMHt8L/yefrz/bDtuj6VUIjhDhLMz2bx+nu/HAkOKRrgom/c1n OYU2X4R6OzlgYJ3Z8GnEFitZ4r9KdtJoyEG4Y+aiODlGbgzE7EzKVqtC2ySde6MEAOLe 47JA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=AcWl+9di; 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-155157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155157-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kl.wtf Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j8-20020a170906474800b00a5250fbded8si6984838ejs.74.2024.04.23.05.26.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=AcWl+9di; 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-155157-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155157-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 54E411F22594 for ; Tue, 23 Apr 2024 12:26:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BBAF86242; Tue, 23 Apr 2024 12:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b="AcWl+9di" Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) (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 3A64184E02 for ; Tue, 23 Apr 2024 12:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875170; cv=none; b=SE1ixCevHrr2NqFexW5Ww4umdg5qi2lYPb78OcWp7/iWXGr8xjRumUIbCGXnJX4YCWfelvRWE68grfyAkvEDfk915GpT30g0Ot0YexNqxKT9OaoYv2K0c+vAigmc1d/OhlaOQI5UhV9RUt2vHMdlGlGGgRs3o+QYRLsjntE6BhU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875170; c=relaxed/simple; bh=TyJU+YaqvfJsyrWAilPAS5rTdJU0SPQM2vyBu+LTUow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZERZguxyFgd5ph6bgUYA9ccTC6n8dV3pX71drHZW1UzQWf5p+rm8pPpBMlDyQFHSCZH/fF35RF9Tgf3leV+bznRnmHDTJZUo7OlgC8tUNaYWKqqAMx7INaHBk4k9RUSifDANoHMaoTxxhY6mdyTzxo/OQaIkfbf/nFZkzFkCOA= 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=AcWl+9di; arc=none smtp.client-ip=95.215.58.185 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=1713875166; 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=AcWl+9diIvh59/Ir5rOQf+TnonxuDVZNGbTEQfnN4dbHnIBR9GOZfT1q7mZu8EwY3yRsS9 08Shxp4MXzA+SbL1+MDGMM6ZXycyzp5SdyvL4K9tw2JgiVuY85XgtRFcFPpF0zRyks5J8L Q0gd3Co9+aJnkA01AfQLUkNOvCsgsIf6ApcIOiGW8VQMa/XGzNfFkq6pzG8i8uZz6NVQUY CB80cjdCtn8R39toCXqyo0n3OS7albhUI4lF9BawvjoEauKJbI2NS1RocuofVTALCMtLSS 1wqzEKQPx/RRIZRi7VrZK8HY833qrCf/pEsxSsrme6j2pIFUaYkNW0e6g0+W6Q== 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 v2 1/3] HID: i2c-hid: Rely on HID descriptor fetch to probe Date: Tue, 23 Apr 2024 14:07:53 +0200 Message-ID: <20240423122518.34811-2-kl@kl.wtf> In-Reply-To: <20240423122518.34811-1-kl@kl.wtf> References: <20240423122518.34811-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