Re: [PATCH RESEND 6/6] clk: s5p-g2d: Fix incorrect usage of IS_ERR_OR_NULL

2013-01-01 Thread Tony Prisk
On Wed, 2013-01-02 at 08:10 +0300, Dan Carpenter wrote:
> clk_get() returns NULL if CONFIG_HAVE_CLK is disabled.
> 
> I told Tony about this but everyone has been gone with end of year
> holidays so it hasn't been addressed.
> 
> Tony, please fix it so people don't apply these patches until
> clk_get() is updated to not return NULL.  It sucks to have to revert
> patches.
> 
> regards,
> dan carpenter

I posted the query to Mike Turquette, linux-kernel and linux-arm-kernel
mailing lists, regarding the return of NULL when HAVE_CLK is undefined.

Short Answer: A return value of NULL is valid and not an error therefore
we should be using IS_ERR, not IS_ERR_OR_NULL on clk_get results.

I see the obvious problem this creates, and asked this question:

If the driver can't operate with a NULL clk, it should use a
IS_ERR_OR_NULL test to test for failure, rather than IS_ERR.


And Russell's answer:

Why should a _consumer_ of a clock care?  It is _very_ important that
people get this idea - to a consumer, the struct clk is just an opaque
cookie.  The fact that it appears to be a pointer does _not_ mean that
the driver can do any kind of dereferencing on that pointer - it should
never do so.

Thread can be viewed here:
https://lkml.org/lkml/2012/12/20/105


Regards
Tony Prisk

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND 6/6] clk: s5p-g2d: Fix incorrect usage of IS_ERR_OR_NULL

2012-12-18 Thread Tony Prisk
Resend to include mailing lists.

Replace IS_ERR_OR_NULL with IS_ERR on clk_get results.

Signed-off-by: Tony Prisk 
CC: Kyungmin Park 
CC: Tomasz Stanislawski 
CC: linux-media@vger.kernel.org
---
 drivers/media/platform/s5p-g2d/g2d.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-g2d/g2d.c 
b/drivers/media/platform/s5p-g2d/g2d.c
index 1bfbc32..dcd5335 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -715,7 +715,7 @@ static int g2d_probe(struct platform_device *pdev)
}
 
dev->clk = clk_get(&pdev->dev, "sclk_fimg2d");
-   if (IS_ERR_OR_NULL(dev->clk)) {
+   if (IS_ERR(dev->clk)) {
dev_err(&pdev->dev, "failed to get g2d clock\n");
return -ENXIO;
}
@@ -727,7 +727,7 @@ static int g2d_probe(struct platform_device *pdev)
}
 
dev->gate = clk_get(&pdev->dev, "fimg2d");
-   if (IS_ERR_OR_NULL(dev->gate)) {
+   if (IS_ERR(dev->gate)) {
dev_err(&pdev->dev, "failed to get g2d clock gate\n");
ret = -ENXIO;
goto unprep_clk;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND 5/6] clk: s5p-fimc: Fix incorrect usage of IS_ERR_OR_NULL

2012-12-18 Thread Tony Prisk
Resend to include mailing lists.

Replace IS_ERR_OR_NULL with IS_ERR on clk_get results.

Signed-off-by: Tony Prisk 
CC: Kyungmin Park 
CC: Tomasz Stanislawski 
CC: linux-media@vger.kernel.org
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 0531ab7..3ac4da2 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -730,7 +730,7 @@ static int fimc_md_get_clocks(struct fimc_md *fmd)
for (i = 0; i < FIMC_MAX_CAMCLKS; i++) {
snprintf(clk_name, sizeof(clk_name), "sclk_cam%u", i);
clock = clk_get(NULL, clk_name);
-   if (IS_ERR_OR_NULL(clock)) {
+   if (IS_ERR(clock)) {
v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s",
  clk_name);
return -ENXIO;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND 4/6] clk: s5p-tv: Fix incorrect usage of IS_ERR_OR_NULL

2012-12-18 Thread Tony Prisk
Resend to include mailing lists.

Replace IS_ERR_OR_NULL with IS_ERR on clk_get results.

Signed-off-by: Tony Prisk 
CC: Kyungmin Park 
CC: Tomasz Stanislawski 
CC: linux-media@vger.kernel.org
---
 drivers/media/platform/s5p-tv/hdmi_drv.c  |   10 +-
 drivers/media/platform/s5p-tv/mixer_drv.c |   10 +-
 drivers/media/platform/s5p-tv/sdo_drv.c   |   10 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c 
b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 8a9cf43..1c48ca5 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -781,27 +781,27 @@ static int hdmi_resources_init(struct hdmi_device *hdev)
/* get clocks, power */
 
res->hdmi = clk_get(dev, "hdmi");
-   if (IS_ERR_OR_NULL(res->hdmi)) {
+   if (IS_ERR(res->hdmi)) {
dev_err(dev, "failed to get clock 'hdmi'\n");
goto fail;
}
res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
-   if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
+   if (IS_ERR(res->sclk_hdmi)) {
dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
goto fail;
}
res->sclk_pixel = clk_get(dev, "sclk_pixel");
-   if (IS_ERR_OR_NULL(res->sclk_pixel)) {
+   if (IS_ERR(res->sclk_pixel)) {
dev_err(dev, "failed to get clock 'sclk_pixel'\n");
goto fail;
}
res->sclk_hdmiphy = clk_get(dev, "sclk_hdmiphy");
-   if (IS_ERR_OR_NULL(res->sclk_hdmiphy)) {
+   if (IS_ERR(res->sclk_hdmiphy)) {
dev_err(dev, "failed to get clock 'sclk_hdmiphy'\n");
goto fail;
}
res->hdmiphy = clk_get(dev, "hdmiphy");
-   if (IS_ERR_OR_NULL(res->hdmiphy)) {
+   if (IS_ERR(res->hdmiphy)) {
dev_err(dev, "failed to get clock 'hdmiphy'\n");
goto fail;
}
diff --git a/drivers/media/platform/s5p-tv/mixer_drv.c 
b/drivers/media/platform/s5p-tv/mixer_drv.c
index ca0f297..c1b2e0e 100644
--- a/drivers/media/platform/s5p-tv/mixer_drv.c
+++ b/drivers/media/platform/s5p-tv/mixer_drv.c
@@ -240,27 +240,27 @@ static int mxr_acquire_clocks(struct mxr_device *mdev)
struct device *dev = mdev->dev;
 
res->mixer = clk_get(dev, "mixer");
-   if (IS_ERR_OR_NULL(res->mixer)) {
+   if (IS_ERR(res->mixer)) {
mxr_err(mdev, "failed to get clock 'mixer'\n");
goto fail;
}
res->vp = clk_get(dev, "vp");
-   if (IS_ERR_OR_NULL(res->vp)) {
+   if (IS_ERR(res->vp)) {
mxr_err(mdev, "failed to get clock 'vp'\n");
goto fail;
}
res->sclk_mixer = clk_get(dev, "sclk_mixer");
-   if (IS_ERR_OR_NULL(res->sclk_mixer)) {
+   if (IS_ERR(res->sclk_mixer)) {
mxr_err(mdev, "failed to get clock 'sclk_mixer'\n");
goto fail;
}
res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
-   if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
+   if (IS_ERR(res->sclk_hdmi)) {
mxr_err(mdev, "failed to get clock 'sclk_hdmi'\n");
goto fail;
}
res->sclk_dac = clk_get(dev, "sclk_dac");
-   if (IS_ERR_OR_NULL(res->sclk_dac)) {
+   if (IS_ERR(res->sclk_dac)) {
mxr_err(mdev, "failed to get clock 'sclk_dac'\n");
goto fail;
}
diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c 
b/drivers/media/platform/s5p-tv/sdo_drv.c
index ad68bbe..269d246 100644
--- a/drivers/media/platform/s5p-tv/sdo_drv.c
+++ b/drivers/media/platform/s5p-tv/sdo_drv.c
@@ -341,25 +341,25 @@ static int __devinit sdo_probe(struct platform_device 
*pdev)
 
/* acquire clocks */
sdev->sclk_dac = clk_get(dev, "sclk_dac");
-   if (IS_ERR_OR_NULL(sdev->sclk_dac)) {
+   if (IS_ERR(sdev->sclk_dac)) {
dev_err(dev, "failed to get clock 'sclk_dac'\n");
ret = -ENXIO;
goto fail;
}
sdev->dac = clk_get(dev, "dac");
-   if (IS_ERR_OR_NULL(sdev->dac)) {
+   if (IS_ERR(sdev->dac)) {
dev_err(dev, "failed to get clock 'dac'\n");
ret = -ENXIO;
goto fail_sclk_dac;
}
sdev->dacphy = clk_get(dev, "dacphy");
-   if (IS_ERR_OR_NULL(sdev->dacphy)) {
+   if (IS_ERR(sdev->dacphy)) {
dev_err(dev, "failed to get clock 'dacphy'\n"

[PATCH 6/6] clk: s5p-g2d: Fix incorrect usage of IS_ERR_OR_NULL

2012-12-18 Thread Tony Prisk
Replace IS_ERR_OR_NULL with IS_ERR on clk_get results.

Signed-off-by: Tony Prisk 
CC: Kyungmin Park 
CC: Tomasz Stanislawski 
CC: linux-media@vger.kernel.org
---
 drivers/media/platform/s5p-g2d/g2d.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-g2d/g2d.c 
b/drivers/media/platform/s5p-g2d/g2d.c
index 1bfbc32..dcd5335 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -715,7 +715,7 @@ static int g2d_probe(struct platform_device *pdev)
}
 
dev->clk = clk_get(&pdev->dev, "sclk_fimg2d");
-   if (IS_ERR_OR_NULL(dev->clk)) {
+   if (IS_ERR(dev->clk)) {
dev_err(&pdev->dev, "failed to get g2d clock\n");
return -ENXIO;
}
@@ -727,7 +727,7 @@ static int g2d_probe(struct platform_device *pdev)
}
 
dev->gate = clk_get(&pdev->dev, "fimg2d");
-   if (IS_ERR_OR_NULL(dev->gate)) {
+   if (IS_ERR(dev->gate)) {
dev_err(&pdev->dev, "failed to get g2d clock gate\n");
ret = -ENXIO;
goto unprep_clk;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] clk: s5p-tv: Fix incorrect usage of IS_ERR_OR_NULL

2012-12-18 Thread Tony Prisk
Replace IS_ERR_OR_NULL with IS_ERR on clk_get results.

Signed-off-by: Tony Prisk 
CC: Kyungmin Park 
CC: Tomasz Stanislawski 
CC: linux-media@vger.kernel.org
---
 drivers/media/platform/s5p-tv/hdmi_drv.c  |   10 +-
 drivers/media/platform/s5p-tv/mixer_drv.c |   10 +-
 drivers/media/platform/s5p-tv/sdo_drv.c   |   10 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c 
b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 8a9cf43..1c48ca5 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -781,27 +781,27 @@ static int hdmi_resources_init(struct hdmi_device *hdev)
/* get clocks, power */
 
res->hdmi = clk_get(dev, "hdmi");
-   if (IS_ERR_OR_NULL(res->hdmi)) {
+   if (IS_ERR(res->hdmi)) {
dev_err(dev, "failed to get clock 'hdmi'\n");
goto fail;
}
res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
-   if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
+   if (IS_ERR(res->sclk_hdmi)) {
dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
goto fail;
}
res->sclk_pixel = clk_get(dev, "sclk_pixel");
-   if (IS_ERR_OR_NULL(res->sclk_pixel)) {
+   if (IS_ERR(res->sclk_pixel)) {
dev_err(dev, "failed to get clock 'sclk_pixel'\n");
goto fail;
}
res->sclk_hdmiphy = clk_get(dev, "sclk_hdmiphy");
-   if (IS_ERR_OR_NULL(res->sclk_hdmiphy)) {
+   if (IS_ERR(res->sclk_hdmiphy)) {
dev_err(dev, "failed to get clock 'sclk_hdmiphy'\n");
goto fail;
}
res->hdmiphy = clk_get(dev, "hdmiphy");
-   if (IS_ERR_OR_NULL(res->hdmiphy)) {
+   if (IS_ERR(res->hdmiphy)) {
dev_err(dev, "failed to get clock 'hdmiphy'\n");
goto fail;
}
diff --git a/drivers/media/platform/s5p-tv/mixer_drv.c 
b/drivers/media/platform/s5p-tv/mixer_drv.c
index ca0f297..c1b2e0e 100644
--- a/drivers/media/platform/s5p-tv/mixer_drv.c
+++ b/drivers/media/platform/s5p-tv/mixer_drv.c
@@ -240,27 +240,27 @@ static int mxr_acquire_clocks(struct mxr_device *mdev)
struct device *dev = mdev->dev;
 
res->mixer = clk_get(dev, "mixer");
-   if (IS_ERR_OR_NULL(res->mixer)) {
+   if (IS_ERR(res->mixer)) {
mxr_err(mdev, "failed to get clock 'mixer'\n");
goto fail;
}
res->vp = clk_get(dev, "vp");
-   if (IS_ERR_OR_NULL(res->vp)) {
+   if (IS_ERR(res->vp)) {
mxr_err(mdev, "failed to get clock 'vp'\n");
goto fail;
}
res->sclk_mixer = clk_get(dev, "sclk_mixer");
-   if (IS_ERR_OR_NULL(res->sclk_mixer)) {
+   if (IS_ERR(res->sclk_mixer)) {
mxr_err(mdev, "failed to get clock 'sclk_mixer'\n");
goto fail;
}
res->sclk_hdmi = clk_get(dev, "sclk_hdmi");
-   if (IS_ERR_OR_NULL(res->sclk_hdmi)) {
+   if (IS_ERR(res->sclk_hdmi)) {
mxr_err(mdev, "failed to get clock 'sclk_hdmi'\n");
goto fail;
}
res->sclk_dac = clk_get(dev, "sclk_dac");
-   if (IS_ERR_OR_NULL(res->sclk_dac)) {
+   if (IS_ERR(res->sclk_dac)) {
mxr_err(mdev, "failed to get clock 'sclk_dac'\n");
goto fail;
}
diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c 
b/drivers/media/platform/s5p-tv/sdo_drv.c
index ad68bbe..269d246 100644
--- a/drivers/media/platform/s5p-tv/sdo_drv.c
+++ b/drivers/media/platform/s5p-tv/sdo_drv.c
@@ -341,25 +341,25 @@ static int __devinit sdo_probe(struct platform_device 
*pdev)
 
/* acquire clocks */
sdev->sclk_dac = clk_get(dev, "sclk_dac");
-   if (IS_ERR_OR_NULL(sdev->sclk_dac)) {
+   if (IS_ERR(sdev->sclk_dac)) {
dev_err(dev, "failed to get clock 'sclk_dac'\n");
ret = -ENXIO;
goto fail;
}
sdev->dac = clk_get(dev, "dac");
-   if (IS_ERR_OR_NULL(sdev->dac)) {
+   if (IS_ERR(sdev->dac)) {
dev_err(dev, "failed to get clock 'dac'\n");
ret = -ENXIO;
goto fail_sclk_dac;
}
sdev->dacphy = clk_get(dev, "dacphy");
-   if (IS_ERR_OR_NULL(sdev->dacphy)) {
+   if (IS_ERR(sdev->dacphy)) {
dev_err(dev, "failed to get clock 'dacphy'\n");
ret = 

[PATCH 5/6] clk: s5p-fimc: Fix incorrect usage of IS_ERR_OR_NULL

2012-12-18 Thread Tony Prisk
Replace IS_ERR_OR_NULL with IS_ERR on clk_get results.

Signed-off-by: Tony Prisk 
CC: Kyungmin Park 
CC: Tomasz Stanislawski 
CC: linux-media@vger.kernel.org
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 0531ab7..3ac4da2 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -730,7 +730,7 @@ static int fimc_md_get_clocks(struct fimc_md *fmd)
for (i = 0; i < FIMC_MAX_CAMCLKS; i++) {
snprintf(clk_name, sizeof(clk_name), "sclk_cam%u", i);
clock = clk_get(NULL, clk_name);
-   if (IS_ERR_OR_NULL(clock)) {
+   if (IS_ERR(clock)) {
v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s",
  clk_name);
return -ENXIO;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html