Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp597642rdb; Tue, 23 Jan 2024 08:49:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcJ458gSiTQg2FCtHcBBHPHnMBFlTBsHVoQWbXqDM+wMXJ+9p9941GpWByVoGGTQHiNvNn X-Received: by 2002:a17:90b:2355:b0:290:7914:dfb5 with SMTP id ms21-20020a17090b235500b002907914dfb5mr2228327pjb.92.1706028539952; Tue, 23 Jan 2024 08:48:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706028539; cv=pass; d=google.com; s=arc-20160816; b=VcNDU5L2LB6X9u294C8Ll8xBhC2nWoA9VmmX1ghaNKwjCemhHCFKcy84kDJfh2h0MV 5/bh/i3I0wD9dqDGzqWgBcWbHXuKpI7iQofY5JcbiL/VkMYVkPJPPEW7cRKvIkdsetqE 8tLsT5+aXt+Q7+5l2QgI+N0ruoISbRYZr+gFjfsH2eO28LVMMDYjz5V6V8DV2HVpZTPN DiwhYwbgJkqigwwgQLc9Ew1HjsMZFH9iXjryviP506n7jGa+GtZ55SM8VvgL6eET5wJm 5DCE+zuY4DZ41Its4fuVyruZcqiRbQ/DpXskJUTMUHEzZoSlxkwW65JMoWfZ6W3YatMO iY6g== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35674-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id br11-20020a17090b0f0b00b00290c2e78fc8si2163921pjb.147.2024.01.23.08.48.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:48:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35674-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35674-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EF4D2291FAF for ; Tue, 23 Jan 2024 16:41:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A3A686AD4; 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="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=20Roh=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 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/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 = { -- 2.39.2