aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Lewandowski <k.lewandowsk@samsung.com>2012-04-12 20:45:28 +0200
committerTushar Behera <tushar.behera@linaro.org>2013-05-14 11:01:08 +0530
commitcaec1fb36a753573d5455e642030708e81d7506d (patch)
treea3db79ecd8234caf9498731ab2a2abfd4787d202
parent56bb8d0feb3657fe3d5148c99aafabfaa6aa0ee7 (diff)
s5p-tv: Move HDMIPHY and MHL subdev probing to dedicated function
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com> Cc: Tomasz Stanislawski <t.stanislaws@samsung.com>
-rw-r--r--drivers/media/platform/s5p-tv/hdmi_drv.c90
1 files changed, 49 insertions, 41 deletions
diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 8de1b3dce45..953a2ea57a0 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -830,11 +830,47 @@ fail:
return -ENODEV;
}
+static struct v4l2_subdev *hdmi_get_subdev(
+ struct hdmi_device *hdmi_dev,
+ struct i2c_board_info *bdinfo,
+ int bus,
+ const char *propname)
+{
+ struct v4l2_subdev *sd = NULL;
+ struct i2c_adapter *adapter;
+ struct device *dev = hdmi_dev->dev;
+
+ if (!bdinfo) {
+ dev_err(dev, "%s info is missing in platform data\n",
+ propname);
+ return ERR_PTR(-ENXIO);
+ }
+
+ adapter = i2c_get_adapter(bus);
+ if (adapter == NULL) {
+ dev_err(dev, "%s adapter request failed, name\n",
+ propname);
+ return ERR_PTR(-ENXIO);
+ }
+
+ sd = v4l2_i2c_new_subdev_board(&hdmi_dev->v4l2_dev,
+ adapter, bdinfo, NULL);
+
+ /* on failure or not adapter is no longer useful */
+ i2c_put_adapter(adapter);
+
+ if (sd == NULL) {
+ dev_err(dev, "missing subdev for %s\n", propname);
+ return ERR_PTR(-ENODEV);
+ }
+
+ return sd;
+}
+
static int hdmi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct resource *res;
- struct i2c_adapter *adapter;
struct v4l2_subdev *sd;
struct hdmi_device *hdmi_dev = NULL;
struct s5p_hdmi_platform_data *pdata = dev->platform_data;
@@ -902,51 +938,23 @@ static int hdmi_probe(struct platform_device *pdev)
goto fail_init;
}
- /* testing if hdmiphy info is present */
- if (!pdata->hdmiphy_info) {
- dev_err(dev, "hdmiphy info is missing in platform data\n");
- ret = -ENXIO;
+ hdmi_dev->phy_sd = hdmi_get_subdev(hdmi_dev,
+ pdata ? pdata->hdmiphy_info : NULL,
+ pdata ? pdata->hdmiphy_bus : -1,
+ "phy");
+ if (IS_ERR_OR_NULL(hdmi_dev->phy_sd)) {
+ ret = PTR_ERR(hdmi_dev->phy_sd);
goto fail_vdev;
}
-
- adapter = i2c_get_adapter(pdata->hdmiphy_bus);
- if (adapter == NULL) {
- dev_err(dev, "hdmiphy adapter request failed\n");
- ret = -ENXIO;
+ hdmi_dev->mhl_sd = hdmi_get_subdev(hdmi_dev,
+ pdata ? pdata->mhl_info : NULL ,
+ pdata ? pdata->mhl_bus : -1,
+ "mhl");
+ if (IS_ERR_OR_NULL(hdmi_dev->mhl_sd)) {
+ ret = PTR_ERR(hdmi_dev->mhl_sd);
goto fail_vdev;
}
- hdmi_dev->phy_sd = v4l2_i2c_new_subdev_board(&hdmi_dev->v4l2_dev,
- adapter, pdata->hdmiphy_info, NULL);
- /* on failure or not adapter is no longer useful */
- i2c_put_adapter(adapter);
- if (hdmi_dev->phy_sd == NULL) {
- dev_err(dev, "missing subdev for hdmiphy\n");
- ret = -ENODEV;
- goto fail_vdev;
- }
-
- /* initialization of MHL interface if present */
- if (pdata->mhl_info) {
- adapter = i2c_get_adapter(pdata->mhl_bus);
- if (adapter == NULL) {
- dev_err(dev, "MHL adapter request failed\n");
- ret = -ENXIO;
- goto fail_vdev;
- }
-
- hdmi_dev->mhl_sd = v4l2_i2c_new_subdev_board(
- &hdmi_dev->v4l2_dev, adapter,
- pdata->mhl_info, NULL);
- /* on failure or not adapter is no longer useful */
- i2c_put_adapter(adapter);
- if (hdmi_dev->mhl_sd == NULL) {
- dev_err(dev, "missing subdev for MHL\n");
- ret = -ENODEV;
- goto fail_vdev;
- }
- }
-
clk_enable(hdmi_dev->res.hdmi);
pm_runtime_enable(dev);