Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp998537ybp; Fri, 4 Oct 2019 08:08:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuyOkBAxDAcZQ+QVzWpGRxGjqrL7IOIPumPh+iVQPjdA7jhr/hmCgCokLX6BKXfkZ59R4L X-Received: by 2002:a17:906:a2c9:: with SMTP id by9mr12776620ejb.29.1570201704537; Fri, 04 Oct 2019 08:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570201704; cv=none; d=google.com; s=arc-20160816; b=H0nEIMsK2SN2UJCBKktR4ipynBJfV7Fo8LYlITIKYtKFxrqxfOWiHJkyMGo91r6vsB 1Zh6Fb4Yc0APLI3mDHlEdOplhWHl+Ktg3VrPKkyjz4uhldXbaIKdg4t2NaD3lmPcLjgb ftR+3/BNYcOTWFf4v5dtgyoN1CmxvakxMgz5r0cEXcN2W9brN+uEGikW/N+i0/822MN8 xW+M6GSbN0djjGwvoc3I5erev0sqD5Ydhb6qf1YRbLi0TH9GP5gVwRaBWcyT80mOOvzO GwjBU2zgamsDgXkPb8sbiN5mR95Oscul6CKVLkn6ko21BGv/hC2svM4IQ499x74CBdIo Wz3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from :dkim-signature; bh=mWFjad82dl5cqjjVKo8EJldfyMblDvB6IS2iAsg3+mk=; b=v8zFEEUkO2VXieKzEEC5f403A9rkqX1eW7JtcloA3YAmFJU8fjYpae6TwpnCYtNrUD +tP1alZ0Gh05vvPXf68uegsCRLfwJtYi/CM/3LWiSIoWD2PEVWHr5EziUkLMIq77NMwy DMLNXB6jiK1OalFE1LNd4uCW6YFoD00tjAD8+519Tkjq0/vofUmJW7Uix5FeHkntofpY d8OPeNW5q5PhuvmlvYdElX2dSh/6Js5J1CcbJJIWh4t2GeVMo1S+VWHysDYLhTz2QFV6 xAUPYnIkrHRKnnnUZ1LNRdWeYS51PTzdjkN8ZmyiUd7ZBaMMboyX+JHDcIHUBq79XhQt C6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OGWg8Ntv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w55si3852398eda.15.2019.10.04.08.08.00; Fri, 04 Oct 2019 08:08:24 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OGWg8Ntv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389596AbfJDPHr (ORCPT + 99 others); Fri, 4 Oct 2019 11:07:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:50348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388802AbfJDPHq (ORCPT ); Fri, 4 Oct 2019 11:07:46 -0400 Received: from localhost.localdomain (unknown [194.230.155.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1AB92207FF; Fri, 4 Oct 2019 15:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570201666; bh=/KV5I5DAghrskNH9QDWgNaeNLl+MrlIiwz5apfW4Vrg=; h=From:To:Subject:Date:From; b=OGWg8NtvNyerybT+VfuS22mipc6Oq+DcD1Z8b/NRsfgNtU+fi5fFNWhlzLyLr4abK zcEUcMR0ODI6gine4L3mMTJiPnQlvO9Tb7aumA5IrUBoDCICHdx7W3waD0UV0sTKr6 I44zsBDOCS3Ya+4oGQmhNliofFEwAkYvvR2GW4sY= From: Krzysztof Kozlowski To: Sebastian Reichel , Krzysztof Kozlowski , "Gustavo A. R. Silva" , Linus Walleij , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFT 1/3] power: supply: ab8500: Cleanup probe in reverse order Date: Fri, 4 Oct 2019 17:07:36 +0200 Message-Id: <20191004150738.6542-1-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is logical to cleanup in probe's error path in reverse order to previous actions. It also makes easier to add additional goto labels within this error path. Signed-off-by: Krzysztof Kozlowski --- Not marking as cc-stable as this was not reproduced and not tested. --- drivers/power/supply/ab8500_btemp.c | 4 ++-- drivers/power/supply/ab8500_fg.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index 8fe81259bfd9..a167938e32f2 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -1104,13 +1104,13 @@ static int ab8500_btemp_probe(struct platform_device *pdev) return ret; free_irq: - power_supply_unregister(di->btemp_psy); - /* We also have to free all successfully registered irqs */ for (i = i - 1; i >= 0; i--) { irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name); free_irq(irq, di); } + + power_supply_unregister(di->btemp_psy); free_btemp_wq: destroy_workqueue(di->btemp_wq); return ret; diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 6fc4bc30644c..36bbb8ea05da 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3212,15 +3212,15 @@ static int ab8500_fg_probe(struct platform_device *pdev) return ret; free_irq: - power_supply_unregister(di->fg_psy); - /* We also have to free all registered irqs */ + irq = platform_get_irq_byname(pdev, ab8500_fg_irq_bh[0].name); + free_irq(irq, di); for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq_th); i++) { irq = platform_get_irq_byname(pdev, ab8500_fg_irq_th[i].name); free_irq(irq, di); } - irq = platform_get_irq_byname(pdev, ab8500_fg_irq_bh[0].name); - free_irq(irq, di); + + power_supply_unregister(di->fg_psy); free_inst_curr_wq: destroy_workqueue(di->fg_wq); return ret; -- 2.17.1