Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4324767pxb; Sun, 14 Feb 2021 06:36:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBFBLmOeHqaYznIwzMgsmF0xUMXr3BInCB1fEMmL0W8L3PC6BqnhFyJwWz4OL0rQsSdKvJ X-Received: by 2002:a17:906:19cf:: with SMTP id h15mr12016809ejd.167.1613313388169; Sun, 14 Feb 2021 06:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613313388; cv=none; d=google.com; s=arc-20160816; b=xSH1tiCYlfsOwLhYT4V3tfj69LQx1rfm9gHihXIlU/5zCSQP7hQ7kaFF/yuy6r2EFK E9AIVAWw8KudMlO4jUXJbVJalQppUSOfOO/EFvAmMYj7XkL34q6mU34hdbnFcsXo5uWe OFXCDtdT18EQsFLxMdxpIgmR7q1pfGqRxTrH7lvDJWwAH2d/WUPrbLErNEIiIwxkiFFS Lgn13R0kqILcKXhNAnrM6ISWbzIyq8EaRuFWdR+h2PTLwR8YoqaxIQcWABxTmuk+/VCd OJFxUcVWk+V/NdZMMGxcqRLFOoqezupVfLU5fRE/NgTcfMtqLTkYjXhRnYdySU0YIZDV EoCA== 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=B0hzTWcfD4g+Hzj6JIwv+pFX9KpGYGIC3MfFOtMKy2U=; b=VbLwqpynYFXc/ezDbiuSWIxxi2IahjkrKgL1f0aqBnfalg3iHzXoc3xD5E3gUjECRF LtTl2sJF70b2FIAQZc++64ed+j+Fb/4lhDYbWo4h3cy+yHwe3WgIqndtchJCh++TWCVr 9GtujgqRxzzcOrEAAjLsFUAl+72yPt3W34eRgYcIW9eBzRPtZngColjbHFmjpoANz3dk w4gSb08jXxmHvewVCTiAVQJFdmLIn4YANVIFPQelz68Rrfd8fKI68vagqtLGm8YI+nEv QmBNHkDlSliEZ9WjEgFfzMUv9ADYYHgTNp1vEnS7oXVXfM4Z9BPlY9ZOb7oOxwg+yZzq CPtw== 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 gb20si10072378ejc.183.2021.02.14.06.36.05; Sun, 14 Feb 2021 06:36:28 -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 S229889AbhBNOcI (ORCPT + 99 others); Sun, 14 Feb 2021 09:32:08 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:17962 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbhBNOcF (ORCPT ); Sun, 14 Feb 2021 09:32:05 -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 11EESZoh012183; Sun, 14 Feb 2021 09:31:13 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 36p9gathg3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Feb 2021 09:31:13 -0500 Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 11EEVC62054475 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Sun, 14 Feb 2021 09:31:12 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Sun, 14 Feb 2021 09:31:11 -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; Sun, 14 Feb 2021 09:31:11 -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; Sun, 14 Feb 2021 09:31:11 -0500 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 11EEV2tt027551; Sun, 14 Feb 2021 09:31:09 -0500 From: Alexandru Ardelean To: , CC: , , , , , Alexandru Ardelean Subject: [PATCH 4/5] iio: accel: sca3000: use devm_iio_kfifo_buffer_setup() helper Date: Sun, 14 Feb 2021 16:33:12 +0200 Message-ID: <20210214143313.67202-5-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210214143313.67202-1-alexandru.ardelean@analog.com> References: <20210214143313.67202-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-14_04:2021-02-12,2021-02-14 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-2102140120 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change makes use of the devm_iio_kfifo_buffer_setup() helper, however the unwind order is changed. The life-time of the kfifo object is attached to the parent device object. This is to make the driver a bit more consistent with the other IIO drivers, even though (as it is now before this change) it shouldn't be a problem. Signed-off-by: Alexandru Ardelean --- drivers/iio/accel/sca3000.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c index 194738660523..467b5fcb81db 100644 --- a/drivers/iio/accel/sca3000.c +++ b/drivers/iio/accel/sca3000.c @@ -1272,20 +1272,6 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev, return ret; } -static int sca3000_configure_ring(struct iio_dev *indio_dev) -{ - struct iio_buffer *buffer; - - buffer = devm_iio_kfifo_allocate(&indio_dev->dev); - if (!buffer) - return -ENOMEM; - - iio_device_attach_buffer(indio_dev, buffer); - indio_dev->modes |= INDIO_BUFFER_SOFTWARE; - - return 0; -} - static inline int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state) { @@ -1479,7 +1465,9 @@ static int sca3000_probe(struct spi_device *spi) } indio_dev->modes = INDIO_DIRECT_MODE; - ret = sca3000_configure_ring(indio_dev); + ret = devm_iio_kfifo_buffer_setup(&spi->dev, indio_dev, + INDIO_BUFFER_SOFTWARE, + &sca3000_ring_setup_ops); if (ret) return ret; @@ -1493,7 +1481,6 @@ static int sca3000_probe(struct spi_device *spi) if (ret) return ret; } - indio_dev->setup_ops = &sca3000_ring_setup_ops; ret = sca3000_clean_setup(st); if (ret) goto error_free_irq; -- 2.17.1