From nobody Wed Dec 3 03:12:36 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8673D2EDD45 for ; Fri, 21 Nov 2025 16:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763743616; cv=none; b=lqiFeJKGOXANpxLpXvavo6NysBPbByob5Bu4Yh9hwtaeQVYwPWRJGlBbF1bg/foL7tBP4RzQaTnxCXF0thcV2aDjy5RBAhz/OEBaPQzQQHiVUQ138l6AMrRb7nDYyH9k0xXbAvlxT4uOFAyrhfE7GlUSyjkzNMDMdEF0Q2O/1qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763743616; c=relaxed/simple; bh=a40IkiU6xvqjxBkq9vQ37vCmt5+0t9lSnkk0qDk52Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=guiZSeP5uZ0df6bOjjL161hxILLWJTyM0GXzXk1yeGODEjosrBrn7ue+QmCg6o7OM4aKds6t3PDlamcsGmFhy09oQcureBU+dKUmoB3ZprL1i/Ff1Gd++DAQLpGoreG5uo9z04GWw0wRCTjgvccpnJRftfqxdtlGkP33weX4u0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O6VnLmeW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O6VnLmeW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BD10C19422; Fri, 21 Nov 2025 16:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763743616; bh=a40IkiU6xvqjxBkq9vQ37vCmt5+0t9lSnkk0qDk52Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6VnLmeWZp24GSdjtF3oHTE3KCuOHk4p1ho6LiP5NydWyXcRI1obhWJ7W1YHb6jCa besem1XY1hJTPv3dUTEXrrCNqoS2B5ldARzovTOYKHZ0z8qMQa8kT+6Y3aXOseOwKp 0O51BVkYKwINyOdyTg5Y5xx3Rs82tfP4Q6cnfneORgE3KY/3XPDAvIPzbKqSnD/rk2 fNjzzYhRXVmgpi6kBVgMSXJBIyjjAoRqIG+F0Wpg7SWMup4RMVAA1/453ix0HNTGwf H0W5bIGFpV4th3yOHo4jM0evljHiK4dJh7wahpIKZ1NKMkEzoduI6aAVWXqP+xCmjo VnAkV7/zuFqgA== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1vMUHh-000000003ZU-2YXq; Fri, 21 Nov 2025 17:46:57 +0100 From: Johan Hovold To: Yong Wu , Krzysztof Kozlowski Cc: Matthias Brugger , AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 3/3] memory: mtk-smi: clean up device link creation Date: Fri, 21 Nov 2025 17:46:24 +0100 Message-ID: <20251121164624.13685-4-johan@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251121164624.13685-1-johan@kernel.org> References: <20251121164624.13685-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Clean up device link creation by bailing out early in case the SMI platform device lookup fails. Signed-off-by: Johan Hovold --- drivers/memory/mtk-smi.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 3609bfd3c64b..aaeba8ab211e 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -595,25 +595,28 @@ static int mtk_smi_device_link_common(struct device *= dev, struct device **com_de =20 smi_com_pdev =3D of_find_device_by_node(smi_com_node); of_node_put(smi_com_node); - if (smi_com_pdev) { - /* smi common is the supplier, Make sure it is ready before */ - if (!platform_get_drvdata(smi_com_pdev)) { - put_device(&smi_com_pdev->dev); - return -EPROBE_DEFER; - } - smi_com_dev =3D &smi_com_pdev->dev; - link =3D device_link_add(dev, smi_com_dev, - DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS); - if (!link) { - dev_err(dev, "Unable to link smi-common dev\n"); - put_device(&smi_com_pdev->dev); - return -ENODEV; - } - *com_dev =3D smi_com_dev; - } else { + if (!smi_com_pdev) { dev_err(dev, "Failed to get the smi_common device\n"); return -EINVAL; } + + /* smi common is the supplier, Make sure it is ready before */ + if (!platform_get_drvdata(smi_com_pdev)) { + put_device(&smi_com_pdev->dev); + return -EPROBE_DEFER; + } + + smi_com_dev =3D &smi_com_pdev->dev; + link =3D device_link_add(dev, smi_com_dev, + DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS); + if (!link) { + dev_err(dev, "Unable to link smi-common dev\n"); + put_device(&smi_com_pdev->dev); + return -ENODEV; + } + + *com_dev =3D smi_com_dev; + return 0; } =20 --=20 2.51.2