Commit 8767f471 authored by Philipp Zabel's avatar Philipp Zabel

drm/imx: imx-ldb: move initialization into probe

Parts of the initialization that do not require the drm device can be
done once during probe instead of possibly multiple times during bind.
The bind function only creates the encoders.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent bed00dde
...@@ -415,6 +415,9 @@ static int imx_ldb_register(struct drm_device *drm, ...@@ -415,6 +415,9 @@ static int imx_ldb_register(struct drm_device *drm,
struct drm_encoder *encoder = &imx_ldb_ch->encoder; struct drm_encoder *encoder = &imx_ldb_ch->encoder;
int ret; int ret;
memset(connector, 0, sizeof(*connector));
memset(encoder, 0, sizeof(*encoder));
ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child); ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child);
if (ret) if (ret)
return ret; return ret;
...@@ -559,17 +562,42 @@ static int imx_ldb_panel_ddc(struct device *dev, ...@@ -559,17 +562,42 @@ static int imx_ldb_panel_ddc(struct device *dev,
static int imx_ldb_bind(struct device *dev, struct device *master, void *data) static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
{ {
struct drm_device *drm = data; struct drm_device *drm = data;
struct imx_ldb *imx_ldb = dev_get_drvdata(dev);
int ret;
int i;
for (i = 0; i < 2; i++) {
struct imx_ldb_channel *channel = &imx_ldb->channel[i];
if (!channel->ldb)
break;
ret = imx_ldb_register(drm, channel);
if (ret)
return ret;
}
return 0;
}
static const struct component_ops imx_ldb_ops = {
.bind = imx_ldb_bind,
};
static int imx_ldb_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
const struct of_device_id *of_id = const struct of_device_id *of_id = of_match_device(imx_ldb_dt_ids, dev);
of_match_device(imx_ldb_dt_ids, dev);
struct device_node *child; struct device_node *child;
struct imx_ldb *imx_ldb; struct imx_ldb *imx_ldb;
int dual; int dual;
int ret; int ret;
int i; int i;
imx_ldb = dev_get_drvdata(dev); imx_ldb = devm_kzalloc(dev, sizeof(*imx_ldb), GFP_KERNEL);
memset(imx_ldb, 0, sizeof(*imx_ldb)); if (!imx_ldb)
return -ENOMEM;
imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr"); imx_ldb->regmap = syscon_regmap_lookup_by_phandle(np, "gpr");
if (IS_ERR(imx_ldb->regmap)) { if (IS_ERR(imx_ldb->regmap)) {
...@@ -669,25 +697,20 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) ...@@ -669,25 +697,20 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
} }
channel->bus_format = bus_format; channel->bus_format = bus_format;
channel->child = child; channel->child = child;
ret = imx_ldb_register(drm, channel);
if (ret) {
channel->child = NULL;
goto free_child;
}
} }
return 0; platform_set_drvdata(pdev, imx_ldb);
return component_add(&pdev->dev, &imx_ldb_ops);
free_child: free_child:
of_node_put(child); of_node_put(child);
return ret; return ret;
} }
static void imx_ldb_unbind(struct device *dev, struct device *master, static int imx_ldb_remove(struct platform_device *pdev)
void *data)
{ {
struct imx_ldb *imx_ldb = dev_get_drvdata(dev); struct imx_ldb *imx_ldb = platform_get_drvdata(pdev);
int i; int i;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -696,28 +719,7 @@ static void imx_ldb_unbind(struct device *dev, struct device *master, ...@@ -696,28 +719,7 @@ static void imx_ldb_unbind(struct device *dev, struct device *master,
kfree(channel->edid); kfree(channel->edid);
i2c_put_adapter(channel->ddc); i2c_put_adapter(channel->ddc);
} }
}
static const struct component_ops imx_ldb_ops = {
.bind = imx_ldb_bind,
.unbind = imx_ldb_unbind,
};
static int imx_ldb_probe(struct platform_device *pdev)
{
struct imx_ldb *imx_ldb;
imx_ldb = devm_kzalloc(&pdev->dev, sizeof(*imx_ldb), GFP_KERNEL);
if (!imx_ldb)
return -ENOMEM;
platform_set_drvdata(pdev, imx_ldb);
return component_add(&pdev->dev, &imx_ldb_ops);
}
static int imx_ldb_remove(struct platform_device *pdev)
{
component_del(&pdev->dev, &imx_ldb_ops); component_del(&pdev->dev, &imx_ldb_ops);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment