From patchwork Sun Mar 28 21:46:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12169157 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 22F01C433C1 for ; Sun, 28 Mar 2021 21:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDAF261951 for ; Sun, 28 Mar 2021 21:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbhC1Vqe (ORCPT ); Sun, 28 Mar 2021 17:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbhC1VqI (ORCPT ); Sun, 28 Mar 2021 17:46:08 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957AAC061756; Sun, 28 Mar 2021 14:46:08 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id q26so10739498qkm.6; Sun, 28 Mar 2021 14:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nurCGhllYuU/wCSSD1tx5ENa5/ZM3WiCimEU92yo5mA=; b=NAsqRwYWvgsABxBVaWknl63rKOMQqBiR8K7ofw0h2qPS+yz18qJFuUtsnSidaK5QNm JRz3HpuX9B5uoe8vtBSKqIrK/tnXi4Lw6FtflfTLU21clyqD3xFi0+Go37Pb6pPLxFEX ipCA+WYoxIPSb3JvAK0Fcqsvk07552gHOyEfhZwwMVxXQYXxDAJ+yy7PSp/ab6OulKvt /kwvCQxgxysZFbRfjxP670V03q2adNEUpNqYnuXowEPczdElwUstSN2DnLqhZL9Do/u6 X0AzxbXXLmNVDikdj+PNEXmJvqlAC+VyvTZ0wojyAV/GbXRO1qPP09b14EsKaosGT49j BSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nurCGhllYuU/wCSSD1tx5ENa5/ZM3WiCimEU92yo5mA=; b=VkuJNcDNt0HRbYzP+3DFw5ng+N6zTb3S6JmR0XjS3VpmCNVOo5LHWRJYp8+bKktEqU td1904iyF2XU2cXmpYseyzxn9zGNni3yQZ7ECUm72iQr2crLT+PX6uj5nUi9xl13Vr1v NtBM6LBCgqqaTy585fUMP1/3D/vIgyAfdtWeP4DtwSVHzn44fyEi1JJ4C6bLrkgqV4db I1RzqwXPgWS2/xP8pXfJqTGgeCKfqt3+Nu0U6/TARJhTPhqn8OueWIE54W9OBpPOQzB6 AOP7EOylBSZh+Gmbr+vANNuDQoClVB6NrK/T2F6ls6BIxhlGrOjcymT0D0l2QO0QYm0J 2KYA== X-Gm-Message-State: AOAM531dTKiYG+63fhRuuhL7/G5dtZT5xU5LFTuMQ0XJfBrxtarqmJeD 9MbcHslOp6ak0xxN60h76/A= X-Google-Smtp-Source: ABdhPJztGz3eBXrpwtqxwqZlQF0fcu+NAN8yfih3FTT+DyKio26a6WhovXfDFoRE2b9S7J5yU1YtGQ== X-Received: by 2002:a05:620a:1442:: with SMTP id i2mr23173651qkl.469.1616967967950; Sun, 28 Mar 2021 14:46:07 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9e91::1002]) by smtp.gmail.com with ESMTPSA id h8sm9680692qta.53.2021.03.28.14.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 14:46:07 -0700 (PDT) Date: Sun, 28 Mar 2021 18:46:04 -0300 From: Lucas Stankus To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] iio: adc: ad7923: use devm_add_action_or_reset for regulator disable Message-ID: <49a7c0436ca1186313dbccf3d810d0cf38cb5b37.1616966903.git.lucas.p.stankus@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Adds a device-managed action to handle disabling the driver's regulator on device detach. This slightly simplifies deinitialization and enables further conversion of the driver to device-managed routines without breaking the init order. Signed-off-by: Lucas Stankus --- drivers/iio/adc/ad7923.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index a2cc96658054..3418ef6f0857 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -293,6 +293,13 @@ static const struct iio_info ad7923_info = { .update_scan_mode = ad7923_update_scan_mode, }; +static void ad7923_regulator_disable(void *data) +{ + struct ad7923_state *st = data; + + regulator_disable(st->reg); +} + static int ad7923_probe(struct spi_device *spi) { struct ad7923_state *st; @@ -340,10 +347,14 @@ static int ad7923_probe(struct spi_device *spi) if (ret) return ret; + ret = devm_add_action_or_reset(&spi->dev, ad7923_regulator_disable, st); + if (ret) + return ret; + ret = iio_triggered_buffer_setup(indio_dev, NULL, &ad7923_trigger_handler, NULL); if (ret) - goto error_disable_reg; + return ret; ret = iio_device_register(indio_dev); if (ret) @@ -353,20 +364,15 @@ static int ad7923_probe(struct spi_device *spi) error_cleanup_ring: iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - regulator_disable(st->reg); - return ret; } static int ad7923_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad7923_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - regulator_disable(st->reg); return 0; } From patchwork Sun Mar 28 21:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12169159 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A8332C433C1 for ; Sun, 28 Mar 2021 21:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79AE761951 for ; Sun, 28 Mar 2021 21:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbhC1VrH (ORCPT ); Sun, 28 Mar 2021 17:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbhC1Vqb (ORCPT ); Sun, 28 Mar 2021 17:46:31 -0400 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E95C061756; Sun, 28 Mar 2021 14:46:30 -0700 (PDT) Received: by mail-qt1-x832.google.com with SMTP id a11so8118680qto.2; Sun, 28 Mar 2021 14:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rzFuE51HjLtetaV2oxoek+FpFdBLQabZgkx6sZySstg=; b=rHYNafv7PqWQQyAIXR4YDq7gsrZBNureSM6KvkN/3mcNIfnZ3v1scNOjB8d/hX/mZ0 LwzMW8FvqnhWXnHs+l8ZLfFoUv6TYYJIO0102otUTOmZeliRPcvE6PzGlfmr1SZCfxXY 2P/VZa2JK1CZt738ATPQjHe3oB3l0bGdHX8ZI2vObPDWe+u1C/XVNh67Su/3AoksXpNS IWkPS2GdqAbFVtiiAXJd2SxOZ1LNQhYi4+YZ4VemQqTmpotK8Vmdpzw5ntLVX5PLTaDO ysB5jpDL6ic8qvOTfSvaUx9PVPZzmPj7PoAmKigW2NwXpq+AUxatkoM79VWnK4offxMV veaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rzFuE51HjLtetaV2oxoek+FpFdBLQabZgkx6sZySstg=; b=JafxkgROlS/A++9B/5dX8tw4eKbShjzfXL9utZZ8sCTkACMzCE9hrUf27fMheo03Eo FLg8JjnbBMNtdUQhxZhBu8y5n9rHmj5E04ryE3ZbHz7Q3uvFIhwV78tpxv+rVZ9v744l GZ4x2NdEeb1YDFP50JxYhzNguyWfOk4VavwPakPlykeep8bsK8o+5he99/dU5/SBag0r HpXFnBttsNubCdVXS2ug0yUEes42pFVgeLUUpgCcyqDxUCMYKjbJZpHpUyN/XtKKG3qF kDuG1Zd05y18hosjBmfaKAxy68+k3o1hKozA/L+ErpcRps1fkwn9s7hvPIfQMru9Xu89 T43Q== X-Gm-Message-State: AOAM530ugcF8jvKmDB+ftm4aJTshjGydIjVHbfuDE36fQKZakflv2JNx 7KXpigs3L0AfT+uV3YVMSvw= X-Google-Smtp-Source: ABdhPJylliaFA/gNKpxH011aGmw0mpAaMh3sAAA6phEUewnCul6FVN5oOYKYxT0XoPHjjuM7zPY4yQ== X-Received: by 2002:a05:622a:9:: with SMTP id x9mr20506856qtw.189.1616967990210; Sun, 28 Mar 2021 14:46:30 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9e91::1002]) by smtp.gmail.com with ESMTPSA id q125sm11825224qkf.68.2021.03.28.14.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 14:46:30 -0700 (PDT) Date: Sun, 28 Mar 2021 18:46:26 -0300 From: Lucas Stankus To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] iio: adc: ad7923: use device-managed function for triggered buffer Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Converts the iio_triggered_buffer_setup() call to its device-managed counterpart. With this, the error handling routine in the ad7923_probe() function becomes unnecessary as well as the iio_triggered_buffer_cleanup() call. Signed-off-by: Lucas Stankus --- drivers/iio/adc/ad7923.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 3418ef6f0857..d07eaf3111ed 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -351,20 +351,12 @@ static int ad7923_probe(struct spi_device *spi) if (ret) return ret; - ret = iio_triggered_buffer_setup(indio_dev, NULL, - &ad7923_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, + &ad7923_trigger_handler, NULL); if (ret) return ret; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - - return 0; - -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); - return ret; + return iio_device_register(indio_dev); } static int ad7923_remove(struct spi_device *spi) @@ -372,7 +364,6 @@ static int ad7923_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); return 0; } From patchwork Sun Mar 28 21:46:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stankus X-Patchwork-Id: 12169161 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C4685C433E1 for ; Sun, 28 Mar 2021 21:47:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9998861951 for ; Sun, 28 Mar 2021 21:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbhC1VrH (ORCPT ); Sun, 28 Mar 2021 17:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbhC1Vqv (ORCPT ); Sun, 28 Mar 2021 17:46:51 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F0DC061756; Sun, 28 Mar 2021 14:46:51 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id j17so5584072qvo.13; Sun, 28 Mar 2021 14:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4zN45Y9NetQY2opVdga1pvMAszygLa6a/w/iQR/Hj3g=; b=WcNWiw37z03fuWilWKrtDkAntPn6lZsVUedAtZeq6OvCR7pwVqqHx6Kg9is7a5udZS ZE2ybala+lRhg4/a5wqJ0A78gF+wOOn2HZ7e6LiehYVI04/mv72LdIDIBystTF7/CH+B B9D0XbFAyBUB5G5uC7n369pxOtmBacGT6wKSC+mUVcGC3HwGHwAyCwIfzrHPqlK8/i9M lLvkeKdYmalcTn1AOZaIIcs8Z6hdxjfLV8zxUgqYNfLbU1/OHPzRSlxBb1ztFeHHbRd2 LavmCGDYBipgntdVqJi+e1/BiG+BBfKs9ncAGQRbWnhBAAubQ6W3BzrfdFzpxznLFuhx zJUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4zN45Y9NetQY2opVdga1pvMAszygLa6a/w/iQR/Hj3g=; b=j9MRMwojIgP0Dhb52HbPWmR3V9Udwuxhh9q4ViMZOyFfwjaSlvOZVgbJJ3892NUhd2 4KBsoxpvDBbYqxcZCxu3LKtKc+YEKtlNIBddoOE3GHz0X2aSo+3jiq+KBd/Z1P0RPkqY 8A3+CqRRRGOffC8ahnNsJsM4U+2Q8zhoUCWckBB8xHbzmtZ68rxgK/J78b3r/oJ6eseW rDHyFJ02BXtobKaNMeThdRpgQwg7MM4KtjdWse+KQQovFzB/ecbYDJhE9i69+lmVscL6 pL2+B0qp58U23o2HHFsErCdb+7tllm/HnT0lUmoJE1sirIEYTNlZGJMzqi1oZ+Wvnj7L PJqw== X-Gm-Message-State: AOAM530VaclKQxNoJNL26CYPyz3lEyt6VtCxuX4Vda6t8eM3vOBWNNjM Y4m+LRARz7LkbRqjBmeFOp8= X-Google-Smtp-Source: ABdhPJwXFnluIQeo82omzQhVXzNeL7ImgxHRHs+wALolYNDjgn38LTG9xlnYDjSyPd4vkkwY0bJ3Qw== X-Received: by 2002:a05:6214:80a:: with SMTP id df10mr22731789qvb.46.1616968010307; Sun, 28 Mar 2021 14:46:50 -0700 (PDT) Received: from smtp.gmail.com ([2804:14c:73:9e91::1002]) by smtp.gmail.com with ESMTPSA id b12sm9910080qti.43.2021.03.28.14.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 14:46:49 -0700 (PDT) Date: Sun, 28 Mar 2021 18:46:46 -0300 From: Lucas Stankus To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] iio: adc: ad7923: register device with devm_iio_device_register Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Registers the device using the devm variant. This is the final step of converting the ad7923 to only use devm routines, meaning that the ad7923_remove() function is no longer needed to release resources on device detach. Signed-off-by: Lucas Stankus --- drivers/iio/adc/ad7923.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index d07eaf3111ed..f7af2f194789 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -356,16 +356,7 @@ static int ad7923_probe(struct spi_device *spi) if (ret) return ret; - return iio_device_register(indio_dev); -} - -static int ad7923_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); - - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct spi_device_id ad7923_id[] = { @@ -398,7 +389,6 @@ static struct spi_driver ad7923_driver = { .of_match_table = ad7923_of_match, }, .probe = ad7923_probe, - .remove = ad7923_remove, .id_table = ad7923_id, }; module_spi_driver(ad7923_driver);