Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Lad, Prabhakar and committed by
Mauro Carvalho Chehab
b3ab190f 7f099a75

+14 -5
+14 -5
drivers/media/i2c/ov2659.c
··· 1340 1340 ov2659_get_pdata(struct i2c_client *client) 1341 1341 { 1342 1342 struct ov2659_platform_data *pdata; 1343 + struct v4l2_of_endpoint *bus_cfg; 1343 1344 struct device_node *endpoint; 1344 - int ret; 1345 1345 1346 1346 if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) 1347 1347 return client->dev.platform_data; ··· 1350 1350 if (!endpoint) 1351 1351 return NULL; 1352 1352 1353 + bus_cfg = v4l2_of_alloc_parse_endpoint(endpoint); 1354 + if (IS_ERR(bus_cfg)) { 1355 + pdata = NULL; 1356 + goto done; 1357 + } 1358 + 1353 1359 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 1354 1360 if (!pdata) 1355 1361 goto done; 1356 1362 1357 - ret = of_property_read_u64(endpoint, "link-frequencies", 1358 - &pdata->link_frequency); 1359 - if (ret) { 1360 - dev_err(&client->dev, "link-frequencies property not found\n"); 1363 + if (!bus_cfg->nr_of_link_frequencies) { 1364 + dev_err(&client->dev, 1365 + "link-frequencies property not found or too many\n"); 1361 1366 pdata = NULL; 1367 + goto done; 1362 1368 } 1363 1369 1370 + pdata->link_frequency = bus_cfg->link_frequencies[0]; 1371 + 1364 1372 done: 1373 + v4l2_of_free_endpoint(bus_cfg); 1365 1374 of_node_put(endpoint); 1366 1375 return pdata; 1367 1376 }