Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3695292ioo; Wed, 25 May 2022 06:21:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbj1ffj1rpkuwoZ5fZs+KcUAmKUUNZ/Dp7WlRRH1a1Vi9kWdc0H2KmBa2Tq46g/WFbBTWw X-Received: by 2002:a17:90b:3b8d:b0:1e0:410d:b0f7 with SMTP id pc13-20020a17090b3b8d00b001e0410db0f7mr10578376pjb.165.1653484917065; Wed, 25 May 2022 06:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653484917; cv=none; d=google.com; s=arc-20160816; b=y01scxVQC1rpZTgsR9/meLj/bv8JP2ELDhRoor8jR6Zk1g0WGjjm82W69X9Lhhigoo nc/Zt0zRrrgz5HccW6olY/GuFRHsX2ZMUF3eQem3Vdgue5dt/zt3l0c3IUM1u6w7AGFy H48QD7+GwKc9BGFino2JhYKbflYPkZgmjIvAD365amXqQ91GajWtWglKj69IdCishNu4 AE5VrgiHv+TKSBVETe+F6I5iV6Lc3E3iiPgfL1VykXrI4fpGEqwpT0aEpQTi0+hWqzlf hClx+ShGeZ9xsRkbPxHss15iLOK6jr7lbI0Ne1sVWRgzwQFqK6imPC6vZ71JsMXdecGF EOuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qj2qVWqqLCW4wt2qnLg7N/C1U3pSsjcBWbFI/p2DKxo=; b=YGNvGBMAC0pJc92JPC0DSR2tRKZ7qvOekgRaOzVHAYI6iKWyoCvZ+8R5Vwj6GSb2l9 p4rvqxzTiLU++Y+dUlMt5WTD9tMmx3SblfpaJVPzIFOMVSqZ4EykO6EvA54LQE3kwNIf 6zzcX1sFuLPbdwnNAEBnPJsax8MyaebATHT1AJsmQSvuu0+lBXFbekUuHYqX5EfZYkSf DKBgVFE7+AyR3ZpQ8QVvt8Tyxn1rxjFLEbF6TR2PsRhKZ/ER3RyzI//2QUrQbwFm5En7 6eY7m6614g514lu6GpIMGBMzW3Pw5etcVCJ1NO9J5Jy4lCep4F7xljjL1NdXZK8JA51F YtRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iMCw1g8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 134-20020a63018c000000b003fa34f0053esi14790860pgb.228.2022.05.25.06.21.44; Wed, 25 May 2022 06:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iMCw1g8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239143AbiEYHsw (ORCPT + 99 others); Wed, 25 May 2022 03:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233874AbiEYHsp (ORCPT ); Wed, 25 May 2022 03:48:45 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0FC77F3F; Wed, 25 May 2022 00:48:44 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id er5so25906442edb.12; Wed, 25 May 2022 00:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qj2qVWqqLCW4wt2qnLg7N/C1U3pSsjcBWbFI/p2DKxo=; b=iMCw1g8NbI+EJvFWr/N4GGCYOCmtfzEYCbFiBjG20E7Y3KUNy+YCDeJ817+zWQ/nv3 6XvytPmWARu0mNA9ZOGXu8ugQ9BIn8L1AO2HT/5Wz3ZEAZPBfG5SxKpYfZbJChHpXomx ROPlVZtwqoIZdlXJNtJOhiYxd63dcZlXKI0AW/vDWHkB0d27h5Wr9pTg0dD0SD2znIFo IGUxoQiy53lPRE2RftdN///o7+G6m1WfpOl6d2eL/Zp/Zt4X3pDSVwZ69pVPZTq5Hysm Z+x7jddj/5yRnlAlKtnBCkL1G7MKEhcLLXyIX+oByDKYVwNnXucf014S5zTu+RMHtDwE Rouw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qj2qVWqqLCW4wt2qnLg7N/C1U3pSsjcBWbFI/p2DKxo=; b=QcYW/Tv8RWnP4zpxUyAj9lc6TkAdPOr5wdBLtG0nf+pAYwm9miuwHDighsYxWg6J1y 3IZ7J2u1DK9H+P7TSMMhoQZcRpTvPKscZmZENRvg/3VXUjRmeUAC8+5VfeMySSWqyqTk GK6Ld+kx4q133Ny5k4/Y35mMRf3o9GsDOn1KAYgVSPMDnwQz7k6gskGosRKm/WbS1A4s jW2Ox0sDafUWldMfAM61AstTl/5MbAa+QUN+9LsrjEcj9H6TBkXoawJMYRzBZbZX0lqS v+OcXNZUv6rT3mOvuUI4IplVkcdPT4pWJjDj75VdifhkguPz4gwCyD0/uRJKx+vkEEZL 9iEw== X-Gm-Message-State: AOAM5312cOVKUPODVLmc+j0e3dC6UhSAD0sRYpQHBNLLHKrjCs+IF+Dq p4upwj6TDJ5JZ0uOLKC5x7Q= X-Received: by 2002:aa7:d94b:0:b0:42a:b93b:c54f with SMTP id l11-20020aa7d94b000000b0042ab93bc54fmr32766944eds.246.1653464922551; Wed, 25 May 2022 00:48:42 -0700 (PDT) Received: from localhost.localdomain (109-186-136-71.bb.netvision.net.il. [109.186.136.71]) by smtp.googlemail.com with ESMTPSA id v1-20020aa7d641000000b0042acd78014esm10230533edr.11.2022.05.25.00.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 00:48:42 -0700 (PDT) From: Michael Zaidman To: jikos@kernel.org, benjamin.tissoires@redhat.com, wsa@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, champagne.guillaume.c@gmail.com, mathieu.gallichand@sonatest.com, Michael Zaidman Subject: [PATCH v1 1/5] HID: ft260: ft260_xfer_status routine cleanup Date: Wed, 25 May 2022 10:47:53 +0300 Message-Id: <20220525074757.7519-2-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525074757.7519-1-michael.zaidman@gmail.com> References: <20220525074757.7519-1-michael.zaidman@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After clarifying with FTDI's support, it turned out that the error condition (bit 1) in byte 1 of the i2c status HID report is a status bit reflecting all error conditions. When bits 2, 3, or 4 are raised to 1, bit 1 is set to 1 also. Since the ft260_xfer_status routine tests the error condition bit and exits in the case of an error, the program flow never reaches the conditional expressions for 2, 3, and 4 bits when any of them indicates an error state. Though these expressions are never evaluated to true, they are checked several times per IO, increasing the ft260_xfer_status polling cycle duration. The patch removes the conditional expressions for 2, 3, and 4 bits in byte 1 of the i2c status HID report. Signed-off-by: Michael Zaidman --- drivers/hid/hid-ft260.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 79505c64dbfe..a35201d68b15 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -313,27 +313,17 @@ static int ft260_xfer_status(struct ft260_device *dev) if (report.bus_status & FT260_I2C_STATUS_CTRL_BUSY) return -EAGAIN; - if (report.bus_status & FT260_I2C_STATUS_BUS_BUSY) - return -EBUSY; - - if (report.bus_status & FT260_I2C_STATUS_ERROR) + /* + * The error condition (bit 1) is a status bit reflecting any + * error conditions. When any of the bits 2, 3, or 4 are raised + * to 1, bit 1 is also set to 1. + */ + if (report.bus_status & FT260_I2C_STATUS_ERROR) { + hid_err(hdev, "i2c bus error: %#02x\n", report.bus_status); return -EIO; + } - ret = -EIO; - - if (report.bus_status & FT260_I2C_STATUS_ADDR_NO_ACK) - ft260_dbg("unacknowledged address\n"); - - if (report.bus_status & FT260_I2C_STATUS_DATA_NO_ACK) - ft260_dbg("unacknowledged data\n"); - - if (report.bus_status & FT260_I2C_STATUS_ARBITR_LOST) - ft260_dbg("arbitration loss\n"); - - if (report.bus_status & FT260_I2C_STATUS_CTRL_IDLE) - ret = 0; - - return ret; + return 0; } static int ft260_hid_output_report(struct hid_device *hdev, u8 *data, @@ -376,7 +366,7 @@ static int ft260_hid_output_report_check_status(struct ft260_device *dev, break; } while (--try); - if (ret == 0 || ret == -EBUSY) + if (ret == 0) return 0; ft260_i2c_reset(hdev); -- 2.25.1