Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp608595pxj; Thu, 13 May 2021 12:27:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTzVirxXjW8tGfX5AThZKuA7ZHT0QRycCALmZI4mOIiuKRamcaFVHtnZ12vvn3FmNdUTHD X-Received: by 2002:a05:6e02:218a:: with SMTP id j10mr19395918ila.279.1620934065571; Thu, 13 May 2021 12:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620934065; cv=none; d=google.com; s=arc-20160816; b=e7m11qIUfY0L0d2Ya3XREnwYQ2fGvSteJEzsoWOza9obnaF3zGyKQrCmtVg+LWjM46 M5f/UIbmxGUr58SrdGqEevRojIxOhOxWhqu9IhbptR67lFDPMnwOQ/PKyVUxBUM7V43/ iOpj0ERFaeuKZMa3pSHeogPxXUSZp6BB6Euzhxhen6qM8cDlbBamhFUltHGzFSAx6m10 FQGS2buwT/H4SZvYes+exPw7v/Em040GyfXc4jNAlJA2aLyjisR/hgGDcGF4l+xE1dzN +Co7L2SxvfK5WvSjdgZqOK1+zqozAqU5ihVrebzvh8Ade4mEPhGW3ZLoozzGoTv4Lyrj pnzw== 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=KdptB6vjeXb+P3qp23d7np63YfYeGR0cUCoW/9GsHq2sW4pmvX/hN5iv0+J2fOpYly +LCXzXATKFGJUWzICeqvhliC/F17P+wVfFFsqvXIpUdzhle/ka+Pa+C3TVr0jx3SCfYu sVR6xaVVmokXVyOsu0s9efKTA4qk65YNpkD7ZKWpZx4JLxEGpVGiQhl/sVix6m1luEnD hQd9MWSCisF79+sfQzaHF2S3FARTgNODpEMPPkc0Y/iqU9wwkfsA0EU7xozEH44S2+OD YQfkkArUgCcrkAb9lHJ/VXoDjb9RGIvtqniQTeUw+GY2PZeESZmMgBp5RlzjzfG6z4Zj 2I3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=REgarnqF; 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 n2si4071976ilm.161.2021.05.13.12.27.32; Thu, 13 May 2021 12:27:45 -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=REgarnqF; 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 S233742AbhEMMMG (ORCPT + 99 others); Thu, 13 May 2021 08:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233706AbhEMMJV (ORCPT ); Thu, 13 May 2021 08:09:21 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95228C06174A for ; Thu, 13 May 2021 05:08:11 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id i13so760646edb.9 for ; Thu, 13 May 2021 05:08:11 -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=REgarnqFmNOJkjjpAZ51MHtU49AG1Me/3Ao2f3aBlYXjhPqINOios+jWutMI2TcWD9 PmY/9n8CZkcSVfB5kVjzJFcG2yfdIhzN39Icv6yx0N8JvVNIsXF3PZskg8d+udQtQld9 THCc7wiN4Vh8cTT7y6oGusXmXqTNa0AXjopkodBQ2IffTgIQnm3Pmo6zBPXuK+P/Tmub 50V6MZcT/dWJjcSF0N85SNPhHKUHiBxeQU6/FctlLEHAlFLKaQS33p7KmMgXtU40JpRE mFgiYXnNDnwBsoVco0D4VlvjwFbzF/AsjoAEdLWOaOWCrgjOU0nN0/f0zQLelkBIMaeU kTYw== 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=TkBb7X7IoBil3SPVCiYr7+rbYctsZZ3GlcJbwvI/hNFuhQ4mKXQC8FUX8YyrDkj1Lp xlRa6qgANLGR/NSo/FBLlU977XpQvhSJebxbOHER7+TPUHT/ezSvoStlVkmjOqr1Uf7V CX+jDNWLOBR1RhHJ9NYHLjXSzqaijkixQ015vUgLrC3V+lhfBXHHK7rBgdXUMasBpHSB vUpktHD2XCndUt+RnF3BiIPYHvTAoLCxQ+k4DWn2PYXP8Ms4S7meoIyqUh7Ti/MYcwMY 6EpaLSfRjGMVPkus8AYZU/IJHkmlOCCKZjHVSjNd8dEDED9dD+MDz/LhMbL/KZrz86yb ZBYg== X-Gm-Message-State: AOAM533+G1c9ddI8nXAL5p3lg5ydgXOg9S97kpWBqnKyVfcpRel9sNQH ih0tl7KoCMy/y/32FHP3vOeFS6AAhW+T5w== X-Received: by 2002:a50:f385:: with SMTP id g5mr12500007edm.222.1620907690414; Thu, 13 May 2021 05:08:10 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id ga28sm1717809ejc.20.2021.05.13.05.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 05:08:10 -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 v4 11/12] iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove() Date: Thu, 13 May 2021 15:07:51 +0300 Message-Id: <20210513120752.90074-12-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513120752.90074-1-aardelean@deviqon.com> References: <20210513120752.90074-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