Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp597976rdb; Tue, 23 Jan 2024 08:49:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI7Oc+XtoCd500v4R4kVistml1x1XjcN10Ua9mkYxSzXOtxQ9c4ga0TSuE+1dSG3voTdlR X-Received: by 2002:a17:90a:ce83:b0:290:2b64:c84c with SMTP id g3-20020a17090ace8300b002902b64c84cmr2815251pju.77.1706028583298; Tue, 23 Jan 2024 08:49:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706028583; cv=pass; d=google.com; s=arc-20160816; b=tSSS7fce59Z9hw4sQF3uJxpYSO5t5e2UMkUzOr//8GdxwIOcic/IsdEj7AGcbQC8aa GZBoNgGiBn0iIpJUhPyHL78WfJrbVrdykDv5GYDlDQ0sSEZhc+C3B12SGXClcEXGd638 ZpzzQvhvA1908lQU93ZwWRp3Nq81xwRPcCspFozrn65eOt9AE7ps7VI6/u3m/NBC/o6v 5NRpVE0wuAJDDKJLn4l0R4mcljjVOpbsVJqystA8HL0XnBvuzzlnfCXZtwHGdqzYXYVJ UEBT1/WDU5/kT3DM7K6pBONVktRxVSspixvQTzjXsJctB1YbUKv2VdVb05Fmp+hua9pS XhgQ== 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=E33CzJiobEDNF9PypNy3HQMQ/t8tZZOrwMdlqCyg1Ws=; fh=pozOWq+Llr4uSsAlLarsoaPJ+QQ4TuIyCJyc15dU4WI=; b=TqY8RGaTnfXiXcPa/nZI+wr2Dtf/wcV5baLNDB2s5eFqsjAK7RdlyDuQ3oejiz+yVQ jDIjF9oyjjrKqiMSQxyy4MHTb/V/a6Ho/Mhvq2MAdtUkEFpq/mw82OJgtd6T2nrBj8AE iwBSCiApj0xxz3l0ZoHEHMwsCqwSbIZKRqt4fPT4mX6LkRovgc9HADdzUc+JRRSGn6to 3S551rE92N/lJIItncNkNdo8AaOR+sazrqqqgKiDrYoSOuq7s4ajg4xWptP9tso2fdXn D9JO59EHDoXi68KFWqUJugigcsP9n2ISjZS3lw48Adf03fKy2W2e6kPGMqS4WilHl1sW 2whw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=glIL0hdb; 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-35666-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35666-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 o4-20020a17090ad24400b00290cb6d12c5si1656217pjw.157.2024.01.23.08.49.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:49:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35666-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=glIL0hdb; 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-35666-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35666-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 458F328E607 for ; Tue, 23 Jan 2024 16:40:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86BA285C7C; 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="glIL0hdb" 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 BEA9F811E9; 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=1706027828; cv=none; b=T/JzsTvBwjz23ci0jcbboShzZq9OK97eLtc8dLoe/qVkJILe17NrVMoJrlHoidjWi0GPbmaP+F+owbO3A0NRL1Fzi2+Q3FUvFO3tBn1ImlvlRMkIrrYHyTuhAptxIdUYXAeSPIyc3aaS9/P5ZbC95U3/hRppk2IXvtVKH2yXLDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706027828; c=relaxed/simple; bh=Mt9VGXSLpx6lU+a/atqtbnv9Q7Fuz7Ts4+Nnj4wDzCc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iae2eCHDf+J0ANMo/TXJb2SGf9AXh0G++/xItbrbPnqxFsfNmKApK8+lTb/Bz0rYAIuK06E6xdOzAii5QQbJLYU+ghAKB+ElQU4TUe6E25ELoEk9fPNpa+uYkEQGzswF7B6FLgrmYbJ+NIIDpWlFo3msiBjXwrm9X+dH7s57z4I= 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=glIL0hdb; 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 fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40NGb1HT094151; Tue, 23 Jan 2024 10:37:01 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706027821; bh=E33CzJiobEDNF9PypNy3HQMQ/t8tZZOrwMdlqCyg1Ws=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=glIL0hdb2lSd4PuTlHy5p117GvpPZ7tYFFyGGzjXFeLmpZ+tV4gFIYb3UUTM5zHmK 6mPyx1HreOTYf853E9hcrgLKapJGRFub3y4z+jkbejNwntXsyKK4qTNf204BwsZJSL cwy8ou+9+48Ra0DWXGAk0XClmhlOwlH8hyBWNXd8= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40NGb1X6004284 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 23 Jan 2024 10:37:01 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) 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:37:00 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE115.ent.ti.com (10.64.6.36) 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 40NGars8123403; Tue, 23 Jan 2024 10:37:00 -0600 From: Andrew Davis To: Sebastian Reichel , Support Opensource , Krzysztof Kozlowski , =?UTF-8?q?Pali=20Roh=C3=A1r?= CC: , , Andrew Davis Subject: [PATCH 20/21] power: supply: twl4030_madc: Use devm_iio_channel_get() helper Date: Tue, 23 Jan 2024 10:36:52 -0600 Message-ID: <20240123163653.384385-21-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 get function. This helps prevent mistakes like releasing out of order in cleanup functions and forgetting to release on error paths. Signed-off-by: Andrew Davis --- drivers/power/supply/twl4030_madc_battery.c | 44 ++++++--------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/power/supply/twl4030_madc_battery.c b/drivers/power/supply/twl4030_madc_battery.c index 33106476bea2c..cd9e94134ab21 100644 --- a/drivers/power/supply/twl4030_madc_battery.c +++ b/drivers/power/supply/twl4030_madc_battery.c @@ -188,30 +188,23 @@ static int twl4030_madc_battery_probe(struct platform_device *pdev) struct twl4030_madc_battery *twl4030_madc_bat; struct twl4030_madc_bat_platform_data *pdata = pdev->dev.platform_data; struct power_supply_config psy_cfg = {}; - int ret = 0; twl4030_madc_bat = devm_kzalloc(&pdev->dev, sizeof(*twl4030_madc_bat), GFP_KERNEL); if (!twl4030_madc_bat) return -ENOMEM; - twl4030_madc_bat->channel_temp = iio_channel_get(&pdev->dev, "temp"); - if (IS_ERR(twl4030_madc_bat->channel_temp)) { - ret = PTR_ERR(twl4030_madc_bat->channel_temp); - goto err; - } + twl4030_madc_bat->channel_temp = devm_iio_channel_get(&pdev->dev, "temp"); + if (IS_ERR(twl4030_madc_bat->channel_temp)) + return PTR_ERR(twl4030_madc_bat->channel_temp); - twl4030_madc_bat->channel_ichg = iio_channel_get(&pdev->dev, "ichg"); - if (IS_ERR(twl4030_madc_bat->channel_ichg)) { - ret = PTR_ERR(twl4030_madc_bat->channel_ichg); - goto err_temp; - } + twl4030_madc_bat->channel_ichg = devm_iio_channel_get(&pdev->dev, "ichg"); + if (IS_ERR(twl4030_madc_bat->channel_ichg)) + return PTR_ERR(twl4030_madc_bat->channel_ichg); - twl4030_madc_bat->channel_vbat = iio_channel_get(&pdev->dev, "vbat"); - if (IS_ERR(twl4030_madc_bat->channel_vbat)) { - ret = PTR_ERR(twl4030_madc_bat->channel_vbat); - goto err_ichg; - } + twl4030_madc_bat->channel_vbat = devm_iio_channel_get(&pdev->dev, "vbat"); + if (IS_ERR(twl4030_madc_bat->channel_vbat)) + return PTR_ERR(twl4030_madc_bat->channel_vbat); /* sort charging and discharging calibration data */ sort(pdata->charging, pdata->charging_size, @@ -227,21 +220,10 @@ static int twl4030_madc_battery_probe(struct platform_device *pdev) twl4030_madc_bat->psy = power_supply_register(&pdev->dev, &twl4030_madc_bat_desc, &psy_cfg); - if (IS_ERR(twl4030_madc_bat->psy)) { - ret = PTR_ERR(twl4030_madc_bat->psy); - goto err_vbat; - } + if (IS_ERR(twl4030_madc_bat->psy)) + return PTR_ERR(twl4030_madc_bat->psy); return 0; - -err_vbat: - iio_channel_release(twl4030_madc_bat->channel_vbat); -err_ichg: - iio_channel_release(twl4030_madc_bat->channel_ichg); -err_temp: - iio_channel_release(twl4030_madc_bat->channel_temp); -err: - return ret; } static void twl4030_madc_battery_remove(struct platform_device *pdev) @@ -249,10 +231,6 @@ static void twl4030_madc_battery_remove(struct platform_device *pdev) struct twl4030_madc_battery *bat = platform_get_drvdata(pdev); power_supply_unregister(bat->psy); - - iio_channel_release(bat->channel_vbat); - iio_channel_release(bat->channel_ichg); - iio_channel_release(bat->channel_temp); } static struct platform_driver twl4030_madc_battery_driver = { -- 2.39.2