Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1672896pxb; Wed, 9 Feb 2022 01:49:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiUsvqWxxz7qyXuhboY4ImCzikjDOOxtnPHepid5D2QRmNOYlnE11eSs3v++wFKvx3GCvD X-Received: by 2002:aa7:9634:: with SMTP id r20mr1420742pfg.57.1644400196630; Wed, 09 Feb 2022 01:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400196; cv=none; d=google.com; s=arc-20160816; b=gy83AqMtpx9ToNexFQRSIMI2XhOB5usizhSDDN2ubiCzuqNGPVMqQ+L+MzOnYRj9Uz Ii2rBaFJBXqtSEkPUK0FV1Sls3NdrC0cvtQNgbvcGMCvRaCdcCwsvN7NaNSB7YFEyxEO vQiukVeKBMjggwhpmVphZ2I7UlRNQEro0/pcjzDwzGhV9au+ChsN/nw40UFim1ceJJVk lBcg0wxF9EYcQpztLvU6MflmsfRog/mkE3jcIcX4nNa368dV5h3LZu749fVYYAODuBZQ 0j2V6mPJJ/4iU8Pwc4nJbp2JxgBq4PELE7M+uua34UgR7gMBTHm6DmCED/Wji9pfd1SZ 3xFA== 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; bh=Koxm+IY4hfjKnNPbW84no/ylZs5mG5fEYdybJY5XLAg=; b=ZpczypltkDRhDXm1q+rOU8Xa9SDtKw6cuxzSGKYV36ufMPaKkUtkxRAY7sMX4a6MmD YLkiLZPdCFTpBn+uEWsyz3ZVG8OuVdaFTgGC4+7blP5du36rQPPlwzrokyKW9Cb51Nvg j6bfiNEBcHZ7qtUkH6zJhpRzbnj3gnCPY25cKZjSUVM+/YDbQRjq58PNSyQxmRUL1VxR +rSR+9ghAxF96XVn3DMgZml8F+vRvdtRLeHSyeziZfTR2e8yP0OxgQ0RfzbKsYcQLsLJ xwJJXIaIEITdCnyqYfSbe99pb1tv0jUkoaucHlCguHktRfbycPv/v9dXMKPLkO/vmNO7 0fCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q20si17050539pgt.648.2022.02.09.01.49.43; Wed, 09 Feb 2022 01:49:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1448861AbiBGNN4 (ORCPT + 99 others); Mon, 7 Feb 2022 08:13:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1448531AbiBGNLs (ORCPT ); Mon, 7 Feb 2022 08:11:48 -0500 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914C2C043188; Mon, 7 Feb 2022 05:11:47 -0800 (PST) From: Paul Cercueil To: Jonathan Cameron Cc: Michael Hennerich , Lars-Peter Clausen , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sumit Semwal , Jonathan Corbet , Alexandru Ardelean , dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Alexandru Ardelean , Paul Cercueil Subject: [PATCH v2 06/12] iio: buffer-dma: split iio_dma_buffer_fileio_free() function Date: Mon, 7 Feb 2022 12:59:27 +0000 Message-Id: <20220207125933.81634-7-paul@crapouillou.net> In-Reply-To: <20220207125933.81634-1-paul@crapouillou.net> References: <20220207125933.81634-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 From: Alexandru Ardelean A part of the logic in the iio_dma_buffer_exit() is required for the change to add mmap support to IIO buffers. 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 a9f1b673374f..15ea7bc3ac08 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -374,6 +374,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) { @@ -694,27 +717,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); -- 2.34.1