Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2904207lqt; Tue, 23 Apr 2024 05:27:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzlZbKdvPOrWOjLVqoDSeidygs2Ee8rNi4LRrA9QQphBNzIn3/0abGTI/Oh7dFqIIzfYqLiav8cH438QLIzSk77FvUfJor+wJImyXy9A== X-Google-Smtp-Source: AGHT+IFalXqhZkNeoo3hwiTtvM+o16BuRdvoIRFs9tBDRWDMrqLEhylGAZEc9FKlE5rdIlheuiE/ X-Received: by 2002:a17:903:2346:b0:1e3:c327:35e4 with SMTP id c6-20020a170903234600b001e3c32735e4mr3364581plh.5.1713875248462; Tue, 23 Apr 2024 05:27:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713875248; cv=pass; d=google.com; s=arc-20160816; b=cpRSKApDB91Z+H/nM7JeXMTwaHUEDmnGjpB0U/Kcr76elmDuojM5lrracyYXg2lO34 hhRYck0GJXPOU73xVzjhjKdynYA0HybXe2EYJDPDxXEgZCWar//gYG1GoBWUJM3zGKWw Mqg3SuOAXYkbgvLySu8mfYzM7VLEwq3nw5RTT2ctJQQ4yAFX4/aAdlYHd3ZAESZz41x4 7sRCKSVGTYUifTQCbbxiHhyf1fVqNxO4mY9Qbg2wcOsSoCFe9hzRlCrd0QpBulpqRLvW DbX5ZVH6kzieEaMb4hSGA9gOIUlSbHfa+6TV1oDc3XhDLULq3aqCg3MMVFAw7vJ2DCPm 1dNQ== 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=WYMVR/H/8GVmViImqt+rKjHX+PeAvfbdfXWhlI89GyM=; fh=Mm8hlFdBHUY0fyqKU/MWlqkizWEw7qYBWD0xRewgNf0=; b=Oy0xwHT9FG0W5qxJMmfeMhkDuhXPNnS0r0WYgaaFdUBU7ZoELECIUdb1MsAbOQWj4K 1cK3rmvIV2xLj7daz7eVkA18gVdHK5gbWVo3ldSRIelYxv/0CfnIItedWVV46I5theW+ zl/CYOfbrdLqIU9kOWlWQ3x13CIDdVWK6DAVnIrWTyWoZ0dfBb/GvBQTgOfMMYpJu01q 07KaU3xW4bSYDFVFDNsxfhGKNHhwNqLDs1bgzjnGnKI3QhxnIujfOQ27VmbguFh2HdaS 2Go2HqaAc1nb1gher/Zh30qafM/GoagHS+thE0FVINjvGkdJUm3NYv/j4li916ChqnmB mVGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b="pB68De/h"; 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-155159-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155159-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kl.wtf Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k9-20020a170902c40900b001e3c6c51673si9577540plk.307.2024.04.23.05.27.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155159-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b="pB68De/h"; 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-155159-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155159-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E2368284E77 for ; Tue, 23 Apr 2024 12:26:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8564127E12; 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="pB68De/h" Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 6A9A884FD9 for ; Tue, 23 Apr 2024 12:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875170; cv=none; b=GpLCFw2Y6mCJeLbxPYna7vaHjOcPAtc+hhidPGn1EyE29gMwWyfsbjE4R/gODMdB6V2AKJnfqjxsR2rL5+W5NrkYUfSSuKNNyY8dvhHPcXcy4yo4QfWLqt/sh2GCxvT2zjXA1E7nFAhNuaVYKdCWV5nU1aJx7wyS5HmnG7dM9PM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875170; c=relaxed/simple; bh=dqEhvtsQA/KnqwaWloiCB5LQGWxBUcBJsyA+qcy7+RE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pxNOWZXOjh8+ALkXahCGmWJchW8ic0wQ5YXlVdtNcXCaKjMMlwNG8HCNZ2Z+ZYodHCSeZ0R63tR4JToNwlQQdQ3GlF6yOLPDh06DMU65UgNIAougaXKBZo8PwNPZrHepLoImk8ZiLfQz4mjf2KMu5lxQOjWm44P2ITYdTfKBozk= 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=pB68De/h; arc=none smtp.client-ip=95.215.58.172 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=1713875167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WYMVR/H/8GVmViImqt+rKjHX+PeAvfbdfXWhlI89GyM=; b=pB68De/hJ8iiLC1/E0Uq7rEtsYEuIKtvB9J2TzUbzCeorsSo7n5wmAG7HzHjfBT4xCk95C 2aJv32U/52tynBxdhVwddI5alPtJmh7J3leiDsRX0t7bRgV3R80JFmUyRIaWzkU7vGqNNi b3w8KIn0yKyCl+1YCItZVGREIjWJer96lfulP4xHCsBd89r45LdXtzdGgxCJF+vD4NCpJr iXhL+9F8uCpOzCMeIfF7Rr782gu4WTv1G3So6Cjc9VXpmHhHvnUzMCSI7qvjIvC5Rnm7tu fF7bdKQhq64nU2aVVKiHlrVA7dJeICiFTCYOnkQu+PVF7oWpCIRgV5bGnxst4Q== 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 3/3] HID: i2c-hid: Align i2c_hid_set_power() retry with HID descriptor read Date: Tue, 23 Apr 2024 14:07:55 +0200 Message-ID: <20240423122518.34811-4-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT The retry for HID descriptor and for power commands deals with the same device quirk, so align the two. Signed-off-by: Kenny Levinsen --- drivers/hid/i2c-hid/i2c-hid-core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 252ccb3b71d1..749c0c036adb 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -391,25 +391,21 @@ static int i2c_hid_set_power(struct i2c_hid *ihid, int power_state) i2c_hid_dbg(ihid, "%s\n", __func__); /* - * Some devices require to send a command to wakeup before power on. - * The call will get a return value (EREMOTEIO) but device will be - * triggered and activated. After that, it goes like a normal device. + * Some STM-based devices need 400µs after a rising clock edge to wake + * from deep sleep, which in turn means that our first command will + * fail EREMOTEIO. Certain Weida Tech devices also need this wake-up. + * Retry the command in this case. */ - if (power_state == I2C_HID_PWR_ON) { + ret = i2c_hid_set_power_command(ihid, power_state); + if (ret == -EREMOTEIO && power_state == I2C_HID_PWR_ON) { + usleep_range(400, 500); ret = i2c_hid_set_power_command(ihid, I2C_HID_PWR_ON); - - /* Device was already activated */ - if (!ret) - goto set_pwr_exit; } - ret = i2c_hid_set_power_command(ihid, power_state); if (ret) dev_err(&ihid->client->dev, "failed to change power setting.\n"); -set_pwr_exit: - /* * The HID over I2C specification states that if a DEVICE needs time * after the PWR_ON request, it should utilise CLOCK stretching. -- 2.44.0