From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61645C61DD6 for ; Tue, 1 Sep 2026 15:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D3h0+oQJOTj39p9p/DPCQemD0oK9Fblo49Sv/tIcU98=; b=aBMZa2wGxeieHF tOw0hyUa0wFt0kuUxkMiwfQuKMerrP5n+DYeNF2o8C5jitvBvu/MVZ4+jSrdaeTFEPLcI1m0vcKad ay+ezAwIPOwo5qdCFD8M9K4dPrpFYpVn9+IVc2XTrkkbrGbPb2CmyjmgvqMbpcfcJfzvbFn5Xb+xZ jUPOtJJ5ocQl4IHAH32o6gi3m9wfJtKXhW6cczedV+TnuhpwkM3YSZ9Di8ozQ8Cp7Cca9/wRlL7a/ E0ssz9g1dNtXD3pXXiYSVdFzNxiasUXaqK2dYALePy996drXD0QNCPKi7Yn/B6dkl8elLYU0SbvAq CKNXtYgbsHQyLGm8crag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1QaN-0000000CXHw-3cMg; Tue, 01 Sep 2026 15:39:43 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1QaG-0000000CWut-3nsf; Tue, 01 Sep 2026 15:39:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1788277175; bh=72GgqHc2XPiq4JBh6tlnagLn2wVqs81B5IrpPDC+VrY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=euLvG/oxdXvzf4Co4Rs1+20u3Nq8HNdVca0dSRoYYgDDGCLBimlVzpiBJ+VBr7CdR o0kmgCcagVcEFf3rTNNM57EMHAeHqBuAy2rwthm9dRUGCMObrPNvR7J7+D/vQ486H0 zjcnmv4U1UXgvq0xyFOYdicKG2+JRNB11edGUxexwmgKbcIsP2g1UULhfblxxMFGMX qKKnEyoxfi0mPsDLbBTVKoZmPWZuHwzdX7D5ub6Gx9vL2xhIGI1ayj9/TTKPiJ+sD6 DwxPrUcDfPuKqcRuEB2fdtcfmejE5u1DckFXMj6lpau1zxFJDFEG5Os8lV0Tl5SViq vsmVcHUmus9Jg== Received: from yukiji.home (unknown [100.64.0.131]) (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: laeyraud) by bali.collaboradmins.com (Postfix) with ESMTPSA id 0D24817E1298; Tue, 01 Sep 2026 17:39:34 +0200 (CEST) From: Louis-Alexis Eyraud Date: Tue, 01 Sep 2026 17:38:57 +0200 Subject: [PATCH v11 09/24] scsi: ufs: mediatek: Rework init function MIME-Version: 1.0 Message-Id: <20260901-mt8196-ufs-v11-9-dbd007704490@collabora.com> References: <20260901-mt8196-ufs-v11-0-dbd007704490@collabora.com> In-Reply-To: <20260901-mt8196-ufs-v11-0-dbd007704490@collabora.com> To: Chunfeng Yun , Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Peter Wang , Chaotian Jing , Alim Akhtar , Avri Altman , Bart Van Assche , Stanley Jhu , "James E.J. Bottomley" , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , "Martin K. Petersen" , "Martin K. Petersen" Cc: kernel@collabora.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788277163; l=3160; i=louisalexis.eyraud@collabora.com; s=20250113; h=from:subject:message-id; bh=tsDK7V4/6PMxSz+OmfJwdGpCa0GssoKhONzvWFpyjYU=; b=dwXMcimxG4/NHyBLW5OA3Io6xJ6v2oWLeWuHKVNjXl7zpFTGKBFoTetHkEGxVEf13931UNUDR DTBlPpHKmjqDqbBUzDuKY/XFxOaf8ul/k5c4JoHbNYTiaJQc1JXkt7u X-Developer-Key: i=louisalexis.eyraud@collabora.com; a=ed25519; pk=CHFBDB2Kqh4EHc6JIqFn69GhxJJAzc0Zr4e8QxtumuM= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260901_083937_210601_BCB44BD3 X-CRM114-Status: GOOD ( 17.36 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org From: Nicolas Frattaroli Printing an error message on ENOMEM is pointless. The print will not work because there is no memory. Adding an of_match_device to the init function is pointless. Why would a different device with a different probe function ever use the same init function? Get rid of it. zero-initialising an error variable just so you can then goto a bare return statement with that error variable to signal success is also pointless, just return directly, there's no unwind being done. Reviewed-by: Peter Wang Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 43 +++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index f298ea6f6ecb..c5089815696f 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -54,18 +54,6 @@ static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { {} }; -static const struct ufs_mtk_soc_data mt8183_data = { - .has_avdd09 = true, -}; - -static const struct of_device_id ufs_mtk_of_match[] = { - { .compatible = "mediatek,mt8183-ufshci", .data = &mt8183_data }, - { .compatible = "mediatek,mt8192-ufshci" }, - { .compatible = "mediatek,mt8195-ufshci" }, - {}, -}; -MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); - /* * Details of UIC Errors */ @@ -1301,29 +1289,19 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host *host) */ static int ufs_mtk_init(struct ufs_hba *hba) { - const struct of_device_id *id; struct device *dev = hba->dev; struct ufs_mtk_host *host; struct Scsi_Host *shost = hba->host; - int err = 0; + int err; struct arm_smccc_res res; host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); - if (!host) { - err = -ENOMEM; - dev_info(dev, "%s: no memory for mtk ufs host\n", __func__); - goto out; - } + if (!host) + return -ENOMEM; host->hba = hba; ufshcd_set_variant(hba, host); - id = of_match_device(ufs_mtk_of_match, dev); - if (!id) { - err = -EINVAL; - goto out; - } - /* Initialize host capability */ ufs_mtk_init_host_caps(hba); @@ -1397,11 +1375,10 @@ static int ufs_mtk_init(struct ufs_hba *hba) ufs_mtk_get_hw_ip_version(hba); - goto out; + return 0; out_variant_clear: ufshcd_set_variant(hba, NULL); -out: return err; } @@ -2443,6 +2420,18 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .config_scsi_dev = ufs_mtk_config_scsi_dev, }; +static const struct ufs_mtk_soc_data mt8183_data = { + .has_avdd09 = true, +}; + +static const struct of_device_id ufs_mtk_of_match[] = { + { .compatible = "mediatek,mt8183-ufshci", .data = &mt8183_data }, + { .compatible = "mediatek,mt8192-ufshci" }, + { .compatible = "mediatek,mt8195-ufshci" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); + /** * ufs_mtk_probe - probe routine of the driver * @pdev: pointer to Platform device handle -- 2.55.0 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy