Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4980288pxb; Mon, 15 Feb 2021 06:33:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrV872pbFuAawZP9XqTFnISu7veFg+TDGFRf8ejYjXc+2P+DZBa+kahipB2cEpP5C7RmUy X-Received: by 2002:aa7:ce8a:: with SMTP id y10mr935069edv.77.1613399601313; Mon, 15 Feb 2021 06:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613399601; cv=none; d=google.com; s=arc-20160816; b=K0QN9tpO1tjkG0/dM5YPW9k6i6P0Tg0nJub7j5JQOwCkFCOtocQ3iLRbKVdsVuPs/J p3c1Hq2a+N13dhWzVJrNa8D1yE1EmnPVRNbLghfYW3mqQ6vMWrMhzqVTTmAfr+2Q+QRm jugGmeCNU+m1Yg1ukhBtvy/E9Rt4y+00YAazQ0biVVRW0dBNUie+Vm2Df2YI2JYeCJZP VJOrHQ8RtCg5k/pFCCckA4RGkPBIcRwfPJiPBsf+lFh9VxaeE84XZl/ZTERIvWMqNPLE pjbBSJ1sQn6RisKYCOc1/b8kM4nbsX1vwFJCNqonn63KYiX1A5jQDPsyUPSXdyZ14A/v H4rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NcJ/BtIsUmh+Jba4/8F3rmLK9IeJxjIKThWFZWELBpA=; b=J35GoyY1Q1KzD5mB5XLR5t1Qze/07XH33/lhnFW2Jcrtm/dBcYwflui+WRbh7vzRo0 Ut/sm6KBUlHdhzyhpiPFf/6e8Wy74NxffMjfWk++zRbNokxhoPECPTSARKXRS7rpzqCU 6UHrbP0uI+k/L+tQDnIAYwW8v4/X4JA1inzHNrrawef/olU23tzTaimcSfONOoD6VNoQ nUxLxNhQvkYG/bJhCROrFsvZrycRi/Ku+aQUVLYWVsTXAJMH0zmWtovS0TaOSxo1ItEv wzLehaCNYoN40yVAccHbIdjSm8VMZajieIGvqSuxEYtP7JaH00JwS86H5Niw1+5ezq38 9Lnw== 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=analog.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si12708988edd.70.2021.02.15.06.32.57; Mon, 15 Feb 2021 06:33:21 -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=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbhBOObt (ORCPT + 99 others); Mon, 15 Feb 2021 09:31:49 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:42562 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbhBOObS (ORCPT ); Mon, 15 Feb 2021 09:31:18 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11FEU6H6025770; Mon, 15 Feb 2021 09:30:26 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 36p9gaw2a4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Feb 2021 09:30:26 -0500 Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 11FEUPR8011827 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 Feb 2021 09:30:25 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Mon, 15 Feb 2021 09:30:24 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.721.2; Mon, 15 Feb 2021 09:30:23 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Mon, 15 Feb 2021 09:30:23 -0500 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 11FEUGbk027532; Mon, 15 Feb 2021 09:30:21 -0500 From: Alexandru Ardelean To: , CC: , , , , , Alexandru Ardelean Subject: [PATCH v3 3/5] iio: buffer-dma: split iio_dma_buffer_fileio_free() function Date: Mon, 15 Feb 2021 16:32:32 +0200 Message-ID: <20210215143234.3248-4-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210215143234.3248-1-alexandru.ardelean@analog.com> References: <20210215143234.3248-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Type: text/plain X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-15_08:2021-02-12,2021-02-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102150117 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/iio/buffer/industrialio-buffer-dma.c | 45 +++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c index d348af8b9705..858af7eea53e 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -356,6 +356,30 @@ 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; + } + INIT_LIST_HEAD(&queue->outgoing); + 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) { @@ -635,28 +659,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; - } - INIT_LIST_HEAD(&queue->outgoing); - 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.17.1