Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3351981pxb; Sun, 26 Sep 2021 12:28:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUPuXPDis9bWe2Kkg9b8ujtooLceYh7nDQNbWBnT4mQ/S91Nll1Qm58sRbCL5/Izp3u6nP X-Received: by 2002:a17:906:b183:: with SMTP id w3mr22920322ejy.394.1632684513502; Sun, 26 Sep 2021 12:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632684513; cv=none; d=google.com; s=arc-20160816; b=fyNhuGsek47DhHq+tXGsJ3c61/JgdbZU6PtYYNKug5FO3XgBgc3m0sMAcGCPmHq/mJ RRgC3VweaVcGjgzpwpi3e+pAJYeTm4KfrJEtEBCxRY6aF6Tm2JElQ3Ze2VeKrgjMsSod ybRlb/80SVsk/FQiu3sITorD+aPLn3VqUISxsOlJImz8ZwQigQYky9dHPgYKfBu25KE2 RrnJA57W1ABVLPZ1/sxy1b0WsF9ebnbQ8sbzqDEgNu5aSSOpZYPHZbIA9PCQLZmqPnr4 jjqIDof2CvqMix1b3CF46hddiyJ90etcJHjugdYhMshjkb11+8gnruy5eA6hk/UjY102 UYFA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MjFc4qpdSBS8qeywuUDP1DYg3DGmfu9tyeJ/HZHA26w=; b=z+lQa41A2q7FwTpYREBDCbVL7N6L1YxubJ1CYezd1XNzvNq7yp07Ozff7t2VYoShmu naqv49+Der43Z0QQE1mTUf6YR6wfNqvZYp0iU2N8F+Xk1alrah8yj/c94EwZylz1wnJv tD6Zk7ZR1gh0JmvruC74wohOtRIE/Impu1dZsHc+Wn16z6qxyvNGa/3dXCMJ1HZYLFje O9qf6SN2Zg63oUu49bt43WmZxwwK/o6iH40WmbChOE/BZsQan52VeJsZNXDDkPjaRHqE QWcby4cZntPaY1TrltBN6AJ3G6FJcHTRv21/Qgx4v17p5/O2zgb+x/vdnx4z9E9GWeyo faMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=URLhrsBb; 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 d12si15841082ejj.278.2021.09.26.12.28.10; Sun, 26 Sep 2021 12:28:33 -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=URLhrsBb; 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 S229832AbhIZT2a (ORCPT + 99 others); Sun, 26 Sep 2021 15:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbhIZT21 (ORCPT ); Sun, 26 Sep 2021 15:28:27 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3264DC061570 for ; Sun, 26 Sep 2021 12:26:51 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id b26so11427761edt.0 for ; Sun, 26 Sep 2021 12:26:51 -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:mime-version :content-transfer-encoding; bh=MjFc4qpdSBS8qeywuUDP1DYg3DGmfu9tyeJ/HZHA26w=; b=URLhrsBbVcZzrEKxtP+L1BeVdakxp6+4O7NCymsdQvAbchVWa/q1imWa0N740vjQKj ZMahEITTJPS3s3c8TiLmHK9E69KHzY3e6vWd6OB75fi4NkUcpo7tEiklYKTegyAJcyjI LQRAeOeGoK7vMluCr5XuZoCdTfPpJ320ijXF9Tgw6Gb+vSFYw3JPojaS+5VVEuNyV4rv ZJ4yxtrm+4t3TERQ7ycDf2jy2OI01JtWorlgevP8hOejejgZ72HCslpsOtaDRLxAvsey psDEzso1M8D2a7u6lwLNJmEaBAJFS5cSUFe3Cf+UsITe0Mx0oYAHKQEwtz1XmNLI3Xqy TN5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MjFc4qpdSBS8qeywuUDP1DYg3DGmfu9tyeJ/HZHA26w=; b=u0iy1KWAKZItFTMDPNTcTAgQYuU8Rqvo3R7tMAGTfRBfhe0lTJw9mRA+66fTH/ZyYr FTV/79i5Nnoza1HBwNfp6VtJp0uVQ0SqZASclJPbuKipBm7d3tmMaFwg/J22MfkYFu2p 46PM46aIRqS/xuBKKEH/ShSHUR5GG6ByCe0EnYqIOQC/5M6qP6qs1kisNUyjWmLuK1z5 6OLqaBNEUygyv6jiYWtkarCimEurGFrE32W59rJS0bmufnwLWFObIfQdjBKOlgOkGkMa hMYzYFkGLQTNvCBs7PY5tRqx4QHEy+cqehOeCERCV6PFKtprERqWLzOrtEAEebvXaKJQ sehA== X-Gm-Message-State: AOAM532oJlymB34E2ccljST/dkhILXcLvJfLHjRfx4rnwyh24hhGFror Dvui6qvbVeey3+vWDTTi4TFQhLMwD/zqsA== X-Received: by 2002:a05:6402:1e88:: with SMTP id f8mr18443735edf.126.1632684409035; Sun, 26 Sep 2021 12:26:49 -0700 (PDT) Received: from neptune.. ([188.27.128.17]) by smtp.gmail.com with ESMTPSA id z18sm9183078edq.29.2021.09.26.12.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 12:26:48 -0700 (PDT) From: Alexandru Ardelean To: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: jic23@kernel.org, Alexandru Ardelean Subject: [PATCH 1/2] iio: adc: berlin2-adc: convert probe to device-managed only Date: Sun, 26 Sep 2021 22:26:41 +0300 Message-Id: <20210926192642.4051329-1-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver requires only a devm_add_action_or_reset() hook for the power-down of the device, and then devm_iio_device_register() can be used directly. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/berlin2-adc.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c index 8b04b95b7b7a..03987d7e6b3d 100644 --- a/drivers/iio/adc/berlin2-adc.c +++ b/drivers/iio/adc/berlin2-adc.c @@ -280,6 +280,13 @@ static const struct iio_info berlin2_adc_info = { .read_raw = berlin2_adc_read_raw, }; +static void berlin2_adc_powerdown(void *regmap) +{ + regmap_update_bits(regmap, BERLIN2_SM_CTRL, + BERLIN2_SM_CTRL_ADC_POWER, 0); + +} + static int berlin2_adc_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; @@ -293,7 +300,6 @@ static int berlin2_adc_probe(struct platform_device *pdev) return -ENOMEM; priv = iio_priv(indio_dev); - platform_set_drvdata(pdev, indio_dev); priv->regmap = syscon_node_to_regmap(parent_np); of_node_put(parent_np); @@ -333,29 +339,12 @@ static int berlin2_adc_probe(struct platform_device *pdev) BERLIN2_SM_CTRL_ADC_POWER, BERLIN2_SM_CTRL_ADC_POWER); - ret = iio_device_register(indio_dev); - if (ret) { - /* Power down the ADC */ - regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, - BERLIN2_SM_CTRL_ADC_POWER, 0); + ret = devm_add_action_or_reset(&pdev->dev, berlin2_adc_powerdown, + priv->regmap); + if (ret) return ret; - } - - return 0; -} - -static int berlin2_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - struct berlin2_adc_priv *priv = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - - /* Power down the ADC */ - regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL, - BERLIN2_SM_CTRL_ADC_POWER, 0); - return 0; + return devm_iio_device_register(&pdev->dev, indio_dev); } static const struct of_device_id berlin2_adc_match[] = { @@ -370,7 +359,6 @@ static struct platform_driver berlin2_adc_driver = { .of_match_table = berlin2_adc_match, }, .probe = berlin2_adc_probe, - .remove = berlin2_adc_remove, }; module_platform_driver(berlin2_adc_driver); -- 2.31.1