[PATCH v11 09/24] scsi: ufs: mediatek: Rework init function
From: Louis-Alexis Eyraud <hidden>
Date: 2026-09-01 15:39:58
Also in:
linux-devicetree, linux-mediatek, linux-phy, linux-scsi, lkml
Subsystem:
scsi subsystem, the rest, universal flash storage host controller driver mediatek hooks · Maintainers:
"James E.J. Bottomley", "Martin K. Petersen", Linus Torvalds, Peter Wang, Chaotian Jing
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> 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 <peter.wang@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> --- 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