From patchwork Tue Dec 19 17:50:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 181207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2142463dyi; Tue, 19 Dec 2023 10:32:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWzH28sSiijjx9jo5fMEGH/NJXE7a8cbhYXSICZI/jSS1LTnIs3X7dZcLNwnL+DuSlt3M2 X-Received: by 2002:a19:6d09:0:b0:50e:435d:7a4e with SMTP id i9-20020a196d09000000b0050e435d7a4emr830953lfc.100.1703010743287; Tue, 19 Dec 2023 10:32:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703010743; cv=none; d=google.com; s=arc-20160816; b=nDRHBC53cq+UaMPxBBD3ZzfS/VGDQusmBtLzTlPupFTD8kV9vaIZa/iUkMWw9+uWO/ 4Q7811SW8z4cSJDMczqhu3IgvWGudDp9HYpxMMzrA6yGckAp5h3Zflqb0a9auj7QI7xR HybdmnZ3DrIs1u7am9tEefGRDh4NC14+gdhBgibCAISjfpKvgNu7G1yIKLFge9QQ39Hw cJTFPdO8yyfL9DKFUsYhpjDLKdPzlBzx/7m2H7vaMH4J0OQ95+gXkKvoeurf8mElp5wF JEW0ohwZXS8vNfKeNT9Tat/4RW2RlrguCWT68OLBvaJSNbt5N4+ZDRsnfPRrZ09gJtIo n/LQ== ARC-Message-Signature: i=1; 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=oGRsJ+tJFINsq/9OPmu94IJFWwVMC9QjYHPIQeMCNU4=; fh=4kLaRtu+eGuv773DpqUA/LhHDskOCkI1ov7zbJtOyyY=; b=OfGO1FRioyWe5aiACvpG/cph5uU1VJ7E3ADk3VoHFXMkZsJpSoe3/AzGzgAAJuP1j/ JDMxhVaCMnydyZtAH0zpz2af5vOoPJvLJolZw5/ikkQt1hAbXiceHAh/kHJ+K5cYkkyq j4TaqfaiuG4UuOI8rf32pvUhMOf+CMHWCUApjHEJaIuMbDFQO3Gwek5TN2afr9jHpvlZ qMfFt8zLDhTZoGgeMFDtru764GStTCRpti0bL4RuJ/E6Sc8KfLNV6lKSpsqfxJvWspTo sE+R+2GaHJ2n8eglVQD/b1tSYcvxfoynxWULtEiA5imrLfpBtmcfo+7GUF3aElJicqWO aVyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=MuLGfssg; spf=pass (google.com: domain of linux-kernel+bounces-5737-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5737-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i23-20020a1709061cd700b00a2353f74c37si2118033ejh.75.2023.12.19.10.32.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 10:32:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5737-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=MuLGfssg; spf=pass (google.com: domain of linux-kernel+bounces-5737-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5737-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net 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 5CA531F27549 for ; Tue, 19 Dec 2023 17:55:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 554D53EA64; Tue, 19 Dec 2023 17:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="MuLGfssg" X-Original-To: linux-kernel@vger.kernel.org Received: from aposti.net (aposti.net [89.234.176.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F215039846; Tue, 19 Dec 2023 17:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=crapouillou.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crapouillou.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1703008220; 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=oGRsJ+tJFINsq/9OPmu94IJFWwVMC9QjYHPIQeMCNU4=; b=MuLGfssg4c9uqlHRE79Zan0YaFSA3PIM61XIkgjxelhw2LYPW8Jn5pJTAmN0n8UE/9AEV0 I6LySUbuJkX7pS6REh3X6KUQauCdJbZajVCIWXQ3CmRo01P3enWEBItJwTkaJO7etrVqF7 H6+2m5ML39bNO7JhosPuSzW5yinBUbo= From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Vinod Koul , Jonathan Corbet Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-iio@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, =?utf-8?q?Nuno_S=C3=A1?= , Michael Hennerich , Alexandru Ardelean , Alexandru Ardelean , Paul Cercueil Subject: [PATCH v5 2/8] iio: buffer-dma: split iio_dma_buffer_fileio_free() function Date: Tue, 19 Dec 2023 18:50:03 +0100 Message-ID: <20231219175009.65482-3-paul@crapouillou.net> In-Reply-To: <20231219175009.65482-1-paul@crapouillou.net> References: <20231219175009.65482-1-paul@crapouillou.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam: Yes X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785736192988275064 X-GMAIL-MSGID: 1785736192988275064 From: Alexandru Ardelean This change splits the logic into a separate function, which will be re-used later. Signed-off-by: Alexandru Ardelean Cc: Alexandru Ardelean Signed-off-by: Paul Cercueil --- drivers/iio/buffer/industrialio-buffer-dma.c | 43 +++++++++++--------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c index 1fc91467d1aa..5610ba67925e 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -346,6 +346,29 @@ int iio_dma_buffer_request_update(struct iio_buffer *buffer) } EXPORT_SYMBOL_GPL(iio_dma_buffer_request_update); +static void iio_dma_buffer_fileio_free(struct iio_dma_buffer_queue *queue) +{ + unsigned int i; + + spin_lock_irq(&queue->list_lock); + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { + if (!queue->fileio.blocks[i]) + continue; + queue->fileio.blocks[i]->state = IIO_BLOCK_STATE_DEAD; + } + spin_unlock_irq(&queue->list_lock); + + INIT_LIST_HEAD(&queue->incoming); + + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { + if (!queue->fileio.blocks[i]) + continue; + iio_buffer_block_put(queue->fileio.blocks[i]); + queue->fileio.blocks[i] = NULL; + } + queue->fileio.active_block = NULL; +} + static void iio_dma_buffer_submit_block(struct iio_dma_buffer_queue *queue, struct iio_dma_buffer_block *block) { @@ -638,27 +661,9 @@ EXPORT_SYMBOL_GPL(iio_dma_buffer_init); */ void iio_dma_buffer_exit(struct iio_dma_buffer_queue *queue) { - unsigned int i; - mutex_lock(&queue->lock); - spin_lock_irq(&queue->list_lock); - for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { - if (!queue->fileio.blocks[i]) - continue; - queue->fileio.blocks[i]->state = IIO_BLOCK_STATE_DEAD; - } - spin_unlock_irq(&queue->list_lock); - - INIT_LIST_HEAD(&queue->incoming); - - for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { - if (!queue->fileio.blocks[i]) - continue; - iio_buffer_block_put(queue->fileio.blocks[i]); - queue->fileio.blocks[i] = NULL; - } - queue->fileio.active_block = NULL; + iio_dma_buffer_fileio_free(queue); queue->ops = NULL; mutex_unlock(&queue->lock);