Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2103135pxb; Thu, 11 Feb 2021 04:35:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKz3nOoOjgjurCDjBgMeyphvNZ5jtnt9+JZcQU5DwhgptqOt2Ag+A3Nh2gkfyGYAsgQB2J X-Received: by 2002:a17:906:c299:: with SMTP id r25mr8435100ejz.80.1613046921752; Thu, 11 Feb 2021 04:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613046921; cv=none; d=google.com; s=arc-20160816; b=iGmEHhMiKiHMB1xq8do2oogWDvNr1Hvg6WdEn+rD8p0sgfRUAJ8Ra5kzGx5tvibXFV cy5ypbho5j+iqDqlmu+z2mf80T/noCqitb2Nzg7/pu/0kRlHMheY3P3bFFWuDNxezu0p LfpexlL4ycmwVhyan7VAbC/aNYiMPUX1SRWAaCuYYOO+4UIjcPXLPmi971z8alkKZBvM GgZPeuIuZEhDUanTdCa/ipezfHMVlaHH+eloQX5WtxNDVnepoU2M2MshQllUlO0+vMi7 jKCCKqP6I5iqhcZTvMRecfvVqTHqOpsATQnwPcZu2JggDAqX+CWk3LRYn+CS+y130NnD Gm1A== 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=Pz1iCNML0DJ+sSm5dddBJQDDUjiLxDpkCT9CVjowZltcRdWRl7m3v5Y6UJ8UdZ9vc0 NgaW1WR4Om3omgubbuO02HDboyALKfoWBJGnqRbxLQq+Mdvgh19t24Crpw5+K2WB9v3J 5WjLd/LnMkigmNCpP0Gc7T4NnMOp/xocKRGgky3eHVboxxejFNb327JKjsL/UbRWriV2 ZDKMg3vTXEXqA6Wg4vpQQbFvrF5WEI6DHF5qM0KOkbBNRVzMQST2CT83CaSkNvgryzIn IzpoaePPyiiIgYkxrM4/hnLb5Y+ge8dAenlt/O7nJ3Zdbur81S6Vt1HXe78hZ6ODgJt3 zyiQ== 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 j8si3650928edv.130.2021.02.11.04.34.58; Thu, 11 Feb 2021 04:35: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 S231718AbhBKMdU (ORCPT + 99 others); Thu, 11 Feb 2021 07:33:20 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:31820 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbhBKMXx (ORCPT ); Thu, 11 Feb 2021 07:23:53 -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 11BCMfVD016207; Thu, 11 Feb 2021 07:23:00 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 36hr7qg8w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Feb 2021 07:23:00 -0500 Received: from SCSQMBX10.ad.analog.com (SCSQMBX10.ad.analog.com [10.77.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 11BCMwTZ004279 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 11 Feb 2021 07:22:59 -0500 Received: from SCSQMBX10.ad.analog.com (10.77.17.5) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Thu, 11 Feb 2021 04:22:57 -0800 Received: from zeus.spd.analog.com (10.66.68.11) by scsqmbx10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server id 15.2.721.2 via Frontend Transport; Thu, 11 Feb 2021 04:22:57 -0800 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 11BCMYWj011557; Thu, 11 Feb 2021 07:22:54 -0500 From: Alexandru Ardelean To: , CC: , , , , , , , Alexandru Ardelean Subject: [PATCH v5 11/17] iio: buffer: move __iio_buffer_free_sysfs_and_mask() before alloc Date: Thu, 11 Feb 2021 14:24:46 +0200 Message-ID: <20210211122452.78106-12-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210211122452.78106-1-alexandru.ardelean@analog.com> References: <20210211122452.78106-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-11_05:2021-02-10,2021-02-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=867 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110110 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