Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp81210rdb; Tue, 19 Dec 2023 09:55:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXlZ/zMs9ePShkra0PCi/dm1LorfTaYPFb8nrnbNRo17LyJ7W3P2pd5T2Hv6XBvyZ+eZpM X-Received: by 2002:aa7:8c55:0:b0:6d6:4372:a123 with SMTP id e21-20020aa78c55000000b006d64372a123mr4762950pfd.11.1703008535008; Tue, 19 Dec 2023 09:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703008534; cv=none; d=google.com; s=arc-20160816; b=zvCqLfocmc6nDTsHcbj6M6fCycDeW/lHij0917yNFF8MtWQtqFfHFMdwjQ9me1pGKl NBrqbqkt4xx3UA/1GOqNqWpnHh4+sZexnuC7bui9lq2Np0LUhN6gOo6UbBMAoDPtVrqY 65DfGWr6YWzkSUr0zEHimluKoicfkWmb4in6pjFXpookMn6WDFG36g+aSTLmlHk4ezf+ t3tAyKFe+WBPQxRdWbgtnl4q9GXcD1Lz7mY9X4fxobt0MlcZbbVWjh5RC6gCBCXwVSpx WjHf7x5edtdM/vVZmCtR6L3uhrpay2imoCQ7b1VkaOeZxRQK1GgQDMwDLEewjwAAs4cM 4u2Q== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5737-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b186-20020a62cfc3000000b006d3a2af2025si5961737pfg.77.2023.12.19.09.55.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:55:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5737-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4B411285380 for ; Tue, 19 Dec 2023 17:55:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50EE03D0DB; Tue, 19 Dec 2023 17:50:46 +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=20K=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=20S=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 Content-Transfer-Encoding: 8bit X-Spam: Yes 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); -- 2.43.0