Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2191332imu; Thu, 10 Jan 2019 09:45:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN7k4LDag5qRRh8Ynn+ZDZ7Pa6oaWgqk3EjvrpeXyIJGicBDV0nzZY7fn9Y2+FN/8eR2eyQ1 X-Received: by 2002:a62:26c7:: with SMTP id m190mr11304760pfm.79.1547142305114; Thu, 10 Jan 2019 09:45:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142305; cv=none; d=google.com; s=arc-20160816; b=ybttyHdrOuOt2sp8Z/FjKnRSET7d6GFw0scfpo36hgOjLMUb0/0Q0DwQrKQ22pD3lK z1VvHw8/ECS6uB9YbeOlXmMtNWJwFIeULLBGz5a7z7NnhIBGltnwvFnRBYSzyDetngus MJme/k1ZEWwcCWnXlGaWjPGm9shpfVolRfI+Crlx1zw7ZavOySa3cMSgUtPkvttQUQik UX4JtMT7u74mBK2U/zLFoX24laK2O/jqUPxSSZz85ez2UqptSH/G7mt3eS+DNPIWsVCm pYkRpT399vv3zLtHKfN7WsEaROOcOY3pzD+6q/klnLnIqBBSDM1gfVGlx1/Sj5ixfB8V DdhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4ycdf81QRAoMmtkhrhTim4ePQLjFTmOvW/s1unQ8xAs=; b=RIx7BG5gdSi4ZjNtmOFMetywIfXGk0LW5CCFRjJIKOBI5JLKaOX8m+mXl/SLJOlOmA dWoXfoZNHoO1ZyPChGjyXQJkiqO/bYIMfg3lFVSxyKysR4pe1+1FGVy5eKW8TcJJj8aY T2wUf6yc14sO+xKlbfzbZ+bl0gfsjDMkXQxZlJ9PFs09RsRCkAoUtyn8BIurSQyBqzCc N2GX9pSlq1d9ZkpTR4RbxKnAtHRit+w4j8L+6zaGRV4z0hXVF+9KWC87yz4mjlLGdXVp EnEGo+nJ1QziZQSbsZJd3uDz4RKb9bHs8JbqWPCOfZg0AtsCHRHoxqsMwHyehe5GZhl1 fxIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j14si25305266pgi.354.2019.01.10.09.44.50; Thu, 10 Jan 2019 09:45:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730745AbfAJRm2 (ORCPT + 99 others); Thu, 10 Jan 2019 12:42:28 -0500 Received: from shell.v3.sk ([90.176.6.54]:58395 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730717AbfAJRmZ (ORCPT ); Thu, 10 Jan 2019 12:42:25 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id CEF611002E6; Thu, 10 Jan 2019 18:42:23 +0100 (CET) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id plXHm1UC-Qus; Thu, 10 Jan 2019 18:42:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 5E12D1002E5; Thu, 10 Jan 2019 18:42:07 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TgMpJF7der0x; Thu, 10 Jan 2019 18:42:04 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id 83D481002E9; Thu, 10 Jan 2019 18:42:03 +0100 (CET) From: Lubomir Rintel To: Sebastian Reichel Cc: Rob Herring , Mark Rutland , x86@kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Lubomir Rintel , Sebastian Reichel Subject: [PATCH v5 5/7] power: supply: olpc_battery: Use devm_power_supply_register() Date: Thu, 10 Jan 2019 18:40:03 +0100 Message-Id: <20190110174005.1202564-6-lkundrak@v3.sk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110174005.1202564-1-lkundrak@v3.sk> References: <20190110174005.1202564-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This simplifies the error handling. Signed-off-by: Lubomir Rintel Reviewed-by: Sebastian Reichel --- Changes since v1: - This was split off the "power: supply: olpc_battery: Move priv data to a struct" patch. drivers/power/supply/olpc_battery.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/o= lpc_battery.c index 7067cb500669..1fcc459433a8 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -634,7 +634,7 @@ static int olpc_battery_probe(struct platform_device = *pdev) psy_cfg.of_node =3D pdev->dev.of_node; psy_cfg.drv_data =3D data; =20 - data->olpc_ac =3D power_supply_register(&pdev->dev, &olpc_ac_desc, &psy= _cfg); + data->olpc_ac =3D devm_power_supply_register(&pdev->dev, &olpc_ac_desc,= &psy_cfg); if (IS_ERR(data->olpc_ac)) return PTR_ERR(data->olpc_ac); =20 @@ -649,15 +649,13 @@ static int olpc_battery_probe(struct platform_devic= e *pdev) olpc_bat_desc.num_properties =3D ARRAY_SIZE(olpc_xo1_bat_props); } =20 - data->olpc_bat =3D power_supply_register(&pdev->dev, &olpc_bat_desc, &p= sy_cfg); - if (IS_ERR(data->olpc_bat)) { - ret =3D PTR_ERR(data->olpc_bat); - goto battery_failed; - } + data->olpc_bat =3D devm_power_supply_register(&pdev->dev, &olpc_bat_des= c, &psy_cfg); + if (IS_ERR(data->olpc_bat)) + return PTR_ERR(data->olpc_bat); =20 ret =3D device_create_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); if (ret) - goto eeprom_failed; + return ret; =20 ret =3D device_create_file(&data->olpc_bat->dev, &olpc_bat_error); if (ret) @@ -672,10 +670,6 @@ static int olpc_battery_probe(struct platform_device= *pdev) =20 error_failed: device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); -eeprom_failed: - power_supply_unregister(data->olpc_bat); -battery_failed: - power_supply_unregister(data->olpc_ac); return ret; } =20 @@ -685,9 +679,6 @@ static int olpc_battery_remove(struct platform_device= *pdev) =20 device_remove_file(&data->olpc_bat->dev, &olpc_bat_error); device_remove_bin_file(&data->olpc_bat->dev, &olpc_bat_eeprom); - power_supply_unregister(data->olpc_bat); - power_supply_unregister(data->olpc_ac); - return 0; } =20 --=20 2.20.1