From patchwork Tue Sep 15 12:02:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nuno Sa X-Patchwork-Id: 11776279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D498618 for ; Tue, 15 Sep 2020 12:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4770321D43 for ; Tue, 15 Sep 2020 12:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726460AbgIOMC1 (ORCPT ); Tue, 15 Sep 2020 08:02:27 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:58654 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIOMB5 (ORCPT ); Tue, 15 Sep 2020 08:01:57 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08FBtDEa002322; Tue, 15 Sep 2020 08:01:37 -0400 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 33h7pr8s4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Sep 2020 08:01:36 -0400 Received: from SCSQMBX10.ad.analog.com (scsqmbx10.ad.analog.com [10.77.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 08FC1ZpO007761 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Tue, 15 Sep 2020 08:01:35 -0400 Received: from SCSQCASHYB7.ad.analog.com (10.77.17.133) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 15 Sep 2020 05:01:43 -0700 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.1.1779.2; Tue, 15 Sep 2020 05:01:43 -0700 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; Tue, 15 Sep 2020 05:01:43 -0700 Received: from nsa.sphairon.box ([10.44.3.98]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 08FC1K9v004525; Tue, 15 Sep 2020 08:01:30 -0400 From: =?utf-8?q?Nuno_S=C3=A1?= To: , CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "Hartmut Knaack" , Peter Meerwald-Stadler , "Dragos Bogdan" , Greg Kroah-Hartman , Alexandru Ardelean Subject: [PATCH v2 04/10] iio: adis16260: Use Managed device functions Date: Tue, 15 Sep 2020 14:02:52 +0200 Message-ID: <20200915120258.161587-5-nuno.sa@analog.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915120258.161587-1-nuno.sa@analog.com> References: <20200915120258.161587-1-nuno.sa@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-15_08:2020-09-15,2020-09-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 impostorscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009150103 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use the adis managed device functions to setup the buffer and the trigger. The ultimate goal will be to completely drop the non devm version from the lib. Since we are here, drop the `.remove` callback by further using devm functions. Signed-off-by: Nuno Sá --- Changes in v2: * Further use devm functions to keep cleanup order and to drop `.remove`. drivers/iio/gyro/adis16260.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c index e638d56e1574..e7c9a3e31c45 100644 --- a/drivers/iio/gyro/adis16260.c +++ b/drivers/iio/gyro/adis16260.c @@ -359,6 +359,11 @@ static const struct adis_data adis16260_data = { BIT(ADIS16260_DIAG_STAT_POWER_LOW_BIT), }; +static void adis16260_stop(void *data) +{ + adis16260_stop_device(data); +} + static int adis16260_probe(struct spi_device *spi) { const struct spi_device_id *id; @@ -390,35 +395,20 @@ static int adis16260_probe(struct spi_device *spi) if (ret) return ret; - ret = adis_setup_buffer_and_trigger(&adis16260->adis, indio_dev, NULL); + ret = devm_adis_setup_buffer_and_trigger(&adis16260->adis, indio_dev, NULL); if (ret) return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(&adis16260->adis); if (ret) - goto error_cleanup_buffer_trigger; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_buffer_trigger; - - return 0; - -error_cleanup_buffer_trigger: - adis_cleanup_buffer_and_trigger(&adis16260->adis, indio_dev); - return ret; -} - -static int adis16260_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct adis16260 *adis16260 = iio_priv(indio_dev); + return ret; - iio_device_unregister(indio_dev); - adis16260_stop_device(indio_dev); - adis_cleanup_buffer_and_trigger(&adis16260->adis, indio_dev); + ret = devm_add_action_or_reset(&spi->dev, adis16260_stop, indio_dev); + if (ret) + return ret; - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } /* @@ -441,7 +431,6 @@ static struct spi_driver adis16260_driver = { .name = "adis16260", }, .probe = adis16260_probe, - .remove = adis16260_remove, .id_table = adis16260_id, }; module_spi_driver(adis16260_driver);