Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2569138pxj; Mon, 10 May 2021 06:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy26VXhCOzviIIOyAJgWKGEinIySmIin3Shv2brwHkxWnsD5PHSLWZRZaY3/hsj53ugnMgn X-Received: by 2002:a17:907:3e99:: with SMTP id hs25mr26640835ejc.518.1620652073744; Mon, 10 May 2021 06:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620652073; cv=none; d=google.com; s=arc-20160816; b=htRhxg2FnSQ917gllxfpokxrupHYSx3eyZ06o76SI8SH1uSiYSIrG4b3C8noY0+SCt hWiH/T0V9woDsDNNywEGQ7pUMQ0If7l5BVRTZchZK629l0EpN25UNjfaAWJW328/6Sz2 39Xe6sJJms1MnjoWgI59G9W2SImgJs1SJMweSe7IE4CxMmAfkjD5rXaowIdY2PRBi4M0 /9Eyrmn1TtCEL39C377rodUOFBRg4r7dLCKAjxwSEQV/40zRx3j2AUMoLOdZtw7CUJmH UXJhPmvYJWOI3HQF7ZtK/D/OXUZT/3xG/3K5lpoG8XvD1A8aYMjk9tfaNpSTHOUiecnI 02rg== 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=Vz4kEJldu4GosjMrUcy5BaoWWF6Pgm+zPh1bcD8HAp8=; b=LCNatzERv7GHOGeJrkIXY55DCzYYKLX5vtS29UZTgTqQcU+OLFQURM+rKqwNsQd0It VfoeZ+V0mrPUGwK/SXPer7XOUK4X4tvYbDt/DhcEO/e9IDL8Uph2WhtjF+AwKE4JoI+N PVj1ewh6DeN8PZ7fftEFgPZR+Uiuypb49tFo1gNbCFxM3ErR6bqrOAPbjMRzvSDKWV/A jhwQhK1Qi8AQIJjv7TzN6W6mRrsqBZWTyL18JDEm6/RaHW4L5skmfwQNSNf6+wlQ6SnV gcYXo3409zKnztk2YgYp0iphER81FNPV8joaUXIiEHybM+eDkJ0me6Sz441UsqUjti36 +ufQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=cVWwtM1x; 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 f10si7383666ejf.291.2021.05.10.06.07.30; Mon, 10 May 2021 06:07:53 -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=cVWwtM1x; 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 S1351474AbhEJNG7 (ORCPT + 99 others); Mon, 10 May 2021 09:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351220AbhEJNDJ (ORCPT ); Mon, 10 May 2021 09:03:09 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B504CC061364 for ; Mon, 10 May 2021 05:56:01 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id v12so16511774wrq.6 for ; Mon, 10 May 2021 05:56:01 -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=Vz4kEJldu4GosjMrUcy5BaoWWF6Pgm+zPh1bcD8HAp8=; b=cVWwtM1xiuY+o3ca9K7oq8d7mjvL2+pcXQcYySUxsUkbFm0Hzr9tdphMsuzmfxjEvJ O7ALQGWABwg6LO+AST/Q2TMqXKg59kQMojvk0zP/wVmGtXi/7AhUeivMNlaVcoly39Gr LPFoV4M95RO74oomDsWafmMVUb88dhgxaOrsigPUTQmY2z+wqHbBftrCD+6SGqiWoLfi FYyDL1OM6Mpt3DbU4jTKAI3WZ+JdN0heq4/FLXGb718BDKN9hQa4UXimsOBTv6Njwlk0 h6Q14Ws+OI504RoAgYmHpQeGRcV4ZYdNIQVhxkM7jYZTJqzQ+JaEsn47zvJBZeNII/5l pKMg== 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=Vz4kEJldu4GosjMrUcy5BaoWWF6Pgm+zPh1bcD8HAp8=; b=SXl6dPinuqGzUY9agufmETDY9cepGlnp+dcViV+chSyZhpBe5sf3+0tvW+ozMJboWd R2KcYhkutD5abdGr2cbTGXpbqIKmdV++M+fY1WDPlfutr6wlDce1JATTq+4atV5EcwvY KSdG+akBjkGaLMxQOuzDfqMiM1ObhGqfp8K4jskyfDzpCXV8ULcKOpnupZ/OZA/APzxs VkyKIBwmWu/OcnP63V3V6dC1r8kbKPRiaOS77BGL95R234UjmidR53N+spVk0Z1MZRbq ML65FW2v0wrInP4hjFgR1fTy2AOuWZJFpzXSzEhYjtzKejU8t+2A8zYf5FKivbwp7uHP kzjQ== X-Gm-Message-State: AOAM530qWAJmkFD+w5U7bogq6zCYLwJ+LFaWrLkcywnFjR4xcHoFDP2Y aaiVi3pFuCt75jUThwiN0gFoxw== X-Received: by 2002:a05:6000:180a:: with SMTP id m10mr30342135wrh.215.1620651360537; Mon, 10 May 2021 05:56:00 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id n2sm23134329wmb.32.2021.05.10.05.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 05:56:00 -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 10/11] iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove() Date: Mon, 10 May 2021 15:55:22 +0300 Message-Id: <20210510125523.1271237-11-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510125523.1271237-1-aardelean@deviqon.com> References: <20210510125523.1271237-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. Signed-off-by: Jonathan Cameron Cc: Alexandru Ardelean Reviewed-by: Alexandru Ardelean 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