Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4760439pxj; Wed, 12 May 2021 12:37:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaWHR9ZB3J5mbCoFAzVGMLjceAaU/R91wfw7Z60T5miMCqOj934TlvCzr8hEpQE4maUn6Y X-Received: by 2002:a05:6830:308a:: with SMTP id f10mr32163780ots.147.1620848267781; Wed, 12 May 2021 12:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620848267; cv=none; d=google.com; s=arc-20160816; b=TcITqpNvEjwqD0co/ssfUIx6m8R2OpunXYpVbgvDFM+3crKYHaP3XuEWxLiIwso+/q P72gJ+EYkgpzu6Wh8hrVdjcQWwyU+KVhOZf8fM7LykwsYYe8NIYWUnvdEfeqqjp/KqMu YbVdpKxKKdDtfyADIYfM5rCB40qSUebOMrJWA1HUeNFhGICBFkyD2eCv7UEhdtqETzEM IgvhDQfgkx+s9uSBVnTTqXK2yIk76/YAMsqRK4EKcLvPDUmAiYhJMthHvWy3VqVK7GsL TzNhOiL5m31px8BNTnWFzNAZED2GiQsjfuU9aH06vlzQ6cdjR4wmQ9aXGJn5wHDxwtyW trFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b3CIlvHXWAL8LnevCxF+tYL0znrNNdyr/u/1pI8y5A4=; b=g0RcAdXwbWE4CjgZ4kYDDIcmHok5aQ03QyIyV2Un2domds8AZe2Wp6LnK/kOTZlZRp Qc4WKdItlu5nosAFJaiXfEwz5+A4Or0iO5pr+4sNrO0HELPJ/0yjVzpKuq2erw+BbP3P spDHKzKCI0coB2ayJ4W2JAzOJkuZlmW/5QfAJYZeDOUfXADKL4DNN2z2hvynAPBxAjgn 070FFBXpb/1fAMoskCG1ST3yx1jlGBljxG9QXwSl9xrewDOBwHv7QgiBBMRfVPXgWQjh MEF/z2k0mAb9MWtSGgWhtgZ2zJ/Eba7c1OhIGOehMvO6/qRzzc8Dnk+5B5xCVfz6s+n1 OmEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=qXCVU1pO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si944991ooq.4.2021.05.12.12.37.34; Wed, 12 May 2021 12:37:47 -0700 (PDT) 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; dkim=pass header.i=@deviqon.com header.s=google header.b=qXCVU1pO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381770AbhELTfO (ORCPT + 99 others); Wed, 12 May 2021 15:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350994AbhELRw6 (ORCPT ); Wed, 12 May 2021 13:52:58 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF4AC061357 for ; Wed, 12 May 2021 10:50:09 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id b25so36190172eju.5 for ; Wed, 12 May 2021 10:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b3CIlvHXWAL8LnevCxF+tYL0znrNNdyr/u/1pI8y5A4=; b=qXCVU1pOC3NzaTJp9gtolMr27NxdPQPD44yJNa++uNdTnbUbh7ROvboXmUiRoIY863 Pmj++blx5+aTL5eYpceb2RQqLPyFCX9Hxe+OSd1hdjIzo/6B+noo7zTyLZ6IANatMsUk o9KvvT0qdHCyKD7L9+c8BZXRUNOx5ukwp90c4N9oF6P01xGhqIt0VeKuKgBlJq931RsY CswmQnyuXgOMCzhTD8jISNOZOR0kyY4OsLzOj1P0cs0T3RTazIaOJmJA64yJ/N4C7jnk 8yE9iHlGTz/PopQayK/trOQpSF70T/dK1UkqQ7M80FeA2hFD20qAEP1jBZPV5cmT45nK 8czA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b3CIlvHXWAL8LnevCxF+tYL0znrNNdyr/u/1pI8y5A4=; b=sVQfUOe49GmhxdDoGPLrD2Xc5qyqH8T63y/urdN+Nmr0LABmpwuDqnQB+RAI8QsXD5 1WIW+3zcgtSdJ+dBBFS/xsVrH5aMqTQj1Z4L8jRHrbg0fE3Ljy68XseS2JY5/nrOUjK6 kJ6Z+25SSKDPY5qipRKjpP5YvwvRRYBm5jmHNiQQ0ne/bvXO5yel6g1fRVIOS2FxfGt+ 8wUN4AgYD/ucAir5ph2KBJ8tRMIUCpkCJnzqphjHn54zVsrsEyL7/CYPMoVsONvv3uvG N1IjUay1nKCOBB7ZVs9e0keY+Gp9RseXg4sKFeR2YqfyfN+i9xk2+oQyiQzFAxI0Ntq8 NtaQ== X-Gm-Message-State: AOAM533G+F7CMzk7E7rtYCbLUONu6dQOWuA4biOTpPUyG6+O/oj8gjTy h0/wbE54W2ac7h7Z6P6SZlm14w== X-Received: by 2002:a17:906:29ce:: with SMTP id y14mr38621527eje.189.1620841808068; Wed, 12 May 2021 10:50:08 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id r16sm338058edq.87.2021.05.12.10.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 10:50:07 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, Jonathan.Cameron@huawei.com, alexandru.tachici@analog.com, linux@deviqon.com, Alexandru Ardelean , Alexandru Ardelean Subject: [PATCH v3 11/12] iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove() Date: Wed, 12 May 2021 20:49:13 +0300 Message-Id: <20210512174914.10549-12-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512174914.10549-1-aardelean@deviqon.com> References: <20210512174914.10549-1-aardelean@deviqon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Cameron As not many steps were not already devm_ managed, use devm_add_action_or_reset() to handle the rest. This also uses the new devm_ad_sd_setup_buffer_and_trigger() function. Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7124.c | 48 +++++++++++++--------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index a27db78ea13e..e45c600fccc0 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -862,6 +862,11 @@ static void ad7124_reg_disable(void *r) regulator_disable(r); } +static void ad7124_clk_disable(void *c) +{ + clk_disable_unprepare(c); +} + static int ad7124_probe(struct spi_device *spi) { const struct ad7124_chip_info *info; @@ -883,8 +888,6 @@ static int ad7124_probe(struct spi_device *spi) ad_sd_init(&st->sd, indio_dev, spi, &ad7124_sigma_delta_info); - spi_set_drvdata(spi, indio_dev); - indio_dev->name = st->chip_info->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &ad7124_info; @@ -922,48 +925,28 @@ static int ad7124_probe(struct spi_device *spi) if (ret < 0) return ret; + ret = devm_add_action_or_reset(&spi->dev, ad7124_clk_disable, st->mclk); + if (ret) + return ret; + ret = ad7124_soft_reset(st); if (ret < 0) - goto error_clk_disable_unprepare; + return ret; ret = ad7124_check_chip_id(st); if (ret) - goto error_clk_disable_unprepare; + return ret; ret = ad7124_setup(st); if (ret < 0) - goto error_clk_disable_unprepare; + return ret; - ret = ad_sd_setup_buffer_and_trigger(indio_dev); + ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev); if (ret < 0) - goto error_clk_disable_unprepare; - - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&spi->dev, "Failed to register iio device\n"); - goto error_remove_trigger; - } - - return 0; - -error_remove_trigger: - ad_sd_cleanup_buffer_and_trigger(indio_dev); -error_clk_disable_unprepare: - clk_disable_unprepare(st->mclk); - - return ret; -} - -static int ad7124_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad7124_state *st = iio_priv(indio_dev); + return ret; - iio_device_unregister(indio_dev); - ad_sd_cleanup_buffer_and_trigger(indio_dev); - clk_disable_unprepare(st->mclk); + return devm_iio_device_register(&spi->dev, indio_dev); - return 0; } static const struct of_device_id ad7124_of_match[] = { @@ -981,7 +964,6 @@ static struct spi_driver ad71124_driver = { .of_match_table = ad7124_of_match, }, .probe = ad7124_probe, - .remove = ad7124_remove, }; module_spi_driver(ad71124_driver); -- 2.31.1