Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp618376rdb; Tue, 23 Jan 2024 09:21:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGj2av8yjI816E+MCvfRpSmBzgzPs5PDjQkjdXlMtvuH+Ka7YEdq6iXsegMmrg0AaLAmrT3 X-Received: by 2002:a17:906:6812:b0:a2e:d563:175a with SMTP id k18-20020a170906681200b00a2ed563175amr119063ejr.151.1706030488850; Tue, 23 Jan 2024 09:21:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706030488; cv=pass; d=google.com; s=arc-20160816; b=rxNSSJPItr6E1rie8eaVjbyaMQd+NRI/kZGzBoOH0a/DZ2BzmRBsIETCIUD2cvJ4DZ Q648e7vZLM1bkTeIjCa35xPd6zHdM+xSfsHBv6AhRZug4FamiBnowhmGWGJGG7+Z8baC HqumWL8RFEgn/h314nmQRNFwzgZPYqnsaysMhh/7Hw4ssGNFe2otjZ1y/TeIg+3CLz9t hs+O0gnU9/6FaFyGUP86BhJ96ED0t5dnOqQCaoAz7t9azeHAo2/s6kQYJWdBoiMGBDTI zpxS33s+wFS5uBGM8vDRBQy5ZZltTu7ewcVP+mvFFgoOlIXDhy5LnkgAZX4P9f9T9mVn LhAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kVXImxDJPM4A7YrQnUDOEbJIk29vaGvEJQGgWRehcUA=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=YJXL+Ola4mgh8/PqshgdanUUo+QJlayuhJTajqumlVnF+whD2VqCZ3a+6ET58YAtqA 0RqUu37m6ZQLXeeuBR+fFTf96fu/f/pDoKvXfcH11PeJOys4y+CkPkKBX/c6NDW+Qmci HNxR/HzQn5/gM3dmts8jQj/qbz4Zmea/802kc5EP/6o5SM5BpWKJkVzgHwMKSPjav5el LUQbCq9CXmwKv2y+dCOujUZBh5sIJjjsFuqkM81Bpz63eKhU4L//sSl3IW2ygWKIv5vP f1ENl7rjM4f5jfY0J5fkf32J2fBH7EFDbIMsSzliVTB/SlJ13v9pJo1Gxytg10J1xYUy d6bQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Z4imqtNS; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35672-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b9-20020a170906490900b00a307a4b0ff3si1768869ejq.928.2024.01.23.09.21.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 09:21:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Z4imqtNS; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-35672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35672-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B22C51F2C52C for ; Tue, 23 Jan 2024 16:41:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AA9186AC6; Tue, 23 Jan 2024 16:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Z4imqtNS" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8E168005D; Tue, 23 Jan 2024 16:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027830; cv=none; b=OMRVzw+bxBwWh/X9Oj2Oq3p6gp5+uW1KSz896DMBH9tP8H1A4+FJ3O46SM+QaIQDg10+Ut28QzZ8HoBRC52KDFiwJekEwRxRFR0eys/3GTc5AFqbnZB4SPh8ctZ8qhQMjmLbrU1IzTtzzeGkq6V4I/tcwbNOL2vQuLE6tOP754o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027830; c=relaxed/simple; bh=HqyDbZstUWJOaMyZ4TiG/oEUrlUvngFXfqf5DbMzNi0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qJCghWFqF33X0A00TtI0mfSidHCQVHESKOkowL6VA5nNa2cxV5hqf6811YkEGoDsK04WXOJY0mJM/QWyTHGtgOQvadecwD+B7KuDWCCWFTkY5JQqSxSK8o2ZKKT/kOqJ+nxTXsQ3KUXUDP3IE9hh9lS8UPHy3YXXqsl69+QiEpI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Z4imqtNS; arc=none smtp.client-ip=198.47.19.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGb0s0094139; Tue, 23 Jan 2024 10:37:00 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706027820; bh=kVXImxDJPM4A7YrQnUDOEbJIk29vaGvEJQGgWRehcUA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Z4imqtNSh7hFg4AmEfTGwNX1/h8bMgvjZZEjwc3EiKeniyaKolR/dqfW4j+KgEkaA tGx+/pafkNm1MkAdG8xrLFrsmXSDbUD6uIrHRzuFYTFpks6l1rKQ8kQPDwjrVnh8/Z 1VQn9ht3Vh6taqfgNbMC2WHP2vcLFJcdT88FTem0= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGb0IK034013 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:37:00 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 23 Jan 2024 10:36:59 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 23 Jan 2024 10:36:59 -0600 Received: from lelvsmtp6.itg.ti.com ([10.249.42.149]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40NGars4123403; Tue, 23 Jan 2024 10:36:59 -0600 From: Andrew Davis To: Sebastian Reichel , Support Opensource , Krzysztof Kozlowski , =?UTF-8?q?Pali=20Roh=C3=A1r?= CC: , , Andrew Davis Subject: [PATCH 16/21] power: supply: da9150: Use devm_iio_channel_get() helper Date: Tue, 23 Jan 2024 10:36:48 -0600 Message-ID: <20240123163653.384385-17-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240123163653.384385-1-afd@ti.com> References: <20240123163653.384385-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Use the device lifecycle managed get function. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Andrew Davis --- drivers/power/supply/da9150-charger.c | 57 +++++++-------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/drivers/power/supply/da9150-charger.c b/drivers/power/supply/da9150-charger.c index 37db9e4ed7f30..77e2d42382e45 100644 --- a/drivers/power/supply/da9150-charger.c +++ b/drivers/power/supply/da9150-charger.c @@ -521,36 +521,26 @@ static int da9150_charger_probe(struct platform_device *pdev) charger->dev = dev; /* Acquire ADC channels */ - charger->ibus_chan = iio_channel_get(dev, "CHAN_IBUS"); - if (IS_ERR(charger->ibus_chan)) { - ret = PTR_ERR(charger->ibus_chan); - goto ibus_chan_fail; - } + charger->ibus_chan = devm_iio_channel_get(dev, "CHAN_IBUS"); + if (IS_ERR(charger->ibus_chan)) + return PTR_ERR(charger->ibus_chan); - charger->vbus_chan = iio_channel_get(dev, "CHAN_VBUS"); - if (IS_ERR(charger->vbus_chan)) { - ret = PTR_ERR(charger->vbus_chan); - goto vbus_chan_fail; - } + charger->vbus_chan = devm_iio_channel_get(dev, "CHAN_VBUS"); + if (IS_ERR(charger->vbus_chan)) + return PTR_ERR(charger->vbus_chan); - charger->tjunc_chan = iio_channel_get(dev, "CHAN_TJUNC"); - if (IS_ERR(charger->tjunc_chan)) { - ret = PTR_ERR(charger->tjunc_chan); - goto tjunc_chan_fail; - } + charger->tjunc_chan = devm_iio_channel_get(dev, "CHAN_TJUNC"); + if (IS_ERR(charger->tjunc_chan)) + return PTR_ERR(charger->tjunc_chan); - charger->vbat_chan = iio_channel_get(dev, "CHAN_VBAT"); - if (IS_ERR(charger->vbat_chan)) { - ret = PTR_ERR(charger->vbat_chan); - goto vbat_chan_fail; - } + charger->vbat_chan = devm_iio_channel_get(dev, "CHAN_VBAT"); + if (IS_ERR(charger->vbat_chan)) + return PTR_ERR(charger->vbat_chan); /* Register power supplies */ charger->usb = power_supply_register(dev, &usb_desc, NULL); - if (IS_ERR(charger->usb)) { - ret = PTR_ERR(charger->usb); - goto usb_fail; - } + if (IS_ERR(charger->usb)) + return PTR_ERR(charger->usb); charger->battery = power_supply_register(dev, &battery_desc, NULL); if (IS_ERR(charger->battery)) { @@ -619,19 +609,6 @@ static int da9150_charger_probe(struct platform_device *pdev) battery_fail: power_supply_unregister(charger->usb); -usb_fail: - iio_channel_release(charger->vbat_chan); - -vbat_chan_fail: - iio_channel_release(charger->tjunc_chan); - -tjunc_chan_fail: - iio_channel_release(charger->vbus_chan); - -vbus_chan_fail: - iio_channel_release(charger->ibus_chan); - -ibus_chan_fail: return ret; } @@ -659,12 +636,6 @@ static void da9150_charger_remove(struct platform_device *pdev) power_supply_unregister(charger->battery); power_supply_unregister(charger->usb); - - /* Release ADC channels */ - iio_channel_release(charger->ibus_chan); - iio_channel_release(charger->vbus_chan); - iio_channel_release(charger->tjunc_chan); - iio_channel_release(charger->vbat_chan); } static struct platform_driver da9150_charger_driver = { -- 2.39.2