Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp677421yba; Thu, 18 Apr 2019 07:50:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzY2FcGDekbgai2QY5Yei4+NkSmbq3OhR5e4OSqYHN0RU3K7AYaKWUk8V0iovCEeqhSkDq/ X-Received: by 2002:a62:ed16:: with SMTP id u22mr96760301pfh.47.1555599038545; Thu, 18 Apr 2019 07:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555599038; cv=none; d=google.com; s=arc-20160816; b=SiI9jjYILw+p89EMO4Jmwpmt+FpNcYzRP4MR2l86fm70RQTZ0lrqj0/DJgrHTfRVAX hnKaIo2uIcd1ACADaUeciYzColC55sI2la/BEP3Vtf4fuGR3T3ZMB42ypaGs08Eu6B1P 4LbPPz8VJTwLY0XQFeIynKkAk6W1dAyxid4VnvnMp1LrSX0QnXHgOBEPCqBZq5kY7/Pl OPayfSbW6cejvSQa5XTYJad+f4WPjatLzsgodq82cW4aOUmxDYkci+MJ6vxQk6IS8jj+ sp5R2l2OmE+ETwwJkt3NhsjGEfTCX5zAH+9eb27vS8ZVgQ5b7E9x3bkb35Pdpj3a50HA c1YQ== 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=IDVu+937hD8n01SUKy227qz5VH388R+5f6BS6Z6ymxQ=; b=jfDaNqpmee6EfrnHKlmqPxvAILYViKacHInDcEHwio8pWONL2rkFo5DvZMnXXoX3ZM sGqq/qwZjo0/Fv+NE+DMpatWLsFWiK2naMPRemZAiMNlYwprRuGB6HDD64xDjhC9nBHN KQteBubRpLOts072y7U3zoAjpOMGojjYUiLSJksOGM5sUWVW08wzkViPHrzR+M/6olQg CJC5RsI6nnEUkbR4VyFbtk5o/kuxaurpsJxpIP+6BD6wjCYVO523FPkJ9f8OsSx6q6kd qeZR6zkauGP60QtCfcjIF3SvQoDk5PPVxfg3IVJJNwvqUByLJUcJ/NKsUnbQzJsY08GL nsOw== 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 c1si2344083pla.240.2019.04.18.07.50.23; Thu, 18 Apr 2019 07:50:38 -0700 (PDT) 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 S2389556AbfDROsC (ORCPT + 99 others); Thu, 18 Apr 2019 10:48:02 -0400 Received: from shell.v3.sk ([90.176.6.54]:48047 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389459AbfDROrg (ORCPT ); Thu, 18 Apr 2019 10:47:36 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 9D7E71027A7; Thu, 18 Apr 2019 16:47:32 +0200 (CEST) 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 p-bVtJnL7vvK; Thu, 18 Apr 2019 16:47:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 9D5061027D1; Thu, 18 Apr 2019 16:47:07 +0200 (CEST) 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 JrfbnnLYy1-M; Thu, 18 Apr 2019 16:47:03 +0200 (CEST) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id CF5FC1027B2; Thu, 18 Apr 2019 16:47:00 +0200 (CEST) From: Lubomir Rintel To: Sebastian Reichel Cc: Darren Hart , 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 v7 07/10] power: supply: olpc_battery: Use devm_power_supply_register() Date: Thu, 18 Apr 2019 16:46:52 +0200 Message-Id: <20190418144655.18758-8-lkundrak@v3.sk> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418144655.18758-1-lkundrak@v3.sk> References: <20190418144655.18758-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 f7bb9bedd893..d83c77c2a0ec 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 @@ -648,15 +648,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) @@ -671,10 +669,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 @@ -684,9 +678,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.21.0