Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp673606imu; Fri, 16 Nov 2018 08:28:26 -0800 (PST) X-Google-Smtp-Source: AJdET5dwZOP05flozgCSLkb1YfDDpz4Yh1RS4ybMQGmHQhydh4lKmc3IQ4Hi3bX3skSXEqvm5Zjm X-Received: by 2002:a17:902:bc4c:: with SMTP id t12mr11253944plz.45.1542385706831; Fri, 16 Nov 2018 08:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542385706; cv=none; d=google.com; s=arc-20160816; b=KBEu2P3rG7+3hOvLbKw9k0fg3XrUQmlcpcLfF+MGirPez3G+/NLAPJvJfo6E6gUGNu 8EdKghpB7fajNH4iZQq2fAJTBlhxGmn27s7QLua04aig718DgbWWUm1FjRq8X0X+GyRl RS+VeZxH1cMyheJSD6SOyW3u/sL6O71i7kYU2YKdhgblU/DC19JeGWObOqQspd13BV5M cDgrscyC/K4XyYXxawZGkH2Vbs3N7GcYS6xFVtcYCSK/8gMfgghFrfDr6uVFCGXvG2qz Jl9ciAwc+hlcJQoMra4GFzwsHEazx9BAVPkh7FTHSHsnRUOL5V+0UCwSu8m5q998ePF9 4JeA== 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=/2IRCQ+BEyX6lcNLOoNNeitEro1JZnleBkphQAATQaQ=; b=Owctchr6c2hYS1+4g3QxPxrCVtRY24JfcL0nK75PhvMSFx2xGOMIk8dkWLRDeCYHPz xrkjMq6iSwyVv5SzVc4kAO0A5AeNjosbOhatQcLUrLRtCdkwdJVbSP9cQc53AFJ3Y4Sg CfGoL1a2hBJYr9S7mEkhAiJtfYmuG8IIocgHP+/4Z+u84CkQBO1oySPb9AEI4nKgpIBK DEyLRnr9+5YVCfwnwmASepnTlcaaGtjn3j9FslemQOagTvEz9vg5WHZ+DlWm6fNuiAYc Q4TMg/m49Obm/y795GgLOpNf8xvwq1G302w7SsqZcmpCHpWwhhfHLTmh7563AUl0JeHR MNjQ== 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 v5si29234139pgg.1.2018.11.16.08.28.12; Fri, 16 Nov 2018 08:28:26 -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 S2390334AbeKQCiR (ORCPT + 99 others); Fri, 16 Nov 2018 21:38:17 -0500 Received: from shell.v3.sk ([90.176.6.54]:57146 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390040AbeKQCiQ (ORCPT ); Fri, 16 Nov 2018 21:38:16 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 7F59753211; Fri, 16 Nov 2018 17:25:10 +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 sEpSlKOzO6SR; Fri, 16 Nov 2018 17:24:48 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id BFC9F52DBB; Fri, 16 Nov 2018 17:24:28 +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 d3SuvMZ2BPtG; Fri, 16 Nov 2018 17:24:26 +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 D70F152AE0; Fri, 16 Nov 2018 17:24:19 +0100 (CET) From: Lubomir Rintel To: Mark Brown , Geert Uytterhoeven , Darren Hart , Andy Shevchenko Cc: Greg Kroah-Hartman , James Cameron , Sebastian Reichel , Rob Herring , Mark Rutland , Eric Miao , Haojian Zhuang , Daniel Mack , Robert Jarzmik , linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, devel@driverdev.osuosl.org, linux-pm@vger.kernel.org, Lubomir Rintel Subject: [PATCH v2 15/17] power: supply: olpc_battery: Use devm_power_supply_register() Date: Fri, 16 Nov 2018 17:24:01 +0100 Message-Id: <20181116162403.49854-16-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116162403.49854-1-lkundrak@v3.sk> References: <20181116162403.49854-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 --- 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 b091f897c1d4..4433eb10a23d 100644 --- a/drivers/power/supply/olpc_battery.c +++ b/drivers/power/supply/olpc_battery.c @@ -628,7 +628,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 @@ -643,15 +643,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(olpc_bat)) { - ret =3D PTR_ERR(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) @@ -666,10 +664,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 @@ -679,9 +673,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.19.1