From patchwork Tue Jan 23 16:36:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 191099 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp477051dyi; Tue, 23 Jan 2024 09:09:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdMON9EZ6AO/7t0Va0m7hxqcUtwiBSNngiTz3zyfyAKJiw0ENuJYmpu4r8bSeCgwT8Ngt6 X-Received: by 2002:a17:902:eccb:b0:1d5:8bf4:c7b4 with SMTP id a11-20020a170902eccb00b001d58bf4c7b4mr4491870plh.82.1706029768700; Tue, 23 Jan 2024 09:09:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706029768; cv=pass; d=google.com; s=arc-20160816; b=Nn5Deab0kZaxI+dhhszJR/07zgHyYvbgTc07tXpYFuikGhYUwGNJzzN1bYFSEfa4uP TVozEoGRJfeebGZwoVBVQBDDrQY6fvhR5XtJoTbsmGWqMcFKuR5LZwzYZ4lwMByfGQ2j BqET2An9Tmxys8aCcJeYKfeotDewwyFC2sQrfA4Ni3JXqU0cba03PaOOYg9v6n8f+jgb oBALiq0PHaDKltX20Jg1bqDV2QQNWs19C5uAkJETWyGW435P4EF61un1l68KrZ4FKBMf 9HlTId0ojYuRWpdL1BGivyR65Bv8sO+U4TmF7Gc4tmLri4o4v1l9rCJBfVaIVwJIjF7U AxXQ== 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=UvtASd/asXTA/GOqfe+7E7h/Aqkvx5Cby7w80f0NLYY=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=zQitjsIAyWOFEewhk+7oLASo6Jd6pC4vv84W9mQe9iLedOB2kEw+FQxA4exewZ8+jX ppC6/RIEMNvrXrbSFgW07bC2ebCjUQ6jaciUPkZbCeYZV8Fe7DujEtBMs4C6jsceiQyg 3CimAnUllrVVaAJgqq8JTqN1jj+GEgdtmRiAfLU8PsyvpTB1uSClex6qnX3ruZjiK8e5 +xKH5PzpM+OXv78aJ70Xl8RYpcD3uh35jaM4Z9g+kmruM/lbmvir3ngwGbQpoFFfoboj hWothaC3JdsapJ0KASmwB+mCnbNYXmicTr3UIpWQVXJyoBoyKHvbRfAmtWoiatTMCQzR h4QA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Cj8rb6a3; 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-35674-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35674-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a24-20020a056a001d1800b006dd7b2c8936si1192538pfx.251.2024.01.23.09.09.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 09:09:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35674-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Cj8rb6a3; 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-35674-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35674-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E2936B2A65D for ; Tue, 23 Jan 2024 16:43:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E4A61292F0; Tue, 23 Jan 2024 16:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Cj8rb6a3" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 6E824823A0; Tue, 23 Jan 2024 16:37:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027830; cv=none; b=cOhtVNDO6+hCj2W7rO21bJkYtnY9j4appuIrbVkd/rKs2kIWQ+++bscNkGafOmEGXxY7lIMe4FQ0YXlMfKm19n3/Nkbylz8PNyZp4w4NXrvSZHH0/QfZ248kN/LLowmqkEJuwd/ZinKWGPmaYFZIypUbcJepVV+QzSUzXTB44fA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027830; c=relaxed/simple; bh=dYCrje2ssLc36AN+z3buna/SfGdx7nGnIMP/hS0/SRw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hFTuMaAbZ/QMzJ96CZkCJOdqLRG65uY7pcSbGNAJ8xTP5exnWXIa75PSKVBCL+Ki6qlY4uCqpP0qp8zMblNrw3xMyA8ntf48mwOwgLkBvjgbSJDx2U3WovabfJ9OkwknpoWNKb/rVvOfn6R7BzqX3/33h0mMS90DJ/H2Oh9k6OY= 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=Cj8rb6a3; arc=none smtp.client-ip=198.47.23.249 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 lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGb0dA095659; 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=UvtASd/asXTA/GOqfe+7E7h/Aqkvx5Cby7w80f0NLYY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Cj8rb6a3/vaYXI793H/zBsa0IaOH0Q/dpt5L9lFODzWKTCnt72F7OoULybes21/+4 tfnoU+/AIWXVDvjfuAc20FRmd9sppaqGlFujLHnd3t6pBXhcDkZDO2l7CFtWkPHngE wI8zxczq65iMZGufXe1mY2xudM66G1CO9NJVt9QE= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGb0qR119754 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:37:00 -0600 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE109.ent.ti.com (10.64.6.30) 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 DFLE100.ent.ti.com (10.64.6.21) 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:37:00 -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 40NGars5123403; Tue, 23 Jan 2024 10:36:59 -0600 From: Andrew Davis To: Sebastian Reichel , Support Opensource , Krzysztof Kozlowski , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= CC: , , Andrew Davis Subject: [PATCH 17/21] power: supply: da9150: Use devm_power_supply_register() helper Date: Tue, 23 Jan 2024 10:36:49 -0600 Message-ID: <20240123163653.384385-18-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 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788901870696480036 X-GMAIL-MSGID: 1788901870696480036 Use the device lifecycle managed register function. This helps prevent mistakes like unregistering out of order in cleanup functions and forgetting to unregister on error paths. Signed-off-by: Andrew Davis --- drivers/power/supply/da9150-charger.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/da9150-charger.c b/drivers/power/supply/da9150-charger.c index 77e2d42382e45..b13cecd84f589 100644 --- a/drivers/power/supply/da9150-charger.c +++ b/drivers/power/supply/da9150-charger.c @@ -538,15 +538,13 @@ static int da9150_charger_probe(struct platform_device *pdev) return PTR_ERR(charger->vbat_chan); /* Register power supplies */ - charger->usb = power_supply_register(dev, &usb_desc, NULL); + charger->usb = devm_power_supply_register(dev, &usb_desc, NULL); if (IS_ERR(charger->usb)) return PTR_ERR(charger->usb); - charger->battery = power_supply_register(dev, &battery_desc, NULL); - if (IS_ERR(charger->battery)) { - ret = PTR_ERR(charger->battery); - goto battery_fail; - } + charger->battery = devm_power_supply_register(dev, &battery_desc, NULL); + if (IS_ERR(charger->battery)) + return PTR_ERR(charger->battery); /* Get initial online supply */ reg = da9150_reg_read(da9150, DA9150_STATUS_H); @@ -606,8 +604,6 @@ static int da9150_charger_probe(struct platform_device *pdev) chg_irq_fail: if (!IS_ERR_OR_NULL(charger->usb_phy)) usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); -battery_fail: - power_supply_unregister(charger->usb); return ret; } @@ -633,9 +629,6 @@ static void da9150_charger_remove(struct platform_device *pdev) if (!IS_ERR_OR_NULL(charger->usb_phy)) usb_unregister_notifier(charger->usb_phy, &charger->otg_nb); cancel_work_sync(&charger->otg_work); - - power_supply_unregister(charger->battery); - power_supply_unregister(charger->usb); } static struct platform_driver da9150_charger_driver = {