aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/davinci/vpif_display.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-09-20 08:06:27 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-05 21:04:46 -0400
commite6067f8b1e3edd731cbcffb642d166d81767a30a (patch)
tree83da541c79b7c19ce028ceece6cdf13aee4fc412 /drivers/media/platform/davinci/vpif_display.c
parentb65814e546b2b6d76a299b0ee605c10d0b84bb96 (diff)
[media] vpif_display: first init subdevs, then register device nodes
When device nodes are registered they must be ready for use immediately, so make sure the subdevs are loaded first. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Lad, Prabhakar <prabhakar.lad@ti.com> Tested-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform/davinci/vpif_display.c')
-rw-r--r--drivers/media/platform/davinci/vpif_display.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 2d90328baa60..f5b5c8d5028e 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1690,6 +1690,32 @@ static __init int vpif_probe(struct platform_device *pdev)
1690 } 1690 }
1691 } 1691 }
1692 1692
1693 i2c_adap = i2c_get_adapter(1);
1694 config = pdev->dev.platform_data;
1695 subdev_count = config->subdev_count;
1696 subdevdata = config->subdevinfo;
1697 vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count,
1698 GFP_KERNEL);
1699 if (vpif_obj.sd == NULL) {
1700 vpif_err("unable to allocate memory for subdevice pointers\n");
1701 err = -ENOMEM;
1702 goto vpif_int_err;
1703 }
1704
1705 for (i = 0; i < subdev_count; i++) {
1706 vpif_obj.sd[i] = v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev,
1707 i2c_adap,
1708 &subdevdata[i].board_info,
1709 NULL);
1710 if (!vpif_obj.sd[i]) {
1711 vpif_err("Error registering v4l2 subdevice\n");
1712 goto probe_subdev_out;
1713 }
1714
1715 if (vpif_obj.sd[i])
1716 vpif_obj.sd[i]->grp_id = 1 << i;
1717 }
1718
1693 for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) { 1719 for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) {
1694 ch = vpif_obj.dev[j]; 1720 ch = vpif_obj.dev[j];
1695 /* Initialize field of the channel objects */ 1721 /* Initialize field of the channel objects */
@@ -1725,6 +1751,7 @@ static __init int vpif_probe(struct platform_device *pdev)
1725 ch->common[VPIF_VIDEO_INDEX].fmt.type = 1751 ch->common[VPIF_VIDEO_INDEX].fmt.type =
1726 V4L2_BUF_TYPE_VIDEO_OUTPUT; 1752 V4L2_BUF_TYPE_VIDEO_OUTPUT;
1727 ch->video_dev->lock = &common->lock; 1753 ch->video_dev->lock = &common->lock;
1754 video_set_drvdata(ch->video_dev, ch);
1728 1755
1729 /* register video device */ 1756 /* register video device */
1730 vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", 1757 vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n",
@@ -1734,42 +1761,12 @@ static __init int vpif_probe(struct platform_device *pdev)
1734 VFL_TYPE_GRABBER, (j ? 3 : 2)); 1761 VFL_TYPE_GRABBER, (j ? 3 : 2));
1735 if (err < 0) 1762 if (err < 0)
1736 goto probe_out; 1763 goto probe_out;
1737
1738 video_set_drvdata(ch->video_dev, ch);
1739 }
1740
1741 i2c_adap = i2c_get_adapter(1);
1742 config = pdev->dev.platform_data;
1743 subdev_count = config->subdev_count;
1744 subdevdata = config->subdevinfo;
1745 vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count,
1746 GFP_KERNEL);
1747 if (vpif_obj.sd == NULL) {
1748 vpif_err("unable to allocate memory for subdevice pointers\n");
1749 err = -ENOMEM;
1750 goto probe_out;
1751 }
1752
1753 for (i = 0; i < subdev_count; i++) {
1754 vpif_obj.sd[i] = v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev,
1755 i2c_adap,
1756 &subdevdata[i].board_info,
1757 NULL);
1758 if (!vpif_obj.sd[i]) {
1759 vpif_err("Error registering v4l2 subdevice\n");
1760 goto probe_subdev_out;
1761 }
1762
1763 if (vpif_obj.sd[i])
1764 vpif_obj.sd[i]->grp_id = 1 << i;
1765 } 1764 }
1766 1765
1767 v4l2_info(&vpif_obj.v4l2_dev, 1766 v4l2_info(&vpif_obj.v4l2_dev,
1768 " VPIF display driver initialized\n"); 1767 " VPIF display driver initialized\n");
1769 return 0; 1768 return 0;
1770 1769
1771probe_subdev_out:
1772 kfree(vpif_obj.sd);
1773probe_out: 1770probe_out:
1774 for (k = 0; k < j; k++) { 1771 for (k = 0; k < j; k++) {
1775 ch = vpif_obj.dev[k]; 1772 ch = vpif_obj.dev[k];
@@ -1777,6 +1774,8 @@ probe_out:
1777 video_device_release(ch->video_dev); 1774 video_device_release(ch->video_dev);
1778 ch->video_dev = NULL; 1775 ch->video_dev = NULL;
1779 } 1776 }
1777probe_subdev_out:
1778 kfree(vpif_obj.sd);
1780vpif_int_err: 1779vpif_int_err:
1781 v4l2_device_unregister(&vpif_obj.v4l2_dev); 1780 v4l2_device_unregister(&vpif_obj.v4l2_dev);
1782 vpif_err("VPIF IRQ request failed\n"); 1781 vpif_err("VPIF IRQ request failed\n");