Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp592582rdb; Tue, 23 Jan 2024 08:39:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXsNN7251z2zNr/oBitNQzZBKC9xR05BcnLpadbZuBQR6mKk0deAT4kSw2fqI//19flO1Q X-Received: by 2002:a05:620a:8414:b0:783:4a89:f1d9 with SMTP id pc20-20020a05620a841400b007834a89f1d9mr5684404qkn.59.1706027978890; Tue, 23 Jan 2024 08:39:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706027978; cv=pass; d=google.com; s=arc-20160816; b=BY7HRnBXivhRQJPE/zSY8edf6PHvNUQF1FbSxxjdR7yAOcvtJZUPJ4AGUKC/EM+ydz LKDT4i+/968wpS60vVwTbMRU8H/FdjD4IH+To/SkOnLOkRSn4jCjstX3w62FOM8pEtYK 3yqvGMg/7pMjtUDEnjROGfdn5uRL53iNyGzX3rt9HfcrOhxP4ZtYa0m5StZwPNYi0cWB m3/oVBJw7pmnIDxVGPs0j+IL7p4qFG5A4hc4fHkqADUcsYUafLutx58yarGAuxs7L7k9 JyFAU6f02+uk46HakiZmQoM3SEeGrB5tgOETbTzSrii2AZCBvtudbS9MFhoVE4upDukf aY7w== 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=83SpcOyjCoqAmqeGTJTVnxyk1THrczdzUYeXisGgzPA=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=0CYNzC1PW9l8JCEDYg8g1gBiC0PT7Xf3kEt2D5+yu1WItmv715DOtR33abdf5q1EZS adYSGWpx8RrMNUZCp5bc9jtSD7GYTs7fWt7t99YGStJrBA99JH6RQf3f81Akn5IRvW+n yxqrGF4H/ChcEOpXwcmOaU0L7/t3Ledvtggu72f8WNqA7b7U2LgqeuIKnDKaHwTPkmXS IfxV2yznOBgQZmW7gT9uWIIBKkjJLy1kmKhoAZjiYrrVaBUc9KmCmPVnstvQrWAVxzgZ faPtWnCHG6I2Do75YFITR9Vs2FTxRD7NFnfHPmFpkZOQiRHfilfoO+39NNuoIxw+cLG/ v1qg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NJ6tdGU1; 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-35665-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id sq25-20020a05620a4ad900b007812c8e4f2esi7930806qkn.510.2024.01.23.08.39.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:39:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35665-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NJ6tdGU1; 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-35665-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35665-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A51AD1C23ACA for ; Tue, 23 Jan 2024 16:39:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 129DB823D0; Tue, 23 Jan 2024 16:37:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="NJ6tdGU1" 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 BC1898002A; Tue, 23 Jan 2024 16:37:05 +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=1706027827; cv=none; b=oSMsLCwBEDw7M7fVr5fHJIdhDDHrmioko455u3/02UelAJ5NO0NOqrlB/H8TiAEPRdi+HOjoBQUK0UgbwYtJ+qRgz19SyXi15ZXW2nrHeTPNjTSaC2QfegczMuzBCvjP6VGc9ACFY1xoFbV09UFVtv4yvUp946pNK9gq3F9P/V8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027827; c=relaxed/simple; bh=bHb2knvd146pNFVcG5N5iKz+RCtUYH/df5O6GziDkaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hVQ2Fp1iKFRezAd9BAg1abRpoZkcOs3NCBUxpgYwwwzbs1n1geJ2J5Ad/R2FdmBy5d0Sd3LoV7DsRmqaf2qoupBw4PaErd0peXnVlgYbjfaLC4COhttZVFVf66jXUWvyVuOP55UraAelysRG11XysM6RVSGY8AG2IVKkrPwqHik= 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=NJ6tdGU1; 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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGaxNE095654; 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=83SpcOyjCoqAmqeGTJTVnxyk1THrczdzUYeXisGgzPA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NJ6tdGU1KMfeefTFAwsWjeZ9hFvFCwZzf5apwd91qgYVnm1wYWruXH7Is3ax7gd98 d/LY64ImgDfUS56O4MhpDZmmcuyF6mAAZezCY+KIdedVc/FUhPPwswvNl2remJWd5Z HQrrDuPyzCifZO9TPg3J938g3HKfhjGPz1YcWa94= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGax4R000602 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:36:59 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) 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:58 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE106.ent.ti.com (10.64.6.27) 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:58 -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 40NGars2123403; 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 14/21] power: supply: wm831x: Use devm_power_supply_register() helper Date: Tue, 23 Jan 2024 10:36:46 -0600 Message-ID: <20240123163653.384385-15-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/wm831x_power.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/power/supply/wm831x_power.c b/drivers/power/supply/wm831x_power.c index e49b01ee5f3ef..d56e499ac59fb 100644 --- a/drivers/power/supply/wm831x_power.c +++ b/drivers/power/supply/wm831x_power.c @@ -570,8 +570,9 @@ static int wm831x_power_probe(struct platform_device *pdev) power->wall_desc.properties = wm831x_wall_props; power->wall_desc.num_properties = ARRAY_SIZE(wm831x_wall_props); power->wall_desc.get_property = wm831x_wall_get_prop; - power->wall = power_supply_register(&pdev->dev, &power->wall_desc, - NULL); + power->wall = devm_power_supply_register(&pdev->dev, + &power->wall_desc, + NULL); if (IS_ERR(power->wall)) { ret = PTR_ERR(power->wall); goto err; @@ -582,7 +583,9 @@ static int wm831x_power_probe(struct platform_device *pdev) power->usb_desc.properties = wm831x_usb_props; power->usb_desc.num_properties = ARRAY_SIZE(wm831x_usb_props); power->usb_desc.get_property = wm831x_usb_get_prop; - power->usb = power_supply_register(&pdev->dev, &power->usb_desc, NULL); + power->usb = devm_power_supply_register(&pdev->dev, + &power->usb_desc, + NULL); if (IS_ERR(power->usb)) { ret = PTR_ERR(power->usb); goto err_wall; @@ -599,9 +602,9 @@ static int wm831x_power_probe(struct platform_device *pdev) power->battery_desc.num_properties = ARRAY_SIZE(wm831x_bat_props); power->battery_desc.get_property = wm831x_bat_get_prop; power->battery_desc.use_for_apm = 1; - power->battery = power_supply_register(&pdev->dev, - &power->battery_desc, - NULL); + power->battery = devm_power_supply_register(&pdev->dev, + &power->battery_desc, + NULL); if (IS_ERR(power->battery)) { ret = PTR_ERR(power->battery); goto err_usb; @@ -684,12 +687,8 @@ static int wm831x_power_probe(struct platform_device *pdev) irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "SYSLO")); free_irq(irq, power); err_battery: - if (power->have_battery) - power_supply_unregister(power->battery); err_usb: - power_supply_unregister(power->usb); err_wall: - power_supply_unregister(power->wall); err: return ret; } @@ -717,11 +716,6 @@ static void wm831x_power_remove(struct platform_device *pdev) irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "SYSLO")); free_irq(irq, wm831x_power); - - if (wm831x_power->have_battery) - power_supply_unregister(wm831x_power->battery); - power_supply_unregister(wm831x_power->wall); - power_supply_unregister(wm831x_power->usb); } static struct platform_driver wm831x_power_driver = { -- 2.39.2