From patchwork Wed Feb 7 14:53:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 197963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2282755dyb; Wed, 7 Feb 2024 06:55:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWWZYwmHbj5jSzOTn7tE5XhV12WqFgS7dTs+rftIQFHm7Gw5q85p4HxSKOfhxhAu1UB8OCQIbD1IVHkYscLtDKFa9NjEw== X-Google-Smtp-Source: AGHT+IHaxXPXnUqSpzhAT+oSAFu+kQGWbdomn6GiYwMa+Mc1TZlJ++n/aCCqWi0I6JCzGkMO5MQN X-Received: by 2002:a25:ad17:0:b0:dc6:d3c3:920f with SMTP id y23-20020a25ad17000000b00dc6d3c3920fmr4855607ybi.50.1707317740868; Wed, 07 Feb 2024 06:55:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707317740; cv=pass; d=google.com; s=arc-20160816; b=nIf0wp2SYop8VJQcCCk6jNvS0vflxNzVt8Wg182e/B3N0RFWpbM/Pe4czjfO5eyd4Y yhd8Le3xO1ejiQZL8xb+kl1LyfARgVX48obx5sINs/Y3ag4W9RudCoNQQy0vGvqyWYth nC6LDuTnNL+80YqiFIAOBf9m/yRVCaL3kj2M2KRg2YbvujegqM8bkc7CjlRvyZEkRZaG K3cckFojf/UaqKUm3x7QRaODw/PiKNH1gTw5neXa+uxWK7hzBZhRq1EtpEdxlYVQzX5q 8UA+UlGa4Ls+4MYKO73ur+Kd6nWPg1IprO0DRDweN/zBRtxLE5G6KbMnjlcGMzvJVACH 8otA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=evxi6usGPO+fiAY9RJ/ytCvgy5L0z9oCNmAUy6UezAE=; fh=a4k5nXESUldg1Tx7nmaMBdFL2kXbRAIJ77kvFmGjpPc=; b=oFri3W5IbIbwlNcjdZa7X2jYj1RnAbc8Ob6zXrp5fBzt3o+3NWzSYVWpLZRDc35Sj2 BLr0pXJ/5rVVR5LJiGwRpEqPir8I9qO0lrGqD++0LhB1PcxZsN0hV0fhtEShEkm27Hak neFgqulFrhVP5+ELXPXuAQLk05Pr7pCedfNWO1S9+S/XOzMMA+0VP5/n4CQGrM6L9HQ2 1fMwITasejLf8BI2Jyy+/DDyRsiJRflscRthcB1GPqYVvy1v2ucY3pcLhGEb7lFQ7ECT YyMWU6YXEYqy+iALmPgwGnNakx5HuQ21eBd3B+ztoZUaJ2lSX/PzhHDEQW2bfgmEKAu9 bJ5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Rl/l+/wI"; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-56666-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56666-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com X-Forwarded-Encrypted: i=2; AJvYcCUYlDQnXZVmLJjwuHgHsr1r6C3JfsMdczSy93wkdVCLNX0xuGz+iidclXw9u7YpX67xYxBw0Zq4dpe0X3xNSZMLasKNWA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e12-20020a05620a208c00b007856d6c049dsi1244622qka.153.2024.02.07.06.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 06:55:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56666-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Rl/l+/wI"; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-56666-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56666-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3B4911C24B6B for ; Wed, 7 Feb 2024 14:55:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D55A8121C; Wed, 7 Feb 2024 14:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Rl/l+/wI" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8861280028 for ; Wed, 7 Feb 2024 14:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707317605; cv=none; b=hcQsLPHZnXaecLm2njgmJhf/onsvF8ua1vr3faIt9NQBkDZv45YaCSuDhmX2n3HWknoupue4NdjlFSoJOyWgESXoap/m+8ClInbVNDVqgRnkrmVZIvRcwES+q7q8rD6aHi/kDbLlTxFT9EbNhp0duss5jAI1KSk4JtaCynktr8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707317605; c=relaxed/simple; bh=jewx2tbyoHc8XkBckJRK6kMqgXG1NMO8tumrU7DXJMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IuAKBhYd8543jQYV+bXkkEIZbVtozajHoqstiNt3JVc9D7vok5uf33CnIW8sXWcaitJGIlFe+0K36TtmXfFc3KdeefbUNl1MPZ4n1Q3SEN5JUGi4rAr+/5PkymQuOXY9/P0Xyjzom/YXDposbnzLmidKwUBYK9yVdLQxXyqI3pU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=Rl/l+/wI; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707317602; bh=jewx2tbyoHc8XkBckJRK6kMqgXG1NMO8tumrU7DXJMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rl/l+/wI9KF7mFOrWNFvQ17zQZL0O9OEBsMys17CWDbPl8VOKoh9GBfrUA38MUX++ 1UP5C/Z8jH61Md4XPh78NuR6JpypkuwzAemrHmvP1TtWny+dfvhVcksfY3ALMU6/rS eIvDerhdvjkvODSFEmXs04Sgcon24gMWqdQn1T0CyDAFD2lZMNC8tjgMlRI/TuYo7n GCzfMGZ/U7HS4jHn9H977TAPS29114GyKT4m2TF6jTgjDPiv1yK1cs6wfDrujTQl8Q mlsAyUrYXhPkhNsJ78lpO+zcRLLIK8l5TwuHE9+HxBunuNlhx46zUAPfKjg9KVM2up kOi1FZuIx0ABA== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 1E3273782076; Wed, 7 Feb 2024 14:53:21 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Alexandre Mergnat Subject: [PATCH v5 7/9] drm/mediatek: dsi: Simplify with dev_err_probe and remove gotos Date: Wed, 7 Feb 2024 15:53:05 +0100 Message-ID: <20240207145307.1626009-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207145307.1626009-1-angelogioacchino.delregno@collabora.com> References: <20240207145307.1626009-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790252407617837141 X-GMAIL-MSGID: 1790252407617837141 Most of the functions that are called in the probe callback are devm managed, or all but mipi_dsi_host_register(): simplify the probe function's error paths with dev_err_probe() and remove the lonely instance of `goto err_unregister_host` by just directly calling the mipi_dsi_host_unregister() function in the devm_request_irq() error path, allowing to also remove the same label. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 60 +++++++++--------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index b3dd6251d611..195ff4dfc3a3 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -1117,64 +1117,44 @@ static int mtk_dsi_probe(struct platform_device *pdev) dsi->driver_data = of_device_get_match_data(dev); dsi->engine_clk = devm_clk_get(dev, "engine"); - if (IS_ERR(dsi->engine_clk)) { - ret = PTR_ERR(dsi->engine_clk); + if (IS_ERR(dsi->engine_clk)) + return dev_err_probe(dev, PTR_ERR(dsi->engine_clk), + "Failed to get engine clock\n"); - if (ret != -EPROBE_DEFER) - dev_err(dev, "Failed to get engine clock: %d\n", ret); - return ret; - } dsi->digital_clk = devm_clk_get(dev, "digital"); - if (IS_ERR(dsi->digital_clk)) { - ret = PTR_ERR(dsi->digital_clk); - - if (ret != -EPROBE_DEFER) - dev_err(dev, "Failed to get digital clock: %d\n", ret); - return ret; - } + if (IS_ERR(dsi->digital_clk)) + return dev_err_probe(dev, PTR_ERR(dsi->digital_clk), + "Failed to get digital clock\n"); dsi->hs_clk = devm_clk_get(dev, "hs"); - if (IS_ERR(dsi->hs_clk)) { - ret = PTR_ERR(dsi->hs_clk); - dev_err(dev, "Failed to get hs clock: %d\n", ret); - return ret; - } + if (IS_ERR(dsi->hs_clk)) + return dev_err_probe(dev, PTR_ERR(dsi->hs_clk), "Failed to get hs clock\n"); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); dsi->regs = devm_ioremap_resource(dev, regs); - if (IS_ERR(dsi->regs)) { - ret = PTR_ERR(dsi->regs); - dev_err(dev, "Failed to ioremap memory: %d\n", ret); - return ret; - } + if (IS_ERR(dsi->regs)) + return dev_err_probe(dev, PTR_ERR(dsi->regs), "Failed to ioremap memory\n"); dsi->phy = devm_phy_get(dev, "dphy"); - if (IS_ERR(dsi->phy)) { - ret = PTR_ERR(dsi->phy); - dev_err(dev, "Failed to get MIPI-DPHY: %d\n", ret); - return ret; - } + if (IS_ERR(dsi->phy)) + return dev_err_probe(dev, PTR_ERR(dsi->phy), "Failed to get MIPI-DPHY\n"); irq_num = platform_get_irq(pdev, 0); - if (irq_num < 0) { - ret = irq_num; - return ret; - } + if (irq_num < 0) + return irq_num; dsi->host.ops = &mtk_dsi_ops; dsi->host.dev = dev; ret = mipi_dsi_host_register(&dsi->host); - if (ret < 0) { - dev_err(dev, "failed to register DSI host: %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to register DSI host\n"); ret = devm_request_irq(&pdev->dev, irq_num, mtk_dsi_irq, IRQF_TRIGGER_NONE, dev_name(&pdev->dev), dsi); if (ret) { - dev_err(&pdev->dev, "failed to request mediatek dsi irq\n"); - goto err_unregister_host; + mipi_dsi_host_unregister(&dsi->host); + return dev_err_probe(&pdev->dev, ret, "Failed to request DSI irq\n"); } init_waitqueue_head(&dsi->irq_wait_queue); @@ -1186,10 +1166,6 @@ static int mtk_dsi_probe(struct platform_device *pdev) dsi->bridge.type = DRM_MODE_CONNECTOR_DSI; return 0; - -err_unregister_host: - mipi_dsi_host_unregister(&dsi->host); - return ret; } static void mtk_dsi_remove(struct platform_device *pdev)