Skip to contentSkip to conversation

Use devm_platform_ioremap_resource_byname()

PATCH Superseded Bean Huo 1 participant 4 messages Sep 15, 2020 – Sep 16, 2020 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bean Huo

author
#0 lore raw

cover Use devm_platform_ioremap_resource_byname()

From: Bean Huo <[email protected]>

platform_get_resource_byname() and devm_ioremap_resource() have been wrapped to the single helper devm_platform_ioremap_resource_byname(), so use it and simplify the code.

Bean Huo (2):
scsi: ufs-mediatek: use devm_platform_ioremap_resource_byname()
scsi: ufs-qcom: use devm_platform_ioremap_resource_byname()

 drivers/scsi/ufs/ufs-exynos.c   | 10 +++-------
 drivers/scsi/ufs/ufs-qcom-ice.c |  9 +--------
 drivers/scsi/ufs/ufs-qcom.c     | 23 +++++++++--------------
 3 files changed, 13 insertions(+), 29 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 scsi: ufs-mediatek: use devm_platform_ioremap_resource_byname()

From: Bean Huo <[email protected]>

Use devm_platform_ioremap_resource_byname() to simplify the code.

---
 drivers/scsi/ufs/ufs-exynos.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/scsi/ufs/ufs-exynos.c +3 -7
index 8f1b6f61a776..1eecbe550536 100644
@@ -940,7 +940,6 @@ static int exynos_ufs_init(struct ufs_hba *hba)
 	struct device *dev = hba->dev;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct exynos_ufs *ufs;
-	struct resource *res;
 	int ret;
 
 	ufs = devm_kzalloc(dev, sizeof(*ufs), GFP_KERNEL);
@@ -948,24 +947,21 @@ static int exynos_ufs_init(struct ufs_hba *hba)
 		return -ENOMEM;
 
 	/* exynos-specific hci */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vs_hci");
-	ufs->reg_hci = devm_ioremap_resource(dev, res);
+	ufs->reg_hci = devm_platform_ioremap_resource_byname(pdev, "vs_hci");
 	if (IS_ERR(ufs->reg_hci)) {
 		dev_err(dev, "cannot ioremap for hci vendor register\n");
 		return PTR_ERR(ufs->reg_hci);
 	}
 
 	/* unipro */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "unipro");
-	ufs->reg_unipro = devm_ioremap_resource(dev, res);
+	ufs->reg_unipro = devm_platform_ioremap_resource_byname(pdev, "unipro");
 	if (IS_ERR(ufs->reg_unipro)) {
 		dev_err(dev, "cannot ioremap for unipro register\n");
 		return PTR_ERR(ufs->reg_unipro);
 	}
 
 	/* ufs protector */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ufsp");
-	ufs->reg_ufsp = devm_ioremap_resource(dev, res);
+	ufs->reg_ufsp = devm_platform_ioremap_resource_byname(pdev, "ufsp");
 	if (IS_ERR(ufs->reg_ufsp)) {
 		dev_err(dev, "cannot ioremap for ufs protector register\n");
 		return PTR_ERR(ufs->reg_ufsp);
Signature · 1 line
2.17.1

A message that is not in the archive (sent off-list or not yet received): CAOBeenZX-E5ZxUtR9iDDjTxMUBKtsU529TaPz4x=u2UWWfB1pg@mail.gmail.com

author
#3 lore raw

Re: [PATCH 1/2] scsi: ufs-mediatek: use devm_platform_ioremap_resource_byname()

Quoted 3 lines · Stanley Chu

Hi Bean,

Maybe the title should be “ufs-exynos”?

Hi Stanley
Thanks, I have pushed a new version for this patch and the subject of the patch has been changed.

Thanks,
Bean

Quoted 3 lines

Thanks,
Stanley Chu

author
#4 lore raw

PATCH 2/2 scsi: ufs-qcom: use devm_platform_ioremap_resource_byname()

In reply to Bean Huo

From: Bean Huo <[email protected]>

Use devm_platform_ioremap_resource_byname() to simplify the code.

---
 drivers/scsi/ufs/ufs-qcom-ice.c |  9 +--------
 drivers/scsi/ufs/ufs-qcom.c     | 23 +++++++++--------------
 2 files changed, 10 insertions(+), 22 deletions(-)
drivers/scsi/ufs/ufs-qcom-ice.c +1 -8
index bbb0ad7590ec..cd67869a725e 100644
@@ -97,25 +97,18 @@ int ufs_qcom_ice_init(struct ufs_qcom_host *host)
 	struct ufs_hba *hba = host->hba;
 	struct device *dev = hba->dev;
 	struct platform_device *pdev = to_platform_device(dev);
-	struct resource *res;
 	int err;
 
 	if (!(ufshcd_readl(hba, REG_CONTROLLER_CAPABILITIES) &
 	      MASK_CRYPTO_SUPPORT))
 		return 0;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ice");
-	if (!res) {
-		dev_warn(dev, "ICE registers not found\n");
-		goto disable;
-	}
-
 	if (!qcom_scm_ice_available()) {
 		dev_warn(dev, "ICE SCM interface not found\n");
 		goto disable;
 	}
 
-	host->ice_mmio = devm_ioremap_resource(dev, res);
+	host->ice_mmio = devm_platform_ioremap_resource_byname(pdev, "ice");
 	if (IS_ERR(host->ice_mmio)) {
 		err = PTR_ERR(host->ice_mmio);
 		dev_err(dev, "Failed to map ICE registers; err=%d\n", err);
drivers/scsi/ufs/ufs-qcom.c +9 -14
index f9d6ef356540..c0c76da5472a 100644
@@ -976,7 +976,6 @@ static int ufs_qcom_init(struct ufs_hba *hba)
 	struct device *dev = hba->dev;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct ufs_qcom_host *host;
-	struct resource *res;
 
 	if (strlen(android_boot_dev) && strcmp(android_boot_dev, dev_name(dev)))
 		return -ENODEV;
@@ -1059,20 +1058,16 @@ static int ufs_qcom_init(struct ufs_hba *hba)
 		host->dev_ref_clk_en_mask = BIT(26);
 	} else {
 		/* "dev_ref_clk_ctrl_mem" is optional resource */
-		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						   "dev_ref_clk_ctrl_mem");
-		if (res) {
-			host->dev_ref_clk_ctrl_mmio =
-					devm_ioremap_resource(dev, res);
-			if (IS_ERR(host->dev_ref_clk_ctrl_mmio)) {
-				dev_warn(dev,
-					"%s: could not map dev_ref_clk_ctrl_mmio, err %ld\n",
-					__func__,
-					PTR_ERR(host->dev_ref_clk_ctrl_mmio));
-				host->dev_ref_clk_ctrl_mmio = NULL;
-			}
-			host->dev_ref_clk_en_mask = BIT(5);
+		host->dev_ref_clk_ctrl_mmio =
+			devm_platform_ioremap_resource_byname(pdev,
+							"dev_ref_clk_ctrl_mem");
+		if (IS_ERR(host->dev_ref_clk_ctrl_mmio)) {
+			dev_warn(dev,
+			"%s: could not map dev_ref_clk_ctrl_mmio, err %ld\n",
+			__func__, PTR_ERR(host->dev_ref_clk_ctrl_mmio));
+			host->dev_ref_clk_ctrl_mmio = NULL;
 		}
+		host->dev_ref_clk_en_mask = BIT(5);
 	}
 
 	err = ufs_qcom_init_lane_clks(host);
Signature · 1 line
2.17.1