From patchwork Tue Jan 28 10:46:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13952437 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8841459B71 for ; Tue, 28 Jan 2025 10:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738061268; cv=none; b=uCodtyYyBCjk1b4+ujuUWVI7Ji76yUHa6nnTjG96IB8p2JLcC96JiIHNrDs+5TorauVpzJjmD0BhV+zLamwS9rr0aX+2mxepPzzHrEFzKsAsAamibDLEfMwq3s4iuMWboOGCwU+MVwtDT7qVrKXMImVrmEtYcQe/tpiRxfxciCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738061268; c=relaxed/simple; bh=Vv2rcp4g5aE2NBJqZTXtrcuQ0LioDYIGFuym2CDFHt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BHzbeWjwmEfGGKwwmlV56RSYKHZ8GV3ZOUH6jMsHaHBnF/ZWMbP5fIi0UeQREuzFGIcRNjQPnvetuoAw+y6AL6sVTnKTs4A4UUThSVDrm4oy2OW1R5ybKTQqjw2/0heiCHK+Ui4CAmJ+SYyRok7XvONM0Msrz2h8Oe6zQg2QuOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: Cj6zOPgETuSSBBiAzSk2SQ== X-CSE-MsgGUID: Acos600mQgOmYAagcVWZXw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 28 Jan 2025 19:47:43 +0900 Received: from localhost.localdomain (unknown [10.226.93.131]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id ECBFE41FB5AB; Tue, 28 Jan 2025 19:47:31 +0900 (JST) From: Biju Das To: Thomas Gleixner , Philipp Zabel Cc: Biju Das , Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v3 04/13] irqchip/renesas-rzv2h: Simplify rzv2h_icu_init() Date: Tue, 28 Jan 2025 10:46:54 +0000 Message-ID: <20250128104714.80807-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250128104714.80807-1-biju.das.jz@bp.renesas.com> References: <20250128104714.80807-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use devm_add_action_or_reset() for calling put_device in error path of rzv2h_icu_init() to simplify the code by using recently added devm_* helpers. Signed-off-by: Biju Das Reviewed-by: Philipp Zabel Reviewed-by: Geert Uytterhoeven --- v3: * New patch --- drivers/irqchip/irq-renesas-rzv2h.c | 37 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/irqchip/irq-renesas-rzv2h.c b/drivers/irqchip/irq-renesas-rzv2h.c index fd432b43506b..fd678947df83 100644 --- a/drivers/irqchip/irq-renesas-rzv2h.c +++ b/drivers/irqchip/irq-renesas-rzv2h.c @@ -419,6 +419,11 @@ static int rzv2h_icu_parse_interrupts(struct rzv2h_icu_priv *priv, struct device return 0; } +static void rzv2h_icu_put_device(void *data) +{ + put_device(data); +} + static int rzv2h_icu_init(struct device_node *node, struct device_node *parent) { struct irq_domain *irq_domain, *parent_domain; @@ -431,41 +436,39 @@ static int rzv2h_icu_init(struct device_node *node, struct device_node *parent) if (!pdev) return -ENODEV; + ret = devm_add_action_or_reset(&pdev->dev, rzv2h_icu_put_device, + &pdev->dev); + if (ret < 0) + return ret; + parent_domain = irq_find_host(parent); if (!parent_domain) { dev_err(&pdev->dev, "cannot find parent domain\n"); - ret = -ENODEV; - goto put_dev; + return -ENODEV; } rzv2h_icu_data = devm_kzalloc(&pdev->dev, sizeof(*rzv2h_icu_data), GFP_KERNEL); - if (!rzv2h_icu_data) { - ret = -ENOMEM; - goto put_dev; - } + if (!rzv2h_icu_data) + return -ENOMEM; rzv2h_icu_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL); - if (IS_ERR(rzv2h_icu_data->base)) { - ret = PTR_ERR(rzv2h_icu_data->base); - goto put_dev; - } + if (IS_ERR(rzv2h_icu_data->base)) + return PTR_ERR(rzv2h_icu_data->base); ret = rzv2h_icu_parse_interrupts(rzv2h_icu_data, node); if (ret) { dev_err(&pdev->dev, "cannot parse interrupts: %d\n", ret); - goto put_dev; + return ret; } resetn = devm_reset_control_get_exclusive(&pdev->dev, NULL); - if (IS_ERR(resetn)) { - ret = PTR_ERR(resetn); - goto put_dev; - } + if (IS_ERR(resetn)) + return PTR_ERR(resetn); ret = reset_control_deassert(resetn); if (ret) { dev_err(&pdev->dev, "failed to deassert resetn pin, %d\n", ret); - goto put_dev; + return ret; } pm_runtime_enable(&pdev->dev); @@ -496,8 +499,6 @@ static int rzv2h_icu_init(struct device_node *node, struct device_node *parent) pm_disable: pm_runtime_disable(&pdev->dev); reset_control_assert(resetn); -put_dev: - put_device(&pdev->dev); return ret; }