From patchwork Sun May 16 17:25:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CE66C433B4 for ; Sun, 16 May 2021 17:26:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F02A861152 for ; Sun, 16 May 2021 17:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbhEPR1e (ORCPT ); Sun, 16 May 2021 13:27:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:59618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhEPR1d (ORCPT ); Sun, 16 May 2021 13:27:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B74061159; Sun, 16 May 2021 17:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185978; bh=LpiHka1EIuPa779mW+4es5KZEQybmHDUQyuiTZUGc7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=adwxmeX8pbivvjveK7pwvlc7ph4RYQX9+s1Gjq7x2Z6wzvJPDWKEa6lnrYcFWpU6r RUjz7i1M5O96bWe7EIWEllg96DJDPU+v2wzOWBwWtoeC3aQtoJXVwUieqgOfsSFcvU rrK2LKLuO3fhkL0oiv0zpnK+OKNB86BWztt++UzMzBIYj5voqEQbPtEL8EDC1AhibR lx/zyVMq0j47NkRx7kiy7D6/GO1zM/Wc6sMII1P+eqxv+J+3TF5wejsjbEQsTQJplR L2QjEvT7VtO8I4pC4t5SsmM0Lm54imawoVUXxp+dJBRbkSeESJA0Ma+mV3HPNJcUyL bpHXXxJrZPm2g== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Jacopo Mondi Subject: [PATCH 1/8] iio: adc: max11100: Use get_unaligned_be16() rather than opencoding. Date: Sun, 16 May 2021 18:25:13 +0100 Message-Id: <20210516172520.1398835-2-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron The function is more explicit in showing the intent + quicker on some platforms. Signed-off-by: Jonathan Cameron Cc: Jacopo Mondi Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/max11100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c index 6cf21758ca66..69d607fa17aa 100644 --- a/drivers/iio/adc/max11100.c +++ b/drivers/iio/adc/max11100.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -63,7 +64,7 @@ static int max11100_read_single(struct iio_dev *indio_dev, int *val) return -EINVAL; } - *val = (state->buffer[1] << 8) | state->buffer[2]; + *val = get_unaligned_be16(&state->buffer[1]); return 0; } From patchwork Sun May 16 17:25:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF49CC433ED for ; Sun, 16 May 2021 17:26:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91FC961152 for ; Sun, 16 May 2021 17:26:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbhEPR1f (ORCPT ); Sun, 16 May 2021 13:27:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:59632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhEPR1f (ORCPT ); Sun, 16 May 2021 13:27:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53EA461177; Sun, 16 May 2021 17:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185980; bh=MkBShWInBBKLb1CiyuTUAIh7WKX0gA0vh4BO9OKZ9gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JkY2EbZAdC7BJ9UlXvKMDTFdWgbIAy4T9hJeEaHcqGpzUt3Pahp/o3WKdazlr+2cj NKbMypoW+IsEnzRn1rBSQyJzZjmukeL4ujgyVTdcGjdg0WhekM3i+orv5EN329Dd6Q RmmOrEbJGDz8M06fB/XDzisQod6Cb5sKhbPcs6fjRy22ICfzz7fIDigeVu2+GnbrSC Tt6wBTLY1aHARmTxh14O6HsoAqXtlRi638+JeuZuuTm82MP6IYi7l2On6YTDdbHi8a nygxxQ8Be8EPpuZ2RwDIqsAV4OaBYvxwqejWvGZlCzSN1uahN9Ue5KvvVXmLN2uaH5 chuVnzYqlX3Ug== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Jacopo Mondi Subject: [PATCH 2/8] iio: adc: max11100: Use devm_ functions for rest of probe() Date: Sun, 16 May 2021 18:25:14 +0100 Message-Id: <20210516172520.1398835-3-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron By using devm_add_action_or_reset() to manage the regulator disable, it becomes simple to use managed functions for all of remove. This simplifies error handling and allows us to drop the remove() function entirely. Signed-off-by: Jonathan Cameron Cc: Jacopo Mondi Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/max11100.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c index 69d607fa17aa..9951f6a6a4b9 100644 --- a/drivers/iio/adc/max11100.c +++ b/drivers/iio/adc/max11100.c @@ -102,6 +102,11 @@ static const struct iio_info max11100_info = { .read_raw = max11100_read_raw, }; +static void max11100_regulator_disable(void *reg) +{ + regulator_disable(reg); +} + static int max11100_probe(struct spi_device *spi) { int ret; @@ -131,27 +136,12 @@ static int max11100_probe(struct spi_device *spi) if (ret) return ret; - ret = iio_device_register(indio_dev); + ret = devm_add_action_or_reset(&spi->dev, max11100_regulator_disable, + state->vref_reg); if (ret) - goto disable_regulator; - - return 0; - -disable_regulator: - regulator_disable(state->vref_reg); - - return ret; -} - -static int max11100_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct max11100_state *state = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - regulator_disable(state->vref_reg); + return ret; - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct of_device_id max11100_ids[] = { @@ -166,7 +156,6 @@ static struct spi_driver max11100_driver = { .of_match_table = max11100_ids, }, .probe = max11100_probe, - .remove = max11100_remove, }; module_spi_driver(max11100_driver); From patchwork Sun May 16 17:25:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA13CC433ED for ; Sun, 16 May 2021 17:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAF9D61152 for ; Sun, 16 May 2021 17:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhEPR1i (ORCPT ); Sun, 16 May 2021 13:27:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:59644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbhEPR1h (ORCPT ); Sun, 16 May 2021 13:27:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4695D61185; Sun, 16 May 2021 17:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185982; bh=vcGighXB/nwMBylhUKgt5zNuF4UXauX4YRaDaFit/2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GzipMHge0evsMyVTQpfAQl5ynqOJWdThb/xhBbfMYldX27z8noZTSn45hMz7RV8Nm GJxCT7uvSuLMaYCDi9xTRt8rZW7NADtgrY5AtapHFbgkCK/M/2YqrZSIIZUfXUQRVN 8bNkYRt9kkFBkrpaKVAprYghDg5n8yXYaxSyUHCjYl7MPdS74T/0p8/7OniQuoa4T7 GQWH/+qvbkRJfJqMkVpUeYcOzjFXNrk2shXDXKjQl7XMoPlz2SrjgrZSRroNOk9Rzw atAJ1ej0dVcPIEyCpg5z0xGreWFwoY4RP6E9jgcLo89+qMobt+8kkd0Z+quHDmdRvI 1zIk/fQbegmgg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Akinobu Mita Subject: [PATCH 3/8] iio: adc: max1118: Use devm_ managed functions for all of probe Date: Sun, 16 May 2021 18:25:15 +0100 Message-Id: <20210516172520.1398835-4-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This simplifies error handling and allows us to drop the remove function entirely. Signed-off-by: Jonathan Cameron Cc: Akinobu Mita Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/max1118.c | 46 +++++++++++++-------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/drivers/iio/adc/max1118.c b/drivers/iio/adc/max1118.c index 6efb0b43d938..4dfbed63ad7f 100644 --- a/drivers/iio/adc/max1118.c +++ b/drivers/iio/adc/max1118.c @@ -201,6 +201,11 @@ static irqreturn_t max1118_trigger_handler(int irq, void *p) return IRQ_HANDLED; } +static void max1118_reg_disable(void *reg) +{ + regulator_disable(reg); +} + static int max1118_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -225,6 +230,12 @@ static int max1118_probe(struct spi_device *spi) ret = regulator_enable(adc->reg); if (ret) return ret; + + ret = devm_add_action_or_reset(&spi->dev, max1118_reg_disable, + adc->reg); + if (ret) + return ret; + } spi_set_drvdata(spi, indio_dev); @@ -243,38 +254,12 @@ static int max1118_probe(struct spi_device *spi) */ max1118_read(spi, 0); - ret = iio_triggered_buffer_setup(indio_dev, NULL, - max1118_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + max1118_trigger_handler, NULL); if (ret) - goto err_reg_disable; - - ret = iio_device_register(indio_dev); - if (ret) - goto err_buffer_cleanup; - - return 0; - -err_buffer_cleanup: - iio_triggered_buffer_cleanup(indio_dev); -err_reg_disable: - if (id->driver_data == max1118) - regulator_disable(adc->reg); - - return ret; -} - -static int max1118_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct max1118 *adc = iio_priv(indio_dev); - const struct spi_device_id *id = spi_get_device_id(spi); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - if (id->driver_data == max1118) - return regulator_disable(adc->reg); + return ret; - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct spi_device_id max1118_id[] = { @@ -299,7 +284,6 @@ static struct spi_driver max1118_spi_driver = { .of_match_table = max1118_dt_ids, }, .probe = max1118_probe, - .remove = max1118_remove, .id_table = max1118_id, }; module_spi_driver(max1118_spi_driver); From patchwork Sun May 16 17:25:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA669C433B4 for ; Sun, 16 May 2021 17:26:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABCFB61177 for ; Sun, 16 May 2021 17:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbhEPR1k (ORCPT ); Sun, 16 May 2021 13:27:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:59652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbhEPR1j (ORCPT ); Sun, 16 May 2021 13:27:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B47A6113C; Sun, 16 May 2021 17:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185984; bh=WgsdGjl7K3U06WP6xQkfrnSCbQdo5kcQBcD9QNnUFCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vLfLyFUatNyvpx26wFHtJ03fJWYl0rpx0/tCZK176jKnjtox5MVuaISJfN2kvqDWN fOISBv/ignAIb1tBQZllnViuB1JFUGjqPa/pHSCbLpcS8Ylu6LgGd9IeDUX0aBiOl3 NSmPrYiJYbV8R+E4+IZyJmAfw7G/qRjWwvKPN/5KezJfDPKxVthHiZwSksMWVMn6zw oZi8Hk6PQ47ns9VQd6fYsONMP0SFJ62+lfbiEPnRu00IWULHXhi+2SfVqKto1H69Cj RnkbdGJfzNytreBxPm//rMIAts8drylDw4KVWCYyco1iXTiGJukbAJtOtChI0Lbj+6 7Udj7Tis+4WBA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron Subject: [PATCH 4/8] iio: adc: max1118: Avoid jumping back and forth between spi and iio structures Date: Sun, 16 May 2021 18:25:16 +0100 Message-Id: <20210516172520.1398835-5-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Changing from passing the spi structure into various functions to passing struct iio_dev avoids use of spi_get_drvdata and lets us stop setting that at all. Previous code was unnecessarily complex. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/max1118.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/max1118.c b/drivers/iio/adc/max1118.c index 4dfbed63ad7f..8cec9d949083 100644 --- a/drivers/iio/adc/max1118.c +++ b/drivers/iio/adc/max1118.c @@ -66,9 +66,8 @@ static const struct iio_chan_spec max1118_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(2), }; -static int max1118_read(struct spi_device *spi, int channel) +static int max1118_read(struct iio_dev *indio_dev, int channel) { - struct iio_dev *indio_dev = spi_get_drvdata(spi); struct max1118 *adc = iio_priv(indio_dev); struct spi_transfer xfers[] = { /* @@ -103,9 +102,9 @@ static int max1118_read(struct spi_device *spi, int channel) int ret; if (channel == 0) - ret = spi_sync_transfer(spi, xfers + 1, 2); + ret = spi_sync_transfer(adc->spi, xfers + 1, 2); else - ret = spi_sync_transfer(spi, xfers, 3); + ret = spi_sync_transfer(adc->spi, xfers, 3); if (ret) return ret; @@ -113,11 +112,10 @@ static int max1118_read(struct spi_device *spi, int channel) return adc->data; } -static int max1118_get_vref_mV(struct spi_device *spi) +static int max1118_get_vref_mV(struct iio_dev *indio_dev) { - struct iio_dev *indio_dev = spi_get_drvdata(spi); struct max1118 *adc = iio_priv(indio_dev); - const struct spi_device_id *id = spi_get_device_id(spi); + const struct spi_device_id *id = spi_get_device_id(adc->spi); int vref_uV; switch (id->driver_data) { @@ -144,14 +142,14 @@ static int max1118_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: mutex_lock(&adc->lock); - *val = max1118_read(adc->spi, chan->channel); + *val = max1118_read(indio_dev, chan->channel); mutex_unlock(&adc->lock); if (*val < 0) return *val; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val = max1118_get_vref_mV(adc->spi); + *val = max1118_get_vref_mV(indio_dev); if (*val < 0) return *val; *val2 = 8; @@ -180,7 +178,7 @@ static irqreturn_t max1118_trigger_handler(int irq, void *p) indio_dev->masklength) { const struct iio_chan_spec *scan_chan = &indio_dev->channels[scan_index]; - int ret = max1118_read(adc->spi, scan_chan->channel); + int ret = max1118_read(indio_dev, scan_chan->channel); if (ret < 0) { dev_warn(&adc->spi->dev, @@ -238,8 +236,6 @@ static int max1118_probe(struct spi_device *spi) } - spi_set_drvdata(spi, indio_dev); - indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &max1118_info; indio_dev->modes = INDIO_DIRECT_MODE; @@ -252,7 +248,7 @@ static int max1118_probe(struct spi_device *spi) * a conversion has been completed, the MAX1117/MAX1118/MAX1119 will go * into AutoShutdown mode until the next conversion is initiated. */ - max1118_read(spi, 0); + max1118_read(indio_dev, 0); ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, max1118_trigger_handler, NULL); From patchwork Sun May 16 17:25:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6357CC433ED for ; Sun, 16 May 2021 17:26:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4496E6113C for ; Sun, 16 May 2021 17:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230095AbhEPR1m (ORCPT ); Sun, 16 May 2021 13:27:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:59662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhEPR1l (ORCPT ); Sun, 16 May 2021 13:27:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 44DB861159; Sun, 16 May 2021 17:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185986; bh=wC6NGX0CdW+D0twiApCtPQfyK7VKTpDO3JIp9AfM7s4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s9ekQCr3q1p2NcJ52QXJ0zdn3OwCV/AmVsPvyB+9PX9+gtjkS3PUpuTNt0Q38JLzI baAD2JhQCjHpPJhjXuRbtS8rT7hoZz1rDLM2ZEiDSH0lqjZsZ60naUF9CisajY2ibR 3bqJxJU8ytQ+z1hUA6bM07pWGmiy4fEUbtSLdhP4UcSfQIZVcBViSGFN4KzDN7/6dS rV3mwNCu0Opkpr406aSUzVF7x7Od4SZy+SI+iSq/2wpbaDEt0tyCd3MK/On8by/1lO /uEw4jLTahDLdczhuv94oAOtowhQ2E+CK2pu/yfQUctz2h6Z9ASG4jWWS84VAJ43xf rJqaEOXH8gWdQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron Subject: [PATCH 5/8] iio: adc: ti-adc081c: Use devm managed functions for all of probe() Date: Sun, 16 May 2021 18:25:17 +0100 Message-Id: <20210516172520.1398835-6-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Simplifies error handling and allows us to drop remove() entirely. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/ti-adc081c.c | 43 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index b64718daa201..16fc608db36a 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -146,6 +146,11 @@ static irqreturn_t adc081c_trigger_handler(int irq, void *p) return IRQ_HANDLED; } +static void adc081c_reg_disable(void *reg) +{ + regulator_disable(reg); +} + static int adc081c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -175,6 +180,11 @@ static int adc081c_probe(struct i2c_client *client, if (err < 0) return err; + err = devm_add_action_or_reset(&client->dev, adc081c_reg_disable, + adc->ref); + if (err) + return err; + iio->name = dev_name(&client->dev); iio->modes = INDIO_DIRECT_MODE; iio->info = &adc081c_info; @@ -182,38 +192,14 @@ static int adc081c_probe(struct i2c_client *client, iio->channels = model->channels; iio->num_channels = ADC081C_NUM_CHANNELS; - err = iio_triggered_buffer_setup(iio, NULL, adc081c_trigger_handler, NULL); + err = devm_iio_triggered_buffer_setup(&client->dev, iio, NULL, + adc081c_trigger_handler, NULL); if (err < 0) { dev_err(&client->dev, "iio triggered buffer setup failed\n"); - goto err_regulator_disable; + return err; } - err = iio_device_register(iio); - if (err < 0) - goto err_buffer_cleanup; - - i2c_set_clientdata(client, iio); - - return 0; - -err_buffer_cleanup: - iio_triggered_buffer_cleanup(iio); -err_regulator_disable: - regulator_disable(adc->ref); - - return err; -} - -static int adc081c_remove(struct i2c_client *client) -{ - struct iio_dev *iio = i2c_get_clientdata(client); - struct adc081c *adc = iio_priv(iio); - - iio_device_unregister(iio); - iio_triggered_buffer_cleanup(iio); - regulator_disable(adc->ref); - - return 0; + return devm_iio_device_register(&client->dev, iio); } static const struct i2c_device_id adc081c_id[] = { @@ -238,7 +224,6 @@ static struct i2c_driver adc081c_driver = { .of_match_table = adc081c_of_match, }, .probe = adc081c_probe, - .remove = adc081c_remove, .id_table = adc081c_id, }; module_i2c_driver(adc081c_driver); From patchwork Sun May 16 17:25:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1879C433B4 for ; Sun, 16 May 2021 17:26:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1BF36113C for ; Sun, 16 May 2021 17:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbhEPR1n (ORCPT ); Sun, 16 May 2021 13:27:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:59670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhEPR1n (ORCPT ); Sun, 16 May 2021 13:27:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A12661177; Sun, 16 May 2021 17:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185988; bh=MjUfJKUaNt5QBQpBVsED2ywmZ8xShQiagy03eEw5FRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZHbWsro8VpEf4Z7VZIG+zeS4/i4Yjo4ikkhO4wtXBSTkwVTndngoPlWCEcmU/NVw ojqciDn3vTaSohSMSDRTFzIFFqLlALpGXJX39dsX/4MlZIa1A97pwnAW+fMGvTCwkU FMoigIR/zsrmUCdH5josZ8us0X+iw8LsVpHGylypMuvF5C/bjgOu62pFwKrfXQFAU1 cEvNGC6nVp2U0KNiNa6nmyIFa/dHYHDc/WScE7JFdQDM5El6P2k/Df/u5fgtfpmgq7 XOBfVwyoR70WGaDT4kvaEEwVo6VITKDjzlh+adJfPqN9rva3B3Lh1lcUXyx3JFzXgP nkcUzKBgmARUQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Akinobu Mita Subject: [PATCH 6/8] iio: adc: ti-adc0832: Use devm managed functions for all of probe() Date: Sun, 16 May 2021 18:25:18 +0100 Message-Id: <20210516172520.1398835-7-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Simplifies error handling, plus allows us to drop the remove() function entirely. Signed-off-by: Jonathan Cameron Cc: Akinobu Mita Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/ti-adc0832.c | 39 +++++++++++------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c index 0261b3cfc92b..fb5e72600b96 100644 --- a/drivers/iio/adc/ti-adc0832.c +++ b/drivers/iio/adc/ti-adc0832.c @@ -236,6 +236,11 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p) return IRQ_HANDLED; } +static void adc0832_reg_disable(void *reg) +{ + regulator_disable(reg); +} + static int adc0832_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -287,36 +292,17 @@ static int adc0832_probe(struct spi_device *spi) if (ret) return ret; - spi_set_drvdata(spi, indio_dev); - - ret = iio_triggered_buffer_setup(indio_dev, NULL, - adc0832_trigger_handler, NULL); + ret = devm_add_action_or_reset(&spi->dev, adc0832_reg_disable, + adc->reg); if (ret) - goto err_reg_disable; + return ret; - ret = iio_device_register(indio_dev); + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + adc0832_trigger_handler, NULL); if (ret) - goto err_buffer_cleanup; - - return 0; -err_buffer_cleanup: - iio_triggered_buffer_cleanup(indio_dev); -err_reg_disable: - regulator_disable(adc->reg); - - return ret; -} - -static int adc0832_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct adc0832 *adc = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(adc->reg); + return ret; - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct of_device_id adc0832_dt_ids[] = { @@ -343,7 +329,6 @@ static struct spi_driver adc0832_driver = { .of_match_table = adc0832_dt_ids, }, .probe = adc0832_probe, - .remove = adc0832_remove, .id_table = adc0832_id, }; module_spi_driver(adc0832_driver); From patchwork Sun May 16 17:25:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 676EDC43460 for ; Sun, 16 May 2021 17:26:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 462646113C for ; Sun, 16 May 2021 17:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbhEPR1p (ORCPT ); Sun, 16 May 2021 13:27:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:59678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhEPR1p (ORCPT ); Sun, 16 May 2021 13:27:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1198761152; Sun, 16 May 2021 17:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185990; bh=EUl4UrCZlkYhrr8A5mA8PR0dEHDpfyRuzx+44D3rhuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CPhZQV23LB1IVooE3oqk1oWS4qK4XAs1Q5guM1oup1sOHzj6nzlUBT7DGfX7fhtr1 gAc8YoIveb8JO3AvA0WeIQZeFKmSHgX+xT8I0JtlQPQDd+u+C6OBryoISxKEysaV5P wc+s4iNyGz5fm8NyxVoYBSXWyIcZqg3ESczyF/0KWddK3IWERzSIUYdZe1vc+mWp6K FAr9XtDEIt3EiAZgodeeIrXck5Hw0ApShbLyzayDXAlknJ+15VBtEQIVmdopVtjCTz sI5CoCAhlBRZKBIFUDAeHib+yTKVJZ4Ockvn3KNIkyHPZegYLYNYYkeLBGLKfbEUTY ie80BUWykzE9A== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Bogdan Pricop Subject: [PATCH 7/8] iio: adc: ti-adc108s102: Use devm managed functions for all of probe() Date: Sun, 16 May 2021 18:25:19 +0100 Message-Id: <20210516172520.1398835-8-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Simplifies error handling and lets us drop remove() entirely. Signed-off-by: Jonathan Cameron Cc: Bogdan Pricop Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/ti-adc108s102.c | 45 +++++++++++---------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/iio/adc/ti-adc108s102.c b/drivers/iio/adc/ti-adc108s102.c index 183b2245e89b..db902aef2abe 100644 --- a/drivers/iio/adc/ti-adc108s102.c +++ b/drivers/iio/adc/ti-adc108s102.c @@ -215,6 +215,11 @@ static const struct iio_info adc108s102_info = { .update_scan_mode = &adc108s102_update_scan_mode, }; +static void adc108s102_reg_disable(void *reg) +{ + regulator_disable(reg); +} + static int adc108s102_probe(struct spi_device *spi) { struct adc108s102_state *st; @@ -239,6 +244,10 @@ static int adc108s102_probe(struct spi_device *spi) dev_err(&spi->dev, "Cannot enable vref regulator\n"); return ret; } + ret = devm_add_action_or_reset(&spi->dev, adc108s102_reg_disable, + st->reg); + if (ret) + return ret; ret = regulator_get_voltage(st->reg); if (ret < 0) { @@ -249,7 +258,6 @@ static int adc108s102_probe(struct spi_device *spi) st->va_millivolt = ret / 1000; } - spi_set_drvdata(spi, indio_dev); st->spi = spi; indio_dev->name = spi->modalias; @@ -266,40 +274,18 @@ static int adc108s102_probe(struct spi_device *spi) spi_message_init_with_transfers(&st->scan_single_msg, &st->scan_single_xfer, 1); - ret = iio_triggered_buffer_setup(indio_dev, NULL, - &adc108s102_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + &adc108s102_trigger_handler, + NULL); if (ret) - goto error_disable_reg; + return ret; - ret = iio_device_register(indio_dev); - if (ret) { + ret = devm_iio_device_register(&spi->dev, indio_dev); + if (ret) dev_err(&spi->dev, "Failed to register IIO device\n"); - goto error_cleanup_triggered_buffer; - } - return 0; - -error_cleanup_triggered_buffer: - iio_triggered_buffer_cleanup(indio_dev); - -error_disable_reg: - regulator_disable(st->reg); - return ret; } -static int adc108s102_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct adc108s102_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - - regulator_disable(st->reg); - - return 0; -} - static const struct of_device_id adc108s102_of_match[] = { { .compatible = "ti,adc108s102" }, { } @@ -327,7 +313,6 @@ static struct spi_driver adc108s102_driver = { .acpi_match_table = ACPI_PTR(adc108s102_acpi_ids), }, .probe = adc108s102_probe, - .remove = adc108s102_remove, .id_table = adc108s102_id, }; module_spi_driver(adc108s102_driver); From patchwork Sun May 16 17:25:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FF3AC433ED for ; Sun, 16 May 2021 17:26:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3459D6109F for ; Sun, 16 May 2021 17:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbhEPR1s (ORCPT ); Sun, 16 May 2021 13:27:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:59700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbhEPR1r (ORCPT ); Sun, 16 May 2021 13:27:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F19061159; Sun, 16 May 2021 17:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621185992; bh=FYLnYsIF9gx0a4haz/QfWKTSPpLrKEedYkGMqxKASII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oKee4MHgjdCARmdzOJsk8xAWfsGBhyrTRLPgzpvmRcRgkzPfx3dTN5XysgxtkpVwM q728YU4y39Nj0a0UNC2La1110G3u6s5s0jajx18eUcX/rXMY40s406okOhxufB6I8T irRVNQcQ3Fu5AR7sERoEx5Ju0lDSqKjlQlCmITa74NytaN3ljd+2Gru4z4rrQHYWid ROMF1KkBeBheZXzhaPkDvvXQWibi8ehoDOahgWm8OwtFSoGBLF5VY9Zwtdkr8w+CPW YK7xSxG71bqVZ/N2Ix3liIt5cD8PhLqnZNcpDckRE673WbZnO8izVzByzp4PJxCHKJ dHYwkqdJS4j7A== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Matt Ranostay Subject: [PATCH 8/8] iio: adc: ti-adc161s626: Use devm managed functions for all of probe. Date: Sun, 16 May 2021 18:25:20 +0100 Message-Id: <20210516172520.1398835-9-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516172520.1398835-1-jic23@kernel.org> References: <20210516172520.1398835-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Simplifies error handling and allows us to drop remove entirely. The regulator handling in this driver was unusual as it would try to acquire the regulator, but if that failed with an error would continue. We should get a stub regulator if one isn't provided in DT and an error could indicate an actual problem preventing the device being powered (perhaps a need to defer). So this handling is cleaned up (arguably that might be a fix but given no one has run into it, I haven't broken it out separately. Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Alexandru Ardelean --- drivers/iio/adc/ti-adc161s626.c | 50 ++++++++++++--------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/drivers/iio/adc/ti-adc161s626.c b/drivers/iio/adc/ti-adc161s626.c index 607791ffe7f0..9f2f25cf9a49 100644 --- a/drivers/iio/adc/ti-adc161s626.c +++ b/drivers/iio/adc/ti-adc161s626.c @@ -169,6 +169,11 @@ static const struct iio_info ti_adc_info = { .read_raw = ti_adc_read_raw, }; +static void ti_adc_reg_disable(void *reg) +{ + regulator_disable(reg); +} + static int ti_adc_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -203,42 +208,24 @@ static int ti_adc_probe(struct spi_device *spi) } data->ref = devm_regulator_get(&spi->dev, "vdda"); - if (!IS_ERR(data->ref)) { - ret = regulator_enable(data->ref); - if (ret < 0) - return ret; - } + if (IS_ERR(data->ref)) + return PTR_ERR(data->ref); - ret = iio_triggered_buffer_setup(indio_dev, NULL, - ti_adc_trigger_handler, NULL); - if (ret) - goto error_regulator_disable; + ret = regulator_enable(data->ref); + if (ret < 0) + return ret; - ret = iio_device_register(indio_dev); + ret = devm_add_action_or_reset(&spi->dev, ti_adc_reg_disable, + data->ref); if (ret) - goto error_unreg_buffer; - - return 0; + return ret; -error_unreg_buffer: - iio_triggered_buffer_cleanup(indio_dev); - -error_regulator_disable: - regulator_disable(data->ref); - - return ret; -} - -static int ti_adc_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ti_adc_data *data = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(data->ref); + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + ti_adc_trigger_handler, NULL); + if (ret) + return ret; - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct of_device_id ti_adc_dt_ids[] = { @@ -261,7 +248,6 @@ static struct spi_driver ti_adc_driver = { .of_match_table = ti_adc_dt_ids, }, .probe = ti_adc_probe, - .remove = ti_adc_remove, .id_table = ti_adc_id, }; module_spi_driver(ti_adc_driver);