From: "Lad, Prabhakar" <[email protected]>
This patch series replaces existing resource handling in the
driver with managed device resource.
Lad, Prabhakar (5):
media: davinci: vpbe_venc: convert to devm_* api
media: davinci: vpbe_osd: convert to devm_* api
media: davinci: vpbe_display: convert to devm* api
media: davinci: vpss: convert to devm* api
media: davinci: vpbe: Replace printk with dev_*
drivers/media/platform/davinci/vpbe.c | 6 +-
drivers/media/platform/davinci/vpbe_display.c | 23 ++----
drivers/media/platform/davinci/vpbe_osd.c | 45 +++---------
drivers/media/platform/davinci/vpbe_venc.c | 97 +++++--------------------
drivers/media/platform/davinci/vpss.c | 62 ++++------------
5 files changed, 52 insertions(+), 181 deletions(-)
--
1.7.9.5
From: "Lad, Prabhakar" <[email protected]>
Replace existing resource handling in the driver with managed
device resource, this ensures more consistent error values and
simplifies error paths.
Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/media/platform/davinci/vpbe_venc.c | 97 ++++++----------------------
1 file changed, 19 insertions(+), 78 deletions(-)
diff --git a/drivers/media/platform/davinci/vpbe_venc.c b/drivers/media/platform/davinci/vpbe_venc.c
index 87eef9b..14a023a 100644
--- a/drivers/media/platform/davinci/vpbe_venc.c
+++ b/drivers/media/platform/davinci/vpbe_venc.c
@@ -639,105 +639,46 @@ static int venc_probe(struct platform_device *pdev)
const struct platform_device_id *pdev_id;
struct venc_state *venc;
struct resource *res;
- int ret;
- venc = kzalloc(sizeof(struct venc_state), GFP_KERNEL);
+ if (!pdev->dev.platform_data) {
+ dev_err(&pdev->dev, "No platform data for VENC sub device");
+ return -EINVAL;
+ }
+
+ pdev_id = platform_get_device_id(pdev);
+ if (!pdev_id)
+ return -EINVAL;
+
+ venc = devm_kzalloc(&pdev->dev, sizeof(struct venc_state), GFP_KERNEL);
if (venc == NULL)
return -ENOMEM;
- pdev_id = platform_get_device_id(pdev);
- if (!pdev_id) {
- ret = -EINVAL;
- goto free_mem;
- }
venc->venc_type = pdev_id->driver_data;
venc->pdev = &pdev->dev;
venc->pdata = pdev->dev.platform_data;
- if (NULL == venc->pdata) {
- dev_err(venc->pdev, "Unable to get platform data for"
- " VENC sub device");
- ret = -ENOENT;
- goto free_mem;
- }
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(venc->pdev,
- "Unable to get VENC register address map\n");
- ret = -ENODEV;
- goto free_mem;
- }
- if (!request_mem_region(res->start, resource_size(res), "venc")) {
- dev_err(venc->pdev, "Unable to reserve VENC MMIO region\n");
- ret = -ENODEV;
- goto free_mem;
- }
-
- venc->venc_base = ioremap_nocache(res->start, resource_size(res));
- if (!venc->venc_base) {
- dev_err(venc->pdev, "Unable to map VENC IO space\n");
- ret = -ENODEV;
- goto release_venc_mem_region;
- }
+ venc->venc_base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(venc->venc_base))
+ return PTR_ERR(venc->venc_base);
if (venc->venc_type != VPBE_VERSION_1) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res) {
- dev_err(venc->pdev,
- "Unable to get VDAC_CONFIG address map\n");
- ret = -ENODEV;
- goto unmap_venc_io;
- }
-
- if (!request_mem_region(res->start,
- resource_size(res), "venc")) {
- dev_err(venc->pdev,
- "Unable to reserve VDAC_CONFIG MMIO region\n");
- ret = -ENODEV;
- goto unmap_venc_io;
- }
-
- venc->vdaccfg_reg = ioremap_nocache(res->start,
- resource_size(res));
- if (!venc->vdaccfg_reg) {
- dev_err(venc->pdev,
- "Unable to map VDAC_CONFIG IO space\n");
- ret = -ENODEV;
- goto release_vdaccfg_mem_region;
- }
+
+ venc->vdaccfg_reg = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(venc->vdaccfg_reg))
+ return PTR_ERR(venc->vdaccfg_reg);
}
spin_lock_init(&venc->lock);
platform_set_drvdata(pdev, venc);
dev_notice(venc->pdev, "VENC sub device probe success\n");
- return 0;
-release_vdaccfg_mem_region:
- release_mem_region(res->start, resource_size(res));
-unmap_venc_io:
- iounmap(venc->venc_base);
-release_venc_mem_region:
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
-free_mem:
- kfree(venc);
- return ret;
+ return 0;
}
static int venc_remove(struct platform_device *pdev)
{
- struct venc_state *venc = platform_get_drvdata(pdev);
- struct resource *res;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- iounmap((void *)venc->venc_base);
- release_mem_region(res->start, resource_size(res));
- if (venc->venc_type != VPBE_VERSION_1) {
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- iounmap((void *)venc->vdaccfg_reg);
- release_mem_region(res->start, resource_size(res));
- }
- kfree(venc);
-
return 0;
}
--
1.7.9.5
From: "Lad, Prabhakar" <[email protected]>
Replace existing resource handling in the driver with managed
device resource, this ensures more consistent error values and
simplifies error paths.
Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/media/platform/davinci/vpbe_osd.c | 45 +++++++----------------------
1 file changed, 10 insertions(+), 35 deletions(-)
diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c
index 6ed82e8..d053c26 100644
--- a/drivers/media/platform/davinci/vpbe_osd.c
+++ b/drivers/media/platform/davinci/vpbe_osd.c
@@ -1547,61 +1547,36 @@ static int osd_probe(struct platform_device *pdev)
const struct platform_device_id *pdev_id;
struct osd_state *osd;
struct resource *res;
- int ret = 0;
- osd = kzalloc(sizeof(struct osd_state), GFP_KERNEL);
+ pdev_id = platform_get_device_id(pdev);
+ if (!pdev_id)
+ return -EINVAL;
+
+ osd = devm_kzalloc(&pdev->dev, sizeof(struct osd_state), GFP_KERNEL);
if (osd == NULL)
return -ENOMEM;
- pdev_id = platform_get_device_id(pdev);
- if (!pdev_id) {
- ret = -EINVAL;
- goto free_mem;
- }
osd->dev = &pdev->dev;
osd->vpbe_type = pdev_id->driver_data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(osd->dev, "Unable to get OSD register address map\n");
- ret = -ENODEV;
- goto free_mem;
- }
+ osd->osd_base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(osd->osd_base))
+ return PTR_ERR(osd->osd_base);
+
osd->osd_base_phys = res->start;
osd->osd_size = resource_size(res);
- if (!request_mem_region(osd->osd_base_phys, osd->osd_size,
- MODULE_NAME)) {
- dev_err(osd->dev, "Unable to reserve OSD MMIO region\n");
- ret = -ENODEV;
- goto free_mem;
- }
- osd->osd_base = ioremap_nocache(res->start, osd->osd_size);
- if (!osd->osd_base) {
- dev_err(osd->dev, "Unable to map the OSD region\n");
- ret = -ENODEV;
- goto release_mem_region;
- }
spin_lock_init(&osd->lock);
osd->ops = osd_ops;
platform_set_drvdata(pdev, osd);
dev_notice(osd->dev, "OSD sub device probe success\n");
- return ret;
-release_mem_region:
- release_mem_region(osd->osd_base_phys, osd->osd_size);
-free_mem:
- kfree(osd);
- return ret;
+ return 0;
}
static int osd_remove(struct platform_device *pdev)
{
- struct osd_state *osd = platform_get_drvdata(pdev);
-
- iounmap((void *)osd->osd_base);
- release_mem_region(osd->osd_base_phys, osd->osd_size);
- kfree(osd);
return 0;
}
--
1.7.9.5
From: "Lad, Prabhakar" <[email protected]>
Replace existing resource handling in the driver with managed
device resource, this ensures more consistent error values and
simplifies error paths.
Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/media/platform/davinci/vpbe_display.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index e180ff7..04609cc6 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1743,11 +1743,10 @@ static int vpbe_display_probe(struct platform_device *pdev)
printk(KERN_DEBUG "vpbe_display_probe\n");
/* Allocate memory for vpbe_display */
- disp_dev = kzalloc(sizeof(struct vpbe_display), GFP_KERNEL);
- if (!disp_dev) {
- printk(KERN_ERR "ran out of memory\n");
+ disp_dev = devm_kzalloc(&pdev->dev, sizeof(struct vpbe_display),
+ GFP_KERNEL);
+ if (!disp_dev)
return -ENOMEM;
- }
spin_lock_init(&disp_dev->dma_queue_lock);
/*
@@ -1786,26 +1785,24 @@ static int vpbe_display_probe(struct platform_device *pdev)
}
irq = res->start;
- if (request_irq(irq, venc_isr, IRQF_DISABLED, VPBE_DISPLAY_DRIVER,
- disp_dev)) {
+ err = devm_request_irq(&pdev->dev, irq, venc_isr, IRQF_DISABLED,
+ VPBE_DISPLAY_DRIVER, disp_dev);
+ if (err) {
v4l2_err(&disp_dev->vpbe_dev->v4l2_dev,
"Unable to request interrupt\n");
- err = -ENODEV;
goto probe_out;
}
for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
if (register_device(disp_dev->dev[i], disp_dev, pdev)) {
err = -ENODEV;
- goto probe_out_irq;
+ goto probe_out;
}
}
printk(KERN_DEBUG "Successfully completed the probing of vpbe v4l2 device\n");
return 0;
-probe_out_irq:
- free_irq(res->start, disp_dev);
probe_out:
for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) {
/* Get the pointer to the layer object */
@@ -1817,7 +1814,6 @@ probe_out:
kfree(disp_dev->dev[k]);
}
}
- kfree(disp_dev);
return err;
}
@@ -1830,15 +1826,10 @@ static int vpbe_display_remove(struct platform_device *pdev)
struct vpbe_layer *vpbe_display_layer;
struct vpbe_display *disp_dev = platform_get_drvdata(pdev);
struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
- struct resource *res;
int i;
v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_remove\n");
- /* unregister irq */
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- free_irq(res->start, disp_dev);
-
/* deinitialize the vpbe display controller */
if (NULL != vpbe_dev->ops.deinitialize)
vpbe_dev->ops.deinitialize(&pdev->dev, vpbe_dev);
--
1.7.9.5
From: "Lad, Prabhakar" <[email protected]>
Replace existing resource handling in the driver with managed
device resource, this ensures more consistent error values and
simplifies error paths.
Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/media/platform/davinci/vpss.c | 62 +++++++--------------------------
1 file changed, 13 insertions(+), 49 deletions(-)
diff --git a/drivers/media/platform/davinci/vpss.c b/drivers/media/platform/davinci/vpss.c
index 8a2f01e..31120b4 100644
--- a/drivers/media/platform/davinci/vpss.c
+++ b/drivers/media/platform/davinci/vpss.c
@@ -21,6 +21,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
+#include <linux/err.h>
#include <media/davinci/vpss.h>
@@ -404,9 +405,8 @@ EXPORT_SYMBOL(dm365_vpss_set_pg_frame_size);
static int vpss_probe(struct platform_device *pdev)
{
- struct resource *r1, *r2;
+ struct resource *res;
char *platform_name;
- int status;
if (!pdev->dev.platform_data) {
dev_err(&pdev->dev, "no platform data\n");
@@ -427,38 +427,19 @@ static int vpss_probe(struct platform_device *pdev)
}
dev_info(&pdev->dev, "%s vpss probed\n", platform_name);
- r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!r1)
- return -ENOENT;
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- r1 = request_mem_region(r1->start, resource_size(r1), r1->name);
- if (!r1)
- return -EBUSY;
-
- oper_cfg.vpss_regs_base0 = ioremap(r1->start, resource_size(r1));
- if (!oper_cfg.vpss_regs_base0) {
- status = -EBUSY;
- goto fail1;
- }
+ oper_cfg.vpss_regs_base0 = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(oper_cfg.vpss_regs_base0))
+ return PTR_ERR(oper_cfg.vpss_regs_base0);
if (oper_cfg.platform == DM355 || oper_cfg.platform == DM365) {
- r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!r2) {
- status = -ENOENT;
- goto fail2;
- }
- r2 = request_mem_region(r2->start, resource_size(r2), r2->name);
- if (!r2) {
- status = -EBUSY;
- goto fail2;
- }
-
- oper_cfg.vpss_regs_base1 = ioremap(r2->start,
- resource_size(r2));
- if (!oper_cfg.vpss_regs_base1) {
- status = -EBUSY;
- goto fail3;
- }
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+
+ oper_cfg.vpss_regs_base1 = devm_ioremap_resource(&pdev->dev,
+ res);
+ if (IS_ERR(oper_cfg.vpss_regs_base1))
+ return PTR_ERR(oper_cfg.vpss_regs_base1);
}
if (oper_cfg.platform == DM355) {
@@ -493,30 +474,13 @@ static int vpss_probe(struct platform_device *pdev)
spin_lock_init(&oper_cfg.vpss_lock);
dev_info(&pdev->dev, "%s vpss probe success\n", platform_name);
- return 0;
-fail3:
- release_mem_region(r2->start, resource_size(r2));
-fail2:
- iounmap(oper_cfg.vpss_regs_base0);
-fail1:
- release_mem_region(r1->start, resource_size(r1));
- return status;
+ return 0;
}
static int vpss_remove(struct platform_device *pdev)
{
- struct resource *res;
-
pm_runtime_disable(&pdev->dev);
- iounmap(oper_cfg.vpss_regs_base0);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, resource_size(res));
- if (oper_cfg.platform == DM355 || oper_cfg.platform == DM365) {
- iounmap(oper_cfg.vpss_regs_base1);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- release_mem_region(res->start, resource_size(res));
- }
return 0;
}
--
1.7.9.5
From: "Lad, Prabhakar" <[email protected]>
Use the dev_* message logging API instead of raw printk.
Signed-off-by: Lad, Prabhakar <[email protected]>
---
drivers/media/platform/davinci/vpbe.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 33b9660..3f32184 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -595,7 +595,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
* matching with device name
*/
if (NULL == vpbe_dev || NULL == dev) {
- printk(KERN_ERR "Null device pointers.\n");
+ dev_err(dev, "Null device pointers.\n");
return -ENODEV;
}
@@ -735,7 +735,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
mutex_unlock(&vpbe_dev->lock);
- printk(KERN_NOTICE "Setting default output to %s\n", def_output);
+ dev_info(dev, "Setting default output to %s\n", def_output);
ret = vpbe_set_default_output(vpbe_dev);
if (ret) {
v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s",
@@ -743,7 +743,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
return ret;
}
- printk(KERN_NOTICE "Setting default mode to %s\n", def_mode);
+ dev_info(dev, "Setting default mode to %s\n", def_mode);
ret = vpbe_set_default_mode(vpbe_dev);
if (ret) {
v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s",
--
1.7.9.5
On Sat, 2013-07-13 at 14:20 +0530, Prabhakar Lad wrote:
> Use the dev_* message logging API instead of raw printk.
[]
> diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
[]
> @@ -735,7 +735,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
>
> mutex_unlock(&vpbe_dev->lock);
>
> - printk(KERN_NOTICE "Setting default output to %s\n", def_output);
> + dev_info(dev, "Setting default output to %s\n", def_output);
You are changing logging levels too.
You should mention that in the changelog.
> @@ -743,7 +743,7 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
> return ret;
> }
>
> - printk(KERN_NOTICE "Setting default mode to %s\n", def_mode);
> + dev_info(dev, "Setting default mode to %s\n", def_mode);
> ret = vpbe_set_default_mode(vpbe_dev);
> if (ret) {
> v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s",
Maybe these should be v4l2_notice() which could
be added to include/media/v4l2-common.h
Hi Prabhakar,
On Saturday 13 July 2013 14:20:26 Prabhakar Lad wrote:
> From: "Lad, Prabhakar" <[email protected]>
>
> This patch series replaces existing resource handling in the
> driver with managed device resource.
Thank you for the patches. They greatly simplify the probe/remove functions, I
like that. For patches 1 to 4,
Acked-by: Laurent Pinchart <[email protected]>
I have the same concern as Joe Perches for patch 5.
> Lad, Prabhakar (5):
> media: davinci: vpbe_venc: convert to devm_* api
> media: davinci: vpbe_osd: convert to devm_* api
> media: davinci: vpbe_display: convert to devm* api
> media: davinci: vpss: convert to devm* api
> media: davinci: vpbe: Replace printk with dev_*
>
> drivers/media/platform/davinci/vpbe.c | 6 +-
> drivers/media/platform/davinci/vpbe_display.c | 23 ++----
> drivers/media/platform/davinci/vpbe_osd.c | 45 +++---------
> drivers/media/platform/davinci/vpbe_venc.c | 97 ++++-----------------
> drivers/media/platform/davinci/vpss.c | 62 ++++------------
> 5 files changed, 52 insertions(+), 181 deletions(-)
--
Regards,
Laurent Pinchart
Hi Laurent,
On Wed, Jul 17, 2013 at 5:51 PM, Laurent Pinchart
<[email protected]> wrote:
> Hi Prabhakar,
>
> On Saturday 13 July 2013 14:20:26 Prabhakar Lad wrote:
>> From: "Lad, Prabhakar" <[email protected]>
>>
>> This patch series replaces existing resource handling in the
>> driver with managed device resource.
>
> Thank you for the patches. They greatly simplify the probe/remove functions, I
> like that. For patches 1 to 4,
>
> Acked-by: Laurent Pinchart <[email protected]>
>
Thanks for the ACK.
> I have the same concern as Joe Perches for patch 5.
>
Ok I'll fix it and repost the alone patch 5/5.
--
Regards,
Prabhakar Lad
Hi Hans,
On Sat, Jul 13, 2013 at 2:20 PM, Prabhakar Lad
<[email protected]> wrote:
> From: "Lad, Prabhakar" <[email protected]>
>
> This patch series replaces existing resource handling in the
> driver with managed device resource.
>
> Lad, Prabhakar (5):
> media: davinci: vpbe_venc: convert to devm_* api
> media: davinci: vpbe_osd: convert to devm_* api
> media: davinci: vpbe_display: convert to devm* api
> media: davinci: vpss: convert to devm* api
can you pick up patches 1-4 for 3.12 ? I'll handle the 5/5 patch later.
Regards,
--Prabhakar Lad
All,
I do not know why I keep receiving these e-mails from multiple people. Could you please remove me from your e-mail lists?
Thanks!
-Tobin Abraham
-----Original Message-----
From: davinci-linux-open-source-bounces+t-abraham=ti.com@linux.davincidsp.com [mailto:davinci-linux-open-source-bounces+t-abraham=ti.com@linux.davincidsp.com] On Behalf Of Prabhakar Lad
Sent: Tuesday, July 23, 2013 6:18 AM
To: Hans Verkuil
Cc: DLOS; LKML; LMML
Subject: Re: [PATCH 0/5] Davinci VPBE use devres and some cleanup
Hi Hans,
On Sat, Jul 13, 2013 at 2:20 PM, Prabhakar Lad <[email protected]> wrote:
> From: "Lad, Prabhakar" <[email protected]>
>
> This patch series replaces existing resource handling in the driver
> with managed device resource.
>
> Lad, Prabhakar (5):
> media: davinci: vpbe_venc: convert to devm_* api
> media: davinci: vpbe_osd: convert to devm_* api
> media: davinci: vpbe_display: convert to devm* api
> media: davinci: vpss: convert to devm* api
can you pick up patches 1-4 for 3.12 ? I'll handle the 5/5 patch later.
Regards,
--Prabhakar Lad
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Abraham,
On Tue, Jul 23, 2013 at 5:14 PM, Abraham, Tobin <[email protected]> wrote:
> All,
>
> I do not know why I keep receiving these e-mails from multiple people. Could you please remove me from your e-mail lists?
>
Please follow this link [1] to un subscribe yourself from the mailing list.
[1] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
Regards,
--Prabhakar Lad
On Tue 23 July 2013 13:17:43 Prabhakar Lad wrote:
> Hi Hans,
>
> On Sat, Jul 13, 2013 at 2:20 PM, Prabhakar Lad
> <[email protected]> wrote:
> > From: "Lad, Prabhakar" <[email protected]>
> >
> > This patch series replaces existing resource handling in the
> > driver with managed device resource.
> >
> > Lad, Prabhakar (5):
> > media: davinci: vpbe_venc: convert to devm_* api
> > media: davinci: vpbe_osd: convert to devm_* api
> > media: davinci: vpbe_display: convert to devm* api
> > media: davinci: vpss: convert to devm* api
>
> can you pick up patches 1-4 for 3.12 ? I'll handle the 5/5 patch later.
Will do. I'm planning on a new pull request during/around the weekend.
Regards,
Hans