[PATCH v2 01/28] drm: omapdrm: Remove duplicate error messages when mapping memory
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon May 8 13:55:57 UTC 2017
Hi Tomi,
On Monday 08 May 2017 15:52:07 Tomi Valkeinen wrote:
> On 08/05/17 14:32, Laurent Pinchart wrote:
> > The devm_ioremap_resource() call can handle being given a NULL resource,
> > and prints an error message when mapping fails. Switch the remaining
> > devm_ioremap() calls to devm_ioremap_resource() and remove all
> > extraneous resource NULL checks and error messages printed manually by
> > the driver.
>
> Looks like in some places we check for "!ret" and in some "IS_ERR(ret)"...
Oops :-/
>From 94d2a8f445cd298d99ffc4717d2184dcf21e8889 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Date: Sun, 7 May 2017 00:29:09 +0300
Subject: [PATCH v2.1 01/28] drm: omapdrm: Remove duplicate error messages when mapping memory
The devm_ioremap_resource() call can handle being given a NULL resource,
and prints an error message when mapping fails. Switch the remaining
devm_ioremap() calls to devm_ioremap_resource() and remove all
extraneous resource NULL checks and error messages printed manually by
the driver.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
Changes since v2:
- Fix devm_ioremap_resource() return value checks
---
drivers/gpu/drm/omapdrm/dss/dispc.c | 14 +++-----------
drivers/gpu/drm/omapdrm/dss/dsi.c | 27 +++++++++------------------
drivers/gpu/drm/omapdrm/dss/dss.c | 14 +++-----------
drivers/gpu/drm/omapdrm/dss/hdmi4_core.c | 9 +--------
drivers/gpu/drm/omapdrm/dss/hdmi5_core.c | 9 +--------
drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 9 +--------
drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 9 +--------
drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 12 +++---------
drivers/gpu/drm/omapdrm/dss/rfbi.c | 14 +++-----------
drivers/gpu/drm/omapdrm/dss/venc.c | 14 +++-----------
drivers/gpu/drm/omapdrm/dss/video-pll.c | 20 ++------------------
11 files changed, 30 insertions(+), 121 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c
index d956e6266368..59fd6bac4306 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -4363,17 +4363,9 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
return r;
dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0);
- if (!dispc_mem) {
- DSSERR("can't get IORESOURCE_MEM DISPC\n");
- return -EINVAL;
- }
-
- dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start,
- resource_size(dispc_mem));
- if (!dispc.base) {
- DSSERR("can't ioremap DISPC\n");
- return -ENOMEM;
- }
+ dispc.base = devm_ioremap_resource(&pdev->dev, dispc_mem);
+ if (IS_ERR(dispc.base))
+ return PTR_ERR(discp.base);
dispc.irq = platform_get_irq(dispc.pdev, 0);
if (dispc.irq < 0) {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index f74615d005a8..5388f798356a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5326,12 +5326,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
dsi_mem = res;
- dsi->proto_base = devm_ioremap(&dsidev->dev, res->start,
- resource_size(res));
- if (!dsi->proto_base) {
- DSSERR("can't ioremap DSI protocol engine\n");
- return -ENOMEM;
- }
+ dsi->proto_base = devm_ioremap_resource(&dsidev->dev, res);
+ if (IS_ERR(dsi->proto_base))
+ return PTR_ERR(dsi->proto_base);
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy");
if (!res) {
@@ -5346,12 +5343,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
res = &temp_res;
}
- dsi->phy_base = devm_ioremap(&dsidev->dev, res->start,
- resource_size(res));
- if (!dsi->phy_base) {
- DSSERR("can't ioremap DSI PHY\n");
- return -ENOMEM;
- }
+ dsi->phy_base = devm_ioremap_resource(&dsidev->dev, res);
+ if (IS_ERR(dsi->phy_base))
+ return PTR_ERR(dsi->phy_base);
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll");
if (!res) {
@@ -5366,12 +5360,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
res = &temp_res;
}
- dsi->pll_base = devm_ioremap(&dsidev->dev, res->start,
- resource_size(res));
- if (!dsi->pll_base) {
- DSSERR("can't ioremap DSI PLL\n");
- return -ENOMEM;
- }
+ dsi->pll_base = devm_ioremap_resource(&dsidev->dev, res);
+ if (IS_ERR(dsi->pll_base))
+ return PTR_ERR(dsi->pll_base);
dsi->irq = platform_get_irq(dsi->pdev, 0);
if (dsi->irq < 0) {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 14887d5b02e5..4bfdcc47b2ee 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1201,17 +1201,9 @@ static int dss_bind(struct device *dev)
return r;
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0);
- if (!dss_mem) {
- DSSERR("can't get IORESOURCE_MEM DSS\n");
- return -EINVAL;
- }
-
- dss.base = devm_ioremap(&pdev->dev, dss_mem->start,
- resource_size(dss_mem));
- if (!dss.base) {
- DSSERR("can't ioremap DSS\n");
- return -ENOMEM;
- }
+ dss.base = devm_ioremap_resource(&pdev->dev, dss_mem);
+ if (IS_ERR(dss.base))
+ return PTR_ERR(dss.base);
r = dss_get_clocks();
if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c
index e05b7ac4f7dd..ed6001613405 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c
@@ -889,16 +889,9 @@ int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core)
struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
- if (!res) {
- DSSERR("can't get CORE mem resource\n");
- return -EINVAL;
- }
-
core->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(core->base)) {
- DSSERR("can't ioremap CORE\n");
+ if (IS_ERR(core->base))
return PTR_ERR(core->base);
- }
return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
index 8de1d7b2ae55..ab179ec133c0 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
@@ -910,16 +910,9 @@ int hdmi5_core_init(struct platform_device *pdev, struct hdmi_core_data *core)
struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
- if (!res) {
- DSSERR("can't get CORE IORESOURCE_MEM HDMI\n");
- return -EINVAL;
- }
-
core->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(core->base)) {
- DSSERR("can't ioremap HDMI core\n");
+ if (IS_ERR(core->base))
return PTR_ERR(core->base);
- }
return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
index 3ead47cccac5..fb5e4c724b4b 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c
@@ -233,16 +233,9 @@ int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy)
return r;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy");
- if (!res) {
- DSSERR("can't get PHY mem resource\n");
- return -EINVAL;
- }
-
phy->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(phy->base)) {
- DSSERR("can't ioremap TX PHY\n");
+ if (IS_ERR(phy->base))
return PTR_ERR(phy->base);
- }
return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index b8bf6a9e5557..46239358655a 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -180,16 +180,9 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
pll->wp = wp;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll");
- if (!res) {
- DSSERR("can't get PLL mem resource\n");
- return -EINVAL;
- }
-
pll->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(pll->base)) {
- DSSERR("can't ioremap PLLCTRL\n");
+ if (IS_ERR(pll->base))
return PTR_ERR(pll->base);
- }
r = dsi_init_pll_data(pdev, pll);
if (r) {
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
index b783d5a0750e..b1ab9e563915 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
@@ -285,17 +285,11 @@ int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp)
struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wp");
- if (!res) {
- DSSERR("can't get WP mem resource\n");
- return -EINVAL;
- }
- wp->phys_base = res->start;
-
wp->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(wp->base)) {
- DSSERR("can't ioremap HDMI WP\n");
+ if (IS_ERR(wp->base))
return PTR_ERR(wp->base);
- }
+
+ wp->phys_base = res->start;
return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/rfbi.c b/drivers/gpu/drm/omapdrm/dss/rfbi.c
index 09724757366a..bf6b96877daf 100644
--- a/drivers/gpu/drm/omapdrm/dss/rfbi.c
+++ b/drivers/gpu/drm/omapdrm/dss/rfbi.c
@@ -965,17 +965,9 @@ static int rfbi_bind(struct device *dev, struct device *master, void *data)
sema_init(&rfbi.bus_lock, 1);
rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0);
- if (!rfbi_mem) {
- DSSERR("can't get IORESOURCE_MEM RFBI\n");
- return -EINVAL;
- }
-
- rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start,
- resource_size(rfbi_mem));
- if (!rfbi.base) {
- DSSERR("can't ioremap RFBI\n");
- return -ENOMEM;
- }
+ rfbi.base = devm_ioremap_resource(&pdev->dev, rfbi_mem);
+ if (IS_ERR(rfbi.base))
+ return PTR_ERR(rfbi.base);
clk = clk_get(&pdev->dev, "ick");
if (IS_ERR(clk)) {
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index d74f7fcc2e46..1811d360466e 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -868,17 +868,9 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
venc.wss_data = 0;
venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0);
- if (!venc_mem) {
- DSSERR("can't get IORESOURCE_MEM VENC\n");
- return -EINVAL;
- }
-
- venc.base = devm_ioremap(&pdev->dev, venc_mem->start,
- resource_size(venc_mem));
- if (!venc.base) {
- DSSERR("can't ioremap VENC\n");
- return -ENOMEM;
- }
+ venc.base = devm_ioremap_resource(&pdev->dev, venc_mem);
+ if (IS_ERR(venc.base))
+ return PTR_ERR(venc.base);
r = venc_get_clocks(pdev);
if (r)
diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c
index 7429de928d4e..fbd1263a29a4 100644
--- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
@@ -150,33 +150,17 @@ struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
/* PLL CONTROL */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, reg_name[id]);
- if (!res) {
- dev_err(&pdev->dev,
- "missing platform resource data for pll%d\n", id);
- return ERR_PTR(-ENODEV);
- }
-
pll_base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(pll_base)) {
- dev_err(&pdev->dev, "failed to ioremap pll%d reg_name\n", id);
+ if (IS_ERR(pll_base))
return ERR_CAST(pll_base);
- }
/* CLOCK CONTROL */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
clkctrl_name[id]);
- if (!res) {
- dev_err(&pdev->dev,
- "missing platform resource data for pll%d\n", id);
- return ERR_PTR(-ENODEV);
- }
-
clkctrl_base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(clkctrl_base)) {
- dev_err(&pdev->dev, "failed to ioremap pll%d clkctrl\n", id);
+ if (IS_ERR(clkctrl_base))
return ERR_CAST(clkctrl_base);
- }
/* CLKIN */
--
Regards,
Laurent Pinchart
More information about the dri-devel
mailing list