Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp897483rwl; Wed, 12 Apr 2023 05:49:03 -0700 (PDT) X-Google-Smtp-Source: AKy350ZstrKZqu0ZLfai6110lP6a2fQfppKCSYqdrfEVBTUuGjHVyIXtWRNtUEJHF4bVsGKX8Aip X-Received: by 2002:a17:907:75e5:b0:94c:ea3b:27a with SMTP id jz5-20020a17090775e500b0094cea3b027amr1898855ejc.16.1681303743271; Wed, 12 Apr 2023 05:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681303743; cv=none; d=google.com; s=arc-20160816; b=EJE+LAgC5+YO6yo0JJEk+wE2/WElaH7iPJpRmyvteZ3861gSmB4lsreXTl65Tj6hBV I6BrKl7OOWr/f0wHpu100auKOoQFpExSQKoD7X2vUx4b4Bn+ytg4Gts25ktCuTFB+ZgK 8LnIrpECuIHAxZ52GVzuTY3+o75eMua7ssXTFfN4N7NWXN5YVLeTLjNXOYejkjkBWeU0 XKbWU9WUHulun2ukUd0IShJ0nyGEGgGK621MyGRChyv+OM0Bro6ci4sXJzRfZrLi2nOU W8tHae2MjK3e6oeccPd5oDCYZzMKht30A85W/j4emx3ItwzIf8RYNkxxqAwCMeB9JW0e rpwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+78AZRYU7aeTnVMroAv5PpTTk3mZ2oSOoWxG6khQdOE=; b=eOCNdqx5IeHz53d+yCK9YErfKKKwhAL2Hspn/idV/TXwbvpvg9dMUyKKVnq3UM0hK/ 8CYWl0GXNEPliiORu1LMvnegUMYDRGMcKcvUxaIa1Z8FA3iKUiBV7OxO8Ey3P6oOS5T9 kimilri2DPNoTpiEyq063K41ALR1qxdPu+wOtTPpMIbx2tsNIhVxfFLyu0zIIPvB2W6h +lJvdRiGFhpE8681jfxCmhUlTls2XxtevdwNXFpV67uOxC7VjcFvmqdSKyw3v3qfDYMn k7HZBCbvxR0ExDXKP7CGRPLwRvir03uf29K0FU3fH8N1idOWswcqWQwNUdTzHjJc3jxD mf1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=1NMXD4c4; 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=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs31-20020a1709073e9f00b0094d491f51d0si5965373ejc.355.2023.04.12.05.48.37; Wed, 12 Apr 2023 05:49:03 -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=@lunn.ch header.s=20171124 header.b=1NMXD4c4; 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=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbjDLMpC (ORCPT + 99 others); Wed, 12 Apr 2023 08:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbjDLMon (ORCPT ); Wed, 12 Apr 2023 08:44:43 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8D27ED2; Wed, 12 Apr 2023 05:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=+78AZRYU7aeTnVMroAv5PpTTk3mZ2oSOoWxG6khQdOE=; b=1NMXD4c4+ttuVMXf2h9bkPusSZ fZsm8Wf6r+KhLPcDp6H2rJYpSOsQCLXlk6MJA9ruQ9DbzTiTQDYkZCnpyJ/7Y5RULgw4zRBiceyi4 q292iJU6vPniDvADrBQAiUAgJST7DlAgFRZREaYeZh1fr/wqGqf+kTBG76D87NBQASS4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pmZpH-00A5Zg-3m; Wed, 12 Apr 2023 14:43:51 +0200 Date: Wed, 12 Apr 2023 14:43:51 +0200 From: Andrew Lunn To: Matthias Schiffer Cc: Peter Korsgaard , Federico Vaga , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux@ew.tq-group.com Subject: Re: [PATCH] i2c: ocores: generate stop condition after timeout in polling mode Message-ID: References: <20230220161628.463620-1-matthias.schiffer@ew.tq-group.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230220161628.463620-1-matthias.schiffer@ew.tq-group.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 Hi Matthias I also don't have access to the hardware, but the change looks O.K. > static int ocores_xfer_core(struct ocores_i2c *i2c, > @@ -387,16 +389,16 @@ static int ocores_xfer_core(struct ocores_i2c *i2c, > oc_setreg(i2c, OCI2C_DATA, i2c_8bit_addr_from_msg(i2c->msg)); > oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); > > - if (polling) { > - ocores_process_polling(i2c); > - } else { > + if (polling) > + ret = ocores_process_polling(i2c); > + else > ret = wait_event_timeout(i2c->wait, > (i2c->state == STATE_ERROR) || > - (i2c->state == STATE_DONE), HZ); > - if (ret == 0) { > - ocores_process_timeout(i2c); > - return -ETIMEDOUT; > - } > + (i2c->state == STATE_DONE), HZ) ? > + 0 : -ETIMEDOUT; > + if (ret) { > + ocores_process_timeout(i2c); > + return ret; > } The ret == 0 becoming ret is not so obvious. Rather than having the trinary, do if (ret == 0) ret = -ETIMEDOUT; and then fall into your new if clause. I think that makes it more obvious that wait_event_timeout() returns 0 on timeout. Andrew