Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp95567lqa; Fri, 26 Apr 2024 15:58:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlDe/c8SRGaoCesZbJXv6lGvj21QkbBz0Kk8/me+mAr2IlFvM2unrkLZ+0sSJuk5x6767yKx7WJQTT3PDSBhGvqRYq/t1XSR4luvCmCg== X-Google-Smtp-Source: AGHT+IGIL0Ge6JwxIuqyh3ifOeMWgEBXsc95ueDOtsPySV498DxG35jf3guBX1G0l7oBf0m/DX8Q X-Received: by 2002:a05:6a20:734a:b0:1ad:8ae:7430 with SMTP id v10-20020a056a20734a00b001ad08ae7430mr5141379pzc.52.1714172311320; Fri, 26 Apr 2024 15:58:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714172311; cv=pass; d=google.com; s=arc-20160816; b=yljJWr/0Bw/Vwv1xUZxEVQeE4zhxac2VYIMhelfk/73ya0HbQObGxd3uplWyeF96aH gisdhS2DgWbHbHT6KWa3IQX8U1tO5QMU88lRZBOCLu0NQS9emLUfMd4hhSBnr8AM2wbf aYLEsTXsxjdvS9eo0YHEn2laa9Pbo9FkZd352SVcy3GXQZsGbXZJTOdNp8vaDqXYBb3r S81LRgZfDJvvaxeGiCArENP48yCWn/O+pxeuu0Z2JtqT0wOLbuwt0jNzSg9jaeRtqyfV 67kN4DpFCTtaVnH4tLPfHXj9Ft4NnNRbNodKHMFS8lcDAiVc1aeMbODlU0p/AQk0Mmcq cIeA== 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=SqC2//5SbqmO7sl0eIyTlpelQ5K5dhBqbZvBw6LmbcE=; fh=Mm8hlFdBHUY0fyqKU/MWlqkizWEw7qYBWD0xRewgNf0=; b=jlWx0TOOZ41j7B1jKS3ZJdgRqWc/4s9K/GeHVpXP1S4asGsc3vwzawBhUDXpMh1lqe OPU1XjaqU1wAjeAXFmrGF6ic3C1xhDCtDMS5rjZBUG7u/IomVXcmHT67/hevUHmsZB1s WnQyGj/rkF7QdP8sxl2z5e+BsUxi6a3qxYDgoCFcTi2H8of1u2Dww8vgLggrMuKItGnK t283VdJXtEKi4p8UgtsBJBWF2UoOmVE0+r5GGd7BqZYn5ute493c67xXTQjaNfa/iM+O ymRfhjzlmRt/eqEwAWS+DtM985rAohQkDqb56omHjNcP7pwJoytvzZTgQz0N7rbt4Ot+ VJKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=FzJjArNr; 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-160758-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160758-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 e8-20020a656788000000b005dc85b86649si15632823pgr.686.2024.04.26.15.58.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 15:58:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160758-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=FzJjArNr; 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-160758-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160758-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 CCD9628305B for ; Fri, 26 Apr 2024 22:58:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 188A13D56D; Fri, 26 Apr 2024 22:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b="FzJjArNr" Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 9556D3A1B0 for ; Fri, 26 Apr 2024 22:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714172280; cv=none; b=h3qb9csYyPYc9C2Ud7hqPmI2plUu3APXod15/ZESD7ilSIoaADx0wuf31XcJEiqTZjB3Ud7TVlVmucF3q6sovKDl2VOt14RKlATQKnUXToNJhpW1yMn+8XgEIe9l0RNkOvfwcqphtrJIUupn+2i41J1f2nMorR3Vj7W2dA7FbYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714172280; c=relaxed/simple; bh=BXBOryCRmdGU3MpjZtj/f9m+SVkcFk68TeUd1IaFwL0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fp3aqUAqlak7wQOwBGHZHHagOja+qRoouFYei1bf0jh+ObwGD/1Xd6Fn4MGuOYpbDIZzQjmgnH7LNQfVuKhMQFx7nhCjmExomjVmpLpmBaYkMOmTAtzXFbwvI6QIDAsSpieBN1fjUPLhh731YPrJ3xhP0RDyooZxYjShaXYZPXU= 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=FzJjArNr; arc=none smtp.client-ip=91.218.175.188 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=1714172276; 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=SqC2//5SbqmO7sl0eIyTlpelQ5K5dhBqbZvBw6LmbcE=; b=FzJjArNrn0fjQZ78lse7C+m9UIX+MxlPLZVwrQyH/p8SIbdpp0/6cXQ422lnrlWKnO9/jZ f0YIgQvTicvUvb/q9pPK4zsfb5/lqIHhOoVF2SkWz7MV0zuxtAsEUB3jLwINdu0BpjyCv3 mmsNj65FqDdirRB8dOutGxacL4tC1OWggiz9Ad1I04PKsDIgtNEO+oifxTZF5+rV/aLbWi BXQYI0Y7v02OAOHDHTlA0aFsRUEg1FkvWk/tENbaUPDUUofiRsYAXovaes7k32rPKJasQK WjKjNNipzuKHM7WvnNvB8P/G28YDRPPyT2fNuLZYSRjG7sIVUlbdHtVSycuM9A== 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 3/3] HID: i2c-hid: Align i2c_hid_set_power() retry with HID descriptor read Date: Sat, 27 Apr 2024 00:47:09 +0200 Message-ID: <20240426225739.2166-4-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-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. Tested-by: Lukasz Majczak Reviewed-by: Lukasz Majczak 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 6ac1b11fb675..4ec12c083714 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -385,25 +385,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 on a bus error. 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 && 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