Commit b3ab190f authored by Lad, Prabhakar's avatar Lad, Prabhakar Committed by Mauro Carvalho Chehab

[media] media: i2c: ov2659: Use v4l2_of_alloc_parse_endpoint()

Instead of parsing the link-frequencies property in the driver, let
v4l2_of_alloc_parse_endpoint() do it.
Signed-off-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 7f099a75
...@@ -1340,8 +1340,8 @@ static struct ov2659_platform_data * ...@@ -1340,8 +1340,8 @@ static struct ov2659_platform_data *
ov2659_get_pdata(struct i2c_client *client) ov2659_get_pdata(struct i2c_client *client)
{ {
struct ov2659_platform_data *pdata; struct ov2659_platform_data *pdata;
struct v4l2_of_endpoint *bus_cfg;
struct device_node *endpoint; struct device_node *endpoint;
int ret;
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data; return client->dev.platform_data;
...@@ -1350,18 +1350,27 @@ ov2659_get_pdata(struct i2c_client *client) ...@@ -1350,18 +1350,27 @@ ov2659_get_pdata(struct i2c_client *client)
if (!endpoint) if (!endpoint)
return NULL; return NULL;
bus_cfg = v4l2_of_alloc_parse_endpoint(endpoint);
if (IS_ERR(bus_cfg)) {
pdata = NULL;
goto done;
}
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) if (!pdata)
goto done; goto done;
ret = of_property_read_u64(endpoint, "link-frequencies", if (!bus_cfg->nr_of_link_frequencies) {
&pdata->link_frequency); dev_err(&client->dev,
if (ret) { "link-frequencies property not found or too many\n");
dev_err(&client->dev, "link-frequencies property not found\n");
pdata = NULL; pdata = NULL;
goto done;
} }
pdata->link_frequency = bus_cfg->link_frequencies[0];
done: done:
v4l2_of_free_endpoint(bus_cfg);
of_node_put(endpoint); of_node_put(endpoint);
return pdata; return pdata;
} }
......
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