Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp591788rdb; Tue, 23 Jan 2024 08:38:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKONU+7jCtz13NL4UhOlSJ/KYMun9z/Nlf7pOIPOJD6BI+VQ2W/IMLd0tJ7rdda6XjOYP+ X-Received: by 2002:a05:620a:2889:b0:781:bd79:dcf8 with SMTP id j9-20020a05620a288900b00781bd79dcf8mr11363680qkp.65.1706027899903; Tue, 23 Jan 2024 08:38:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706027899; cv=pass; d=google.com; s=arc-20160816; b=GeCKipqZ3voZz3hLzLw5tOgc00LWIYyJok5o9CJnUih2njjJs84gMPBlD1dFobVC1B KuljGmxPfK8gxRosAcdNkwhfAUmA5+ypSUecPjwmnR3hUZvAmOcWoN7qj2qdg8XRxMHx QQrNs3YwlCM0xOBvTYR+jcakuZmpJ6OPin45niorh15YqIWfpU6UNQnTn0XzAgQPXGko LOALaeBjuf5fI2tAGN2vll7zXMABwTx3W2JypGb0oPWPFclCPn3aQUEjNCJss3RDTgyU uEv3w6GwEIkIepEEzR0uRzDqmPAwzy0pwEb3cGkqOYOCY/rqPl3a2LzEM7C8SGX04Vi8 7Jcw== 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=kY60sQE2O0mWnnL7W1my2Lgy6WoutICMhmnbxu89kcA=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=S5kLPDw1BlM5aO8bVunmVush/2azotkJI8/sFOy1FQ28g8TsPp03dArwYlGDjiQqn3 QVfzS9M3TGjUonGrhiY5NDzvw+LOVZphqgb+FX7RUApgKYBxQmIwin6i/MSCiBZVXB/L DRvaYjQKyXg7d/5QPIM55/vR66bSNvr8K6cu0c+cJ0sTRMCIpPdoV+8mv1qS83nOfdb5 LSkNVrXKF4rFkRYOTWaVdN8lmw1yRTuR+HPvpY4YchdjsPKq+A1utjx5UqtYWL0fg4Ly ntnvKJH5BBigBrrEGNEgOl0pP7scI1eGyXdtYQXgvq9Bis+FH9tq9G89JvueHEyPjkvN bENQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YhJCOtRC; 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-35660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35660-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 w35-20020a05622a192300b00429f1b15880si8199749qtc.142.2024.01.23.08.38.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:38:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35660-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=YhJCOtRC; 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-35660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35660-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 A5FBC1C2199D for ; Tue, 23 Jan 2024 16:38:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 994A28005C; Tue, 23 Jan 2024 16:37:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="YhJCOtRC" Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 153237F7E2; Tue, 23 Jan 2024 16:37:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.248 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027825; cv=none; b=NQ2Ux2oExXWp++FRZv1WzAYc4VUKnl6hx1G6v2zOXmrVV18nvM7JVziJg5cp3eyEQlFnPIu8bslfcR1xcOIFJ1qrqz0NW34p8nXJN0uxA7a1U3+IQwr4WcE4CDeeZVNdZYcCwPBferT0VFAibHBSUQ0/1esKyhUg/6/m2yVYKLE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027825; c=relaxed/simple; bh=OY2361TGwrkXPrQ1UsenLqUtBgbOE0Azmm4BwfLansg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kOSQzyd/55s/YZSjgZ7dXkl7Zvz8a07PqyvRX/t5CazK6SQtkCg2UrC0+M9FROAuyz0u1/gP+l6Oeu6ogL1H/oyGKmbQj35RudoMXZzI5pXs++qTGBLGagK0sFCv8Nh9rGOw2L5wV7IPgl4NyRh7XKAfJSkNuDcQrIg8nex+Z4k= 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=YhJCOtRC; arc=none smtp.client-ip=198.47.23.248 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 lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGatk2049949; Tue, 23 Jan 2024 10:36:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706027815; bh=kY60sQE2O0mWnnL7W1my2Lgy6WoutICMhmnbxu89kcA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YhJCOtRCdPuqytKsPHHQo9zyjvkAqoOHUcWNfmezYI1V8ft+l3nIKTaKt4uCci1lt Pd1G7JlLLw9rXw7wLzcVnEIuqud/y3hxz1cTD3inGCts6FLMBl40bvjYeW3A7ZmDcm D2LdiCvcXyX6tXwemYHky7+2dZls4ph3xayMZOyY= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGathg033944 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:36:55 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE114.ent.ti.com (157.170.170.25) 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:55 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE115.ent.ti.com (157.170.170.26) 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:55 -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 40NGarrp123403; Tue, 23 Jan 2024 10:36:55 -0600 From: Andrew Davis To: Sebastian Reichel , Support Opensource , Krzysztof Kozlowski , =?UTF-8?q?Pali=20Roh=C3=A1r?= CC: , , Andrew Davis Subject: [PATCH 03/21] power: supply: ds2760: Use devm_power_supply_register() helper Date: Tue, 23 Jan 2024 10:36:35 -0600 Message-ID: <20240123163653.384385-4-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/ds2760_battery.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/power/supply/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c index 40fba31be1744..7cf4ea06b5003 100644 --- a/drivers/power/supply/ds2760_battery.c +++ b/drivers/power/supply/ds2760_battery.c @@ -739,7 +739,7 @@ static int w1_ds2760_add_slave(struct w1_slave *sl) if (current_accum) ds2760_battery_set_current_accum(di, current_accum); - di->bat = power_supply_register(dev, &di->bat_desc, &psy_cfg); + di->bat = devm_power_supply_register(dev, &di->bat_desc, &psy_cfg); if (IS_ERR(di->bat)) { dev_err(di->dev, "failed to register battery\n"); retval = PTR_ERR(di->bat); @@ -762,7 +762,6 @@ static int w1_ds2760_add_slave(struct w1_slave *sl) goto success; workqueue_failed: - power_supply_unregister(di->bat); batt_failed: di_alloc_failed: success: @@ -777,7 +776,6 @@ static void w1_ds2760_remove_slave(struct w1_slave *sl) cancel_delayed_work_sync(&di->monitor_work); cancel_delayed_work_sync(&di->set_charged_work); destroy_workqueue(di->monitor_wqueue); - power_supply_unregister(di->bat); } #ifdef CONFIG_OF -- 2.39.2