Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1189095pxb; Wed, 10 Feb 2021 02:15:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/z9gwNCinghEcUGD0Yw+knyY0DG4kuvrvd/iNbojh2u22G2ig52f2i8sBn9h1auQ5O/Rs X-Received: by 2002:a17:906:2b16:: with SMTP id a22mr2205108ejg.291.1612952148846; Wed, 10 Feb 2021 02:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612952148; cv=none; d=google.com; s=arc-20160816; b=aNfbR4doaVgZRqai7If737LrkfOAedcs1W4pGjIip1wWLJLpQwnHq2p0vXY4gwidlA rcjYMy7ReOhFUHNG8QHjmUBYHVUX1ypXV/bzptpamrw+T01Dk82kWAsA0O5kupcTKdx+ dO5TREI/EXcyQ79KX+yKCK4O9r0khQnDgwc00xlbuZh/g7DgGEdeVEc0I/Jtq2kKBv0A CqgEat9FeHaRkoXrMJqBOJvqQ3MqrThS6jgsDURprbt5OjKoIeMmyoYcjd32k0n9hntd a/N4cTAA82qlVC6dXlzTCdqAYJWBG8ZXycofrK/Kp5oG6HhBaSaJyjpY/Ivwnf5eXfYN /KyA== 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=+Ko4yRqj7rb83fesudFHPTAf/QCMXTVxIbGqdhjUPbw=; b=sixf+Ylhy+XXHyK2mhWp5AdY62C+6qh8xTw5R3wXC4OFai+PPXDGTT/X5jX5VixUFR VrFS4Io24DtS8/qTNrdh1lcoDDY5g25bwkAPiaERkqUvHZminlqR/iq5jmf8iSuH0kUq FYjLiJIziWt8U3L2PDedtx8kq4WgkRPlbaBxdo+pDjrY749X6jW23d5j4/581Cr5c98b +OSmwwmJi8APYvDrFYPlG/iHiu828fHs7IGl7PEwwNAVVyHSb5HrPohsNz0Zu9UY9a6x 8plAK20MBq1M5YWyOb6R032rys6qY2sgpYw+dgECJA8uEnsdUcZpzwr2h10xIgt9opBw kGsg== 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 t5si1080189edd.296.2021.02.10.02.15.24; Wed, 10 Feb 2021 02:15:48 -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 S229812AbhBJKOy (ORCPT + 99 others); Wed, 10 Feb 2021 05:14:54 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:53692 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230390AbhBJKHQ (ORCPT ); Wed, 10 Feb 2021 05:07:16 -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 11AA4I7m019059; Wed, 10 Feb 2021 05:06:24 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 36hrw8v4b1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 05:06:23 -0500 Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 11AA6MDg025921 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Feb 2021 05:06:22 -0500 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) 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; Wed, 10 Feb 2021 05:06:22 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.721.2; Wed, 10 Feb 2021 05:06:21 -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; Wed, 10 Feb 2021 05:06:21 -0500 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 11AA5x0H018045; Wed, 10 Feb 2021 05:06:19 -0500 From: Alexandru Ardelean To: , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v4 11/17] iio: buffer: move __iio_buffer_free_sysfs_and_mask() before alloc Date: Wed, 10 Feb 2021 12:08:17 +0200 Message-ID: <20210210100823.46780-12-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210210100823.46780-1-alexandru.ardelean@analog.com> References: <20210210100823.46780-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-10_03:2021-02-10,2021-02-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 mlxlogscore=862 clxscore=1015 adultscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100097 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 a6148ed24e41..209b3a32bdbb 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