Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4735706rwl; Mon, 3 Apr 2023 08:56:37 -0700 (PDT) X-Google-Smtp-Source: AKy350Zjt+ZKarMmTIiKyiXz0paLbNg3xfk50VQr5+6HEX2841+N4iOxXOpcL9RYKuerD8OFQKou X-Received: by 2002:a05:6402:42c3:b0:4af:70a5:560b with SMTP id i3-20020a05640242c300b004af70a5560bmr19742953edc.9.1680537397568; Mon, 03 Apr 2023 08:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680537397; cv=none; d=google.com; s=arc-20160816; b=SrKctrXwW3xoZDPgLAzKXhMsTymaCjlPkLYw3F4mNsrwy+w8gM2uxdoe9gs0ngfyWa imsCvzuH1cR727O+BuyYkQ6WKKOKkGDuGygNo/Lgi3jxhxF9L9FIaLsC5njVQHZtBwXp 5S9J7i+dGlU3rnR2yPwyehd+OkdABw5xCWaBvLPijSFzO9y8oTKHdEF35V9/TrXPCpBO 3RcJbE4lbAJzVNe7pbI+ga/EbHqE6Ym+hKAmbUX0T6f615JXd3JixovPK93XxxA7AEZU 1UpOaXI+mnTvSI1Rhuo2Gno4E5MX2jzdV52aIt4v8cAINt1CzGWcHjQEgDCs7Ewm56OD gVBw== 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=beF+K1NHWP/zsnX7POz8yyiiOBr7zCFi5ikb61FvcI4=; b=JpkW4CoFYyiIRq9F+NN/Vdm1Ei6txp6QrFAcafWqpgAH4gPjZ+UrpsXkCxsi6cZCcp 0EGeKQOYXsrZWUayjM70oBFIfyAWxVzc2qBA1LJrSqUPi/WRpScK1kTzBdltPOqQYbN1 H28ABK9lfqRCRlYGUCN0uzOZj5JApBQqHUeO4yx46VTRnVm4GdI9izLyGA5AVVpRvpVs 6ylYkLuOf50p0Vq9w86Wt9fwnwofetrnnkznaA1IYoiLPX/8QLYyPz7G47Ztps+WCx/W q9BC/QW8IOIILz6f4rkckTnH8WfXap8nqabnI0ex4YbSpiyp1PzgfY0l3holtucgoJZa axPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=rEQlu75p; 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=crapouillou.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a1709062f0500b009335d891056si970132eji.984.2023.04.03.08.56.12; Mon, 03 Apr 2023 08:56:37 -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=@crapouillou.net header.s=mail header.b=rEQlu75p; 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=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232626AbjDCPz2 (ORCPT + 99 others); Mon, 3 Apr 2023 11:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232582AbjDCPzN (ORCPT ); Mon, 3 Apr 2023 11:55:13 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C64844AC; Mon, 3 Apr 2023 08:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1680536901; 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=beF+K1NHWP/zsnX7POz8yyiiOBr7zCFi5ikb61FvcI4=; b=rEQlu75pE1XlxvEiW2Vp6Q2DrJqFlXQRWGAGO/qViDKRDquUpd4KRJ2jtCkCphUkqIMmkc kCibghuDBjplYnoTYkLj+VJLDOiOKickpRJaP+TywS3SWmlYLN2xIf8YpVNxnxU3wY3Pj7 8OG7sKOHPKMOxagqrUvT8h8+0YtaZik= From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen , Vinod Koul , Michael Hennerich , =?UTF-8?q?Nuno=20S=C3=A1?= , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: 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, Alexandru Ardelean , Alexandru Ardelean , Paul Cercueil Subject: [PATCH v3 08/11] iio: buffer-dma: split iio_dma_buffer_fileio_free() function Date: Mon, 3 Apr 2023 17:47:57 +0200 Message-Id: <20230403154800.215924-9-paul@crapouillou.net> In-Reply-To: <20230403154800.215924-1-paul@crapouillou.net> References: <20230403154800.215924-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 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 86eced458236..e14814e0d4c8 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) { @@ -695,27 +718,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.39.2