Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp596154rdb; Tue, 23 Jan 2024 08:46:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFh9PTysOjydrncM71NHZBOUxpa6VP1rcvMAxB4t3qSocqMWGi0j4ajZnJ1ZzKIbu07ph/j X-Received: by 2002:a05:6402:518b:b0:55c:850e:1831 with SMTP id q11-20020a056402518b00b0055c850e1831mr843025edd.63.1706028367348; Tue, 23 Jan 2024 08:46:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706028367; cv=pass; d=google.com; s=arc-20160816; b=0tKFrOkzDzU1Fpvy8KPidCfcoHSUC7DN54C7wXjlMIHkeg5pamGOkYccWeXlEuiAu3 hqdaU8i3koRr4+c3XO6q6oeYtTW7ZLQ7cercUq8dp/0kHsUcC78VDRweHrds9C9sT2mn pRqIJkrL8rUgCs81HzOwc4XXx/spX1672raryurIEbqgffpyAFqNktmufnPq4jrkNmdG 9GCYd/UiCDmf6De9VMVflttsRewxJJC20pLS3MEq1qvlKKb0XLyBa/3cKE2oY0JBU0W3 9P2+HHJx4TydClwD5rRwSYy0tqSZdUxtBEMgUMf9DMZvXQAeCp7JJ6Wnd9YlGjKwfVFz 5qxQ== 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=NynlMJZVVWmFK6HEqJQ06332dhB5iMXyjOa26cOux3g=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=J8ERJn4Jjq3+9dxWIcWYFMLkEeYMMe1UKbX/mE3viuM1RfGcX79AC/YpEAQf3tzEFE ow9+lREmzGbvT8HWneO85X3+a2ByHc8hRhRXcirH9XTrGL6TXVaObGFMjAKyq3TKFktQ tELeD8cU4p+dzZLf/7UoetBunpkhMWk0/Q542JZoYFARL82GlL6glGLTuYlS55IDE0HV xE3Sa0gStcDAZaBW3rtWZ7ku4RO9y3IfxXgppWySnpv3TTh9SIM2Ba5T4EA9Rnz4lNqv yrAX2mdoL+pVOw8ewrlhPwpoO13nYfPDQYOfHQirl/5MS4XPT0Rf2oAhR4ILZS4znZxZ gScA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="En/XbSYb"; 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-35669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35669-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. [147.75.80.249]) by mx.google.com with ESMTPS id w6-20020a05640234c600b0055c65f87f49si1570851edc.287.2024.01.23.08.46.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:46:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="En/XbSYb"; 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-35669-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35669-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 AC0B51F2C250 for ; Tue, 23 Jan 2024 16:40:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA04C8612D; Tue, 23 Jan 2024 16:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="En/XbSYb" 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 2FBBB80046; 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=1706027829; cv=none; b=P6eKtePJbOun7wXPcd16AETVBr9Otl42VQMD+H3FXlVyoYryFHTCAmOFgASxri5zBSTKiz5fH6psdXNCko3E/MIWXM9UipsGK5Wy6N51sEKE/a5j4Ox54CQbhq1YnmKRge7XrR/ysaJUsvo3GH5OefzI/zGi/NP8TcnYheGIN24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027829; c=relaxed/simple; bh=AOscs8QIG573GTnqalFMMwHtcQ8ONmRuwieK8uqlR40=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ryqcfJRfO5cYPeOLlz/ywwwWi/HdvmSoGxVTM+mRVyTwvSuKJNvmtAtLZJxot1vYfvp8tMPj7HLm7BhWH3wXFR0QLwWPuKWoGCpX2+PDot84eCqcfX+XyyuEXJdOogkSGG1kF0Ml7N9AIgmIH5Bc9e4VHGwYF8gY4qp4ocOqwKs= 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=En/XbSYb; 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 lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGax8N094134; Tue, 23 Jan 2024 10:36:59 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706027819; bh=NynlMJZVVWmFK6HEqJQ06332dhB5iMXyjOa26cOux3g=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=En/XbSYbkpAcJ6Xir3CNLJiY1RSv1Tblem41AtTRy3eVfDAYyubRm40jysHFe5o5e yR7dxzI1qPLHTXBJQ5jwyiTPbYEe/0eYi8DXg4GB4tIi4PfEnV8nFwypqppuesg6CP 6i/sCNkGkSQt4pv5UKakL8dTC5VASwYwq1MsjC+g= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGaxU5119736 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:36:59 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE111.ent.ti.com (10.64.6.32) 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 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 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 40NGars3123403; Tue, 23 Jan 2024 10:36:58 -0600 From: Andrew Davis To: Sebastian Reichel , Support Opensource , Krzysztof Kozlowski , =?UTF-8?q?Pali=20Roh=C3=A1r?= CC: , , Andrew Davis Subject: [PATCH 15/21] power: supply: wm8350: Use devm_power_supply_register() helper Date: Tue, 23 Jan 2024 10:36:47 -0600 Message-ID: <20240123163653.384385-16-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 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/wm8350_power.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/power/supply/wm8350_power.c b/drivers/power/supply/wm8350_power.c index f23b4f5343bc1..9b0010b28cafc 100644 --- a/drivers/power/supply/wm8350_power.c +++ b/drivers/power/supply/wm8350_power.c @@ -540,22 +540,17 @@ static int wm8350_power_probe(struct platform_device *pdev) struct wm8350_charger_policy *policy = power->policy; int ret; - power->ac = power_supply_register(&pdev->dev, &wm8350_ac_desc, NULL); + power->ac = devm_power_supply_register(&pdev->dev, &wm8350_ac_desc, NULL); if (IS_ERR(power->ac)) return PTR_ERR(power->ac); - power->battery = power_supply_register(&pdev->dev, &wm8350_battery_desc, - NULL); - if (IS_ERR(power->battery)) { - ret = PTR_ERR(power->battery); - goto battery_failed; - } + power->battery = devm_power_supply_register(&pdev->dev, &wm8350_battery_desc, NULL); + if (IS_ERR(power->battery)) + return PTR_ERR(power->battery); - power->usb = power_supply_register(&pdev->dev, &wm8350_usb_desc, NULL); - if (IS_ERR(power->usb)) { - ret = PTR_ERR(power->usb); - goto usb_failed; - } + power->usb = devm_power_supply_register(&pdev->dev, &wm8350_usb_desc, NULL); + if (IS_ERR(power->usb)) + return PTR_ERR(power->usb); ret = device_create_file(&pdev->dev, &dev_attr_charger_state); if (ret < 0) @@ -569,13 +564,6 @@ static int wm8350_power_probe(struct platform_device *pdev) wm8350_reg_lock(wm8350); } - return ret; - -usb_failed: - power_supply_unregister(power->battery); -battery_failed: - power_supply_unregister(power->ac); - return ret; } @@ -586,9 +574,6 @@ static void wm8350_power_remove(struct platform_device *pdev) free_charger_irq(wm8350); device_remove_file(&pdev->dev, &dev_attr_charger_state); - power_supply_unregister(power->battery); - power_supply_unregister(power->ac); - power_supply_unregister(power->usb); } static struct platform_driver wm8350_power_driver = { -- 2.39.2