From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 395EBC64EC4 for ; Thu, 16 Feb 2023 14:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbjBPOAW (ORCPT ); Thu, 16 Feb 2023 09:00:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjBPOAV (ORCPT ); Thu, 16 Feb 2023 09:00:21 -0500 Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE55E497C1 for ; Thu, 16 Feb 2023 06:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=rWlCoq1ZTbLktUBB4zD1H0bmEPrHDs9UzSQc+atRYbY=; b=VJlanjw2P3guRI2OtZ2p/fpFVG 8h3awhkL19+lPT0qDu0ycIeLnxK0d6jVb6W5LWxOg40JKXUeocjabvUeipyfD9CJ3Ixf8Oo2eE19H Wzi08UK2xU7zB6buxM11HRe5uDvZ+zPToBH8K+vcK2A6M6OWHBXLjOeWBSGzV0y6lm0+mGZqup7B8 la0cUpVgZyVgAzWyCHLma/PytOVWfbsGIzvyfju2bN/YmCvY1+LleVhE5Ol74iRjP2mypLveIqyhH Wq6MIqPa4pI+p0CT5mO6DLn+LK87fOvXIXTk9dU9Zcaiy32zGyj/mtI+bqdOxAo5tJW/9cJWg8uLf 3x9OuN6w==; Received: from sslproxy01.your-server.de ([78.46.139.224]) by www381.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pSenr-000PHw-KX; Thu, 16 Feb 2023 15:00:03 +0100 Received: from [2604:5500:c0e5:eb00:da5e:d3ff:feff:933b] by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSenq-000Hld-Fn; Thu, 16 Feb 2023 15:00:02 +0100 Message-ID: <386610fc-08ce-ec04-a577-26f415b48701@metafoo.de> Date: Thu, 16 Feb 2023 06:00:00 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 2/3] iio: buffer: make sure O_NONBLOCK is respected Content-Language: en-US To: =?UTF-8?Q?Nuno_S=c3=a1?= , linux-iio@vger.kernel.org Cc: Jonathan Cameron References: <20230216101452.591805-1-nuno.sa@analog.com> <20230216101452.591805-3-nuno.sa@analog.com> From: Lars-Peter Clausen In-Reply-To: <20230216101452.591805-3-nuno.sa@analog.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.7/26814/Thu Feb 16 09:40:04 2023) Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On 2/16/23 02:14, Nuno Sá wrote: > For output buffers, there's no guarantee that the buffer won't be full > in the first iteration of the loop in which case we would block > independently of userspace passing O_NONBLOCK or not. Fix it by always > checking the flag before going to sleep. > > While at it (and as it's a bit related), refactored the loop so that the > stop condition is 'written != n', i.e, run the loop until all data has > been copied into the IIO buffers. This makes the code a bit simpler. > > Fixes: 9eeee3b0bf190 ("iio: Add output buffer support") > Signed-off-by: Nuno Sá Reviewed-by: Lars-Peter Clausen