Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4846803pxb; Mon, 15 Feb 2021 02:52:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAPNzIVCPL8P/KLfrzb4tgLkDRpKwFgC7+V8FTm9iviRiwDhmPhZm2SkwFU0eqURezFeT6 X-Received: by 2002:a05:6402:1655:: with SMTP id s21mr14606768edx.171.1613386372887; Mon, 15 Feb 2021 02:52:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613386372; cv=none; d=google.com; s=arc-20160816; b=kELBWrZhs2Si1mhRcjYjrx0Y2L2jCez/SwGK4wAjf8iB0RCKekkdpdJlzyLUHE90xf ugzqRj0BKIM88xiUOM4UHc3aEHJ3Oy1mVBjD9RvfXwgH4WTI4SNJSIbPhrd8aSiTBnJ5 mrRxGkq7SimAc1j7ByUhEjY27Y6gwTR/xx0C+DhhdwKT1SgjyOPi1eOettu2C5kVIbyA 0j9FRCfKetv0K1HI+ci9Kwh3hiSaFPYOichBEaXA0B22lSO+Mfbb5wn7TjLTHrGOs3J+ iA0AAStA2yQ82uuOOb4jtVHrcuKSzfBeobG2SzMFFOptp7puD/iSfCZ4lL2OlVA568+8 iGdg== 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=b9e7BwzjN4Blt3YAU4TsqRIAlOlvL2D61iDBJ/lCD7A=; b=0j+jXygcbII15O2CgEXpVJywO9jrwOuedzvmClwqvoJqhn+VnriGaEy1ZlAtGGvx3D llHCN6pxBqeJMXIKa5bldkyL0D1CsXYUVFbjw+wvE+Hbj0Nc+25nj2J+nCsVSwcl5v0B 2tcCIgQil7uGLb1tBtTxbAk6nKvG2aaFi6UWOcqb5+iAdJbzPeFT7AXbtQBQOePPgkQK yWxVnYKlTsEw7TCGLQUK+amj83mZI3T0vucY8LpUCQrLun4fAjq4SkCpT5NV5c7G4oOk bXjcmJwXTE6tpb+9SrpWMvQf6MZ8XdjaOiIuY0HM7uJZDoNy4h152F+C97/PTj/O8+AN r/Qg== 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 gg11si2208473ejb.751.2021.02.15.02.52.30; Mon, 15 Feb 2021 02:52:52 -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 S230368AbhBOKqS (ORCPT + 99 others); Mon, 15 Feb 2021 05:46:18 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:1790 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbhBOKkJ (ORCPT ); Mon, 15 Feb 2021 05:40:09 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11FAZnYm028725; Mon, 15 Feb 2021 05:39:16 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 36pcjamaka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Feb 2021 05:39:16 -0500 Received: from SCSQMBX11.ad.analog.com (SCSQMBX11.ad.analog.com [10.77.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 11FAdEP1008341 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Mon, 15 Feb 2021 05:39:15 -0500 Received: from SCSQCASHYB7.ad.analog.com (10.77.17.133) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Mon, 15 Feb 2021 02:39:13 -0800 Received: from SCSQMBX11.ad.analog.com (10.77.17.10) by SCSQCASHYB7.ad.analog.com (10.77.17.133) 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 02:39:13 -0800 Received: from zeus.spd.analog.com (10.66.68.11) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Mon, 15 Feb 2021 02:39:13 -0800 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 11FAcQUk017530; Mon, 15 Feb 2021 05:39:09 -0500 From: Alexandru Ardelean To: , CC: , , , , , Alexandru Ardelean Subject: [PATCH v6 17/24] iio: buffer: move __iio_buffer_free_sysfs_and_mask() before alloc Date: Mon, 15 Feb 2021 12:40:36 +0200 Message-ID: <20210215104043.91251-18-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210215104043.91251-1-alexandru.ardelean@analog.com> References: <20210215104043.91251-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.737 definitions=2021-02-15_03:2021-02-12,2021-02-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 spamscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 mlxlogscore=917 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102150087 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The __iio_buffer_free_sysfs_and_mask() function will be used in iio_buffer_alloc_sysfs_and_mask() when multiple buffers will be attached to the IIO device. This will need to be used to cleanup resources on each buffer, when the buffers cleanup unwind will occur on the error path. The move is done in this patch to make the patch that adds multiple buffers per IIO device a bit cleaner. Signed-off-by: Alexandru Ardelean --- drivers/iio/industrialio-buffer.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 83ea15e330a4..7efa32dd9c61 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -1443,6 +1443,14 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer, return ret; } +static void __iio_buffer_free_sysfs_and_mask(struct iio_buffer *buffer) +{ + bitmap_free(buffer->scan_mask); + kfree(buffer->buffer_group.name); + kfree(buffer->buffer_group.attrs); + iio_free_chan_devattr_list(&buffer->buffer_attr_list); +} + int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) { struct iio_buffer *buffer = indio_dev->buffer; @@ -1464,14 +1472,6 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev) return __iio_buffer_alloc_sysfs_and_mask(buffer, indio_dev, 0); } -static void __iio_buffer_free_sysfs_and_mask(struct iio_buffer *buffer) -{ - bitmap_free(buffer->scan_mask); - kfree(buffer->buffer_group.name); - kfree(buffer->buffer_group.attrs); - iio_free_chan_devattr_list(&buffer->buffer_attr_list); -} - void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev) { struct iio_buffer *buffer = indio_dev->buffer; -- 2.17.1