Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1573621lqp; Mon, 15 Apr 2024 10:09:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0d4cCZrmZyX/uUoGqHTm3/k2BISCOcjC5Y+R0U4oIF9Zb+kFrTMKuWBiD1XKZlYFr3DCfoXspGdyW3AtQnxzUS4LWx9+Hie4cBMLeeA== X-Google-Smtp-Source: AGHT+IHbcxzsMu981pT4yDcke+intKOESsdIpgwu+3flQSIgqjPbPTAODSlsUeY5pS4mR9lLrgTm X-Received: by 2002:a19:5f44:0:b0:516:d232:2516 with SMTP id a4-20020a195f44000000b00516d2322516mr7670034lfj.6.1713200965414; Mon, 15 Apr 2024 10:09:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713200965; cv=pass; d=google.com; s=arc-20160816; b=pD9je5Fea5GIYilfyHjyMOKJvNPlF7nrXbu/D596hJ4hDk0iqyqje1VPVBe0l8zYzb uIMYP/w0IT0HiQd4KVgq70Jh8D71dWmVBQ153KAy0hi45yB/YB9LdfhEKqJhSlfBctPT y0NT2lm70LwA6BoBScS8FPAKqsfJ3p3LttPaq/zl7DI5cbEJTJyYGsK6NSdOg1hlpDsP T4sxEjasDnsFOmSsHws0dZfYbYzPk0QOqDkaVEwBTGk40OfXm6UH7Sd/sdL6W7jANvCU VlSjyZqM3atiDIGGkXoNx4STeiXUFY6lfNh1kItXZuVp3Ujd1/CBRdAMAnSNAs26xGMU hecQ== 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=ptoV88Ij0/j9NhFFGW6zsh8KfISiHRwnC9zklzCEC5s=; fh=Mm8hlFdBHUY0fyqKU/MWlqkizWEw7qYBWD0xRewgNf0=; b=0wCXlHCxLRqNnGGjjRHiWkS0K40QZE1ZGd9eE2kTGGYU6RzrPxdn7qEMXwTnc4C058 UjXQMFvhKMaMp+5cvcADuQ0FKIXTZBGXYvXQtY/EzfLa2I9JFG700SQTVLDnDoFqHzw5 cT3VLix8kpIwQlfPz+qixpnBKXg4eB0bqLldVktINaqa9d46dIeiP3XmCbomIujd0KhM BakhaOi1sJdwj+tH9fehbBcXqds4eoz93vJfoDr20j2btjxqwZapIRinDUIko9PzEkKX yka4T4n3lDXcankBEafIJfUu7CuzqtFvv/KtJvj7gBK2gxadl3Dken8PStZj81Tiutfw dQjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kl.wtf header.s=key1 header.b=M54NEGVz; 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-145629-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145629-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 cm40-20020a170906f5a800b00a5258270ff9si2068445ejd.925.2024.04.15.10.09.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 10:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145629-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=M54NEGVz; 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-145629-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145629-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 22E121F21756 for ; Mon, 15 Apr 2024 17:09:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B72F41272B5; Mon, 15 Apr 2024 17:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kl.wtf header.i=@kl.wtf header.b="M54NEGVz" 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 668818526C for ; Mon, 15 Apr 2024 17:05:52 +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=odX0UV1QV1/2aLLMi4WHZDYkVyOXMRZFkYON/1SLHch7Un736krR4yhqo3NKetYc0hUtyWRkyeh6PYwHSZ6L6ODnk/FQuCCJ2SXyO23HyUAliwGjmU3eD0TybF3Brwffc2LoZ1ifWWL7wDQHFvl/S6h//NPOitWANsi4LS+qu78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713200753; c=relaxed/simple; bh=0mJpgs4aUQEhIiZHyXeNH/EklJ0LtNa/zt00pTK4jZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YLM42CG6eK0zQw4aFqX6kL5s8BSn1OgiZN7JGBgHF6z4ZJO7Cmy3uVeg1RD1/1200K9+bJpFzask9RytjoV0lR1+n46OqWKRUWLiNhtDLu97xb6S4/zZRefE7SjcXomi395fonxn/tqd5qHUHzdRtx2jO9jMZ3aO05eKnEuEZ0M= 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=M54NEGVz; 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=1713200750; 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=ptoV88Ij0/j9NhFFGW6zsh8KfISiHRwnC9zklzCEC5s=; b=M54NEGVztU8esR0V50Z57mvarN+dZN/XS/51m37T9NlZ2lFFhUyXWSE9k53KPbRaqxUypZ IA+FtEmMnA3YbalvGaBpMcEruXs1Qaj6GMsvDXL+IGwi0zlUWog0VxUreeYbBLPeEp2gJs 7lpqqc78KIF6/gdRfAcZIaC2F4AQ0y3CCUPUbkoSIEFBMxMCq5FY6wMXsoWRXl6yT/fIjv 6Y8rtCM0ZUcW9nJaPi6nqjgi4hQ1GQujWH0iLaWf8VR9aTpCMzCTHDTeVOSe4dsi+Hr59X VE6SZ+XX3R9r9VfOusekSX2s3XBsERJrPtDsoVVUkckxE5MQXx/7TX5pJCEOfw== 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 3/3] HID: i2c-hid: Align i2c_hid_set_power() retry with HID descriptor read Date: Mon, 15 Apr 2024 19:04:13 +0200 Message-ID: <20240415170517.18780-4-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 Instead of retrying on any error, just retry on EREMOTEIO and simplify the retry handling a bit. Signed-off-by: Kenny Levinsen --- drivers/hid/i2c-hid/i2c-hid-core.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index ac661199d2c8..998e7aa140d7 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -395,21 +395,14 @@ static int i2c_hid_set_power(struct i2c_hid *ihid, int power_state) * The call will get a return value (EREMOTEIO) but device will be * triggered and activated. After that, it goes like a normal device. */ - 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) 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