diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2018-06-02 12:19:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-10-04 16:08:09 -0400 |
commit | 6970d37cc97d77189d775fd16d47b2ac87d0e757 (patch) | |
tree | f8731768cc5c16db6fe1625a74272d893cb8758a | |
parent | 2d95e7ed07ed29715a801a3d33b2ad2a6fb26ee3 (diff) |
media: v4l: fwnode: Let the caller provide V4L2 fwnode endpoint
Instead of allocating the V4L2 fwnode endpoint in
v4l2_fwnode_endpoint_alloc_parse, let the caller to do this. This allows
setting default parameters for the endpoint which is a very common need
for drivers.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r-- | drivers/media/i2c/ov2659.c | 14 | ||||
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp-core.c | 26 | ||||
-rw-r--r-- | drivers/media/i2c/tc358743.c | 26 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-fwnode.c | 49 | ||||
-rw-r--r-- | include/media/v4l2-fwnode.h | 10 |
5 files changed, 60 insertions, 65 deletions
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index 4715edc8ca33..799acce803fe 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c | |||
@@ -1347,8 +1347,9 @@ static struct ov2659_platform_data * | |||
1347 | ov2659_get_pdata(struct i2c_client *client) | 1347 | ov2659_get_pdata(struct i2c_client *client) |
1348 | { | 1348 | { |
1349 | struct ov2659_platform_data *pdata; | 1349 | struct ov2659_platform_data *pdata; |
1350 | struct v4l2_fwnode_endpoint *bus_cfg; | 1350 | struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 }; |
1351 | struct device_node *endpoint; | 1351 | struct device_node *endpoint; |
1352 | int ret; | ||
1352 | 1353 | ||
1353 | if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) | 1354 | if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) |
1354 | return client->dev.platform_data; | 1355 | return client->dev.platform_data; |
@@ -1357,8 +1358,9 @@ ov2659_get_pdata(struct i2c_client *client) | |||
1357 | if (!endpoint) | 1358 | if (!endpoint) |
1358 | return NULL; | 1359 | return NULL; |
1359 | 1360 | ||
1360 | bus_cfg = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(endpoint)); | 1361 | ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(endpoint), |
1361 | if (IS_ERR(bus_cfg)) { | 1362 | &bus_cfg); |
1363 | if (ret) { | ||
1362 | pdata = NULL; | 1364 | pdata = NULL; |
1363 | goto done; | 1365 | goto done; |
1364 | } | 1366 | } |
@@ -1367,17 +1369,17 @@ ov2659_get_pdata(struct i2c_client *client) | |||
1367 | if (!pdata) | 1369 | if (!pdata) |
1368 | goto done; | 1370 | goto done; |
1369 | 1371 | ||
1370 | if (!bus_cfg->nr_of_link_frequencies) { | 1372 | if (!bus_cfg.nr_of_link_frequencies) { |
1371 | dev_err(&client->dev, | 1373 | dev_err(&client->dev, |
1372 | "link-frequencies property not found or too many\n"); | 1374 | "link-frequencies property not found or too many\n"); |
1373 | pdata = NULL; | 1375 | pdata = NULL; |
1374 | goto done; | 1376 | goto done; |
1375 | } | 1377 | } |
1376 | 1378 | ||
1377 | pdata->link_frequency = bus_cfg->link_frequencies[0]; | 1379 | pdata->link_frequency = bus_cfg.link_frequencies[0]; |
1378 | 1380 | ||
1379 | done: | 1381 | done: |
1380 | v4l2_fwnode_endpoint_free(bus_cfg); | 1382 | v4l2_fwnode_endpoint_free(&bus_cfg); |
1381 | of_node_put(endpoint); | 1383 | of_node_put(endpoint); |
1382 | return pdata; | 1384 | return pdata; |
1383 | } | 1385 | } |
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 69495c6dc228..2d6059e3a577 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c | |||
@@ -2757,7 +2757,7 @@ static int __maybe_unused smiapp_resume(struct device *dev) | |||
2757 | static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) | 2757 | static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) |
2758 | { | 2758 | { |
2759 | struct smiapp_hwconfig *hwcfg; | 2759 | struct smiapp_hwconfig *hwcfg; |
2760 | struct v4l2_fwnode_endpoint *bus_cfg; | 2760 | struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 }; |
2761 | struct fwnode_handle *ep; | 2761 | struct fwnode_handle *ep; |
2762 | struct fwnode_handle *fwnode = dev_fwnode(dev); | 2762 | struct fwnode_handle *fwnode = dev_fwnode(dev); |
2763 | u32 rotation; | 2763 | u32 rotation; |
@@ -2771,27 +2771,27 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) | |||
2771 | if (!ep) | 2771 | if (!ep) |
2772 | return NULL; | 2772 | return NULL; |
2773 | 2773 | ||
2774 | bus_cfg = v4l2_fwnode_endpoint_alloc_parse(ep); | 2774 | rval = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); |
2775 | if (IS_ERR(bus_cfg)) | 2775 | if (rval) |
2776 | goto out_err; | 2776 | goto out_err; |
2777 | 2777 | ||
2778 | hwcfg = devm_kzalloc(dev, sizeof(*hwcfg), GFP_KERNEL); | 2778 | hwcfg = devm_kzalloc(dev, sizeof(*hwcfg), GFP_KERNEL); |
2779 | if (!hwcfg) | 2779 | if (!hwcfg) |
2780 | goto out_err; | 2780 | goto out_err; |
2781 | 2781 | ||
2782 | switch (bus_cfg->bus_type) { | 2782 | switch (bus_cfg.bus_type) { |
2783 | case V4L2_MBUS_CSI2_DPHY: | 2783 | case V4L2_MBUS_CSI2_DPHY: |
2784 | hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2; | 2784 | hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2; |
2785 | hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes; | 2785 | hwcfg->lanes = bus_cfg.bus.mipi_csi2.num_data_lanes; |
2786 | break; | 2786 | break; |
2787 | case V4L2_MBUS_CCP2: | 2787 | case V4L2_MBUS_CCP2: |
2788 | hwcfg->csi_signalling_mode = (bus_cfg->bus.mipi_csi1.strobe) ? | 2788 | hwcfg->csi_signalling_mode = (bus_cfg.bus.mipi_csi1.strobe) ? |
2789 | SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE : | 2789 | SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE : |
2790 | SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK; | 2790 | SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK; |
2791 | hwcfg->lanes = 1; | 2791 | hwcfg->lanes = 1; |
2792 | break; | 2792 | break; |
2793 | default: | 2793 | default: |
2794 | dev_err(dev, "unsupported bus %u\n", bus_cfg->bus_type); | 2794 | dev_err(dev, "unsupported bus %u\n", bus_cfg.bus_type); |
2795 | goto out_err; | 2795 | goto out_err; |
2796 | } | 2796 | } |
2797 | 2797 | ||
@@ -2823,28 +2823,28 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) | |||
2823 | dev_dbg(dev, "nvm %d, clk %d, mode %d\n", | 2823 | dev_dbg(dev, "nvm %d, clk %d, mode %d\n", |
2824 | hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode); | 2824 | hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode); |
2825 | 2825 | ||
2826 | if (!bus_cfg->nr_of_link_frequencies) { | 2826 | if (!bus_cfg.nr_of_link_frequencies) { |
2827 | dev_warn(dev, "no link frequencies defined\n"); | 2827 | dev_warn(dev, "no link frequencies defined\n"); |
2828 | goto out_err; | 2828 | goto out_err; |
2829 | } | 2829 | } |
2830 | 2830 | ||
2831 | hwcfg->op_sys_clock = devm_kcalloc( | 2831 | hwcfg->op_sys_clock = devm_kcalloc( |
2832 | dev, bus_cfg->nr_of_link_frequencies + 1 /* guardian */, | 2832 | dev, bus_cfg.nr_of_link_frequencies + 1 /* guardian */, |
2833 | sizeof(*hwcfg->op_sys_clock), GFP_KERNEL); | 2833 | sizeof(*hwcfg->op_sys_clock), GFP_KERNEL); |
2834 | if (!hwcfg->op_sys_clock) | 2834 | if (!hwcfg->op_sys_clock) |
2835 | goto out_err; | 2835 | goto out_err; |
2836 | 2836 | ||
2837 | for (i = 0; i < bus_cfg->nr_of_link_frequencies; i++) { | 2837 | for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) { |
2838 | hwcfg->op_sys_clock[i] = bus_cfg->link_frequencies[i]; | 2838 | hwcfg->op_sys_clock[i] = bus_cfg.link_frequencies[i]; |
2839 | dev_dbg(dev, "freq %d: %lld\n", i, hwcfg->op_sys_clock[i]); | 2839 | dev_dbg(dev, "freq %d: %lld\n", i, hwcfg->op_sys_clock[i]); |
2840 | } | 2840 | } |
2841 | 2841 | ||
2842 | v4l2_fwnode_endpoint_free(bus_cfg); | 2842 | v4l2_fwnode_endpoint_free(&bus_cfg); |
2843 | fwnode_handle_put(ep); | 2843 | fwnode_handle_put(ep); |
2844 | return hwcfg; | 2844 | return hwcfg; |
2845 | 2845 | ||
2846 | out_err: | 2846 | out_err: |
2847 | v4l2_fwnode_endpoint_free(bus_cfg); | 2847 | v4l2_fwnode_endpoint_free(&bus_cfg); |
2848 | fwnode_handle_put(ep); | 2848 | fwnode_handle_put(ep); |
2849 | return NULL; | 2849 | return NULL; |
2850 | } | 2850 | } |
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 0834f254f1c2..ca5d92942820 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c | |||
@@ -1895,11 +1895,11 @@ static void tc358743_gpio_reset(struct tc358743_state *state) | |||
1895 | static int tc358743_probe_of(struct tc358743_state *state) | 1895 | static int tc358743_probe_of(struct tc358743_state *state) |
1896 | { | 1896 | { |
1897 | struct device *dev = &state->i2c_client->dev; | 1897 | struct device *dev = &state->i2c_client->dev; |
1898 | struct v4l2_fwnode_endpoint *endpoint; | 1898 | struct v4l2_fwnode_endpoint endpoint = { .bus_type = 0 }; |
1899 | struct device_node *ep; | 1899 | struct device_node *ep; |
1900 | struct clk *refclk; | 1900 | struct clk *refclk; |
1901 | u32 bps_pr_lane; | 1901 | u32 bps_pr_lane; |
1902 | int ret = -EINVAL; | 1902 | int ret; |
1903 | 1903 | ||
1904 | refclk = devm_clk_get(dev, "refclk"); | 1904 | refclk = devm_clk_get(dev, "refclk"); |
1905 | if (IS_ERR(refclk)) { | 1905 | if (IS_ERR(refclk)) { |
@@ -1915,26 +1915,28 @@ static int tc358743_probe_of(struct tc358743_state *state) | |||
1915 | return -EINVAL; | 1915 | return -EINVAL; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | endpoint = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep)); | 1918 | ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep), &endpoint); |
1919 | if (IS_ERR(endpoint)) { | 1919 | if (ret) { |
1920 | dev_err(dev, "failed to parse endpoint\n"); | 1920 | dev_err(dev, "failed to parse endpoint\n"); |
1921 | ret = PTR_ERR(endpoint); | 1921 | ret = ret; |
1922 | goto put_node; | 1922 | goto put_node; |
1923 | } | 1923 | } |
1924 | 1924 | ||
1925 | if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY || | 1925 | if (endpoint.bus_type != V4L2_MBUS_CSI2_DPHY || |
1926 | endpoint->bus.mipi_csi2.num_data_lanes == 0 || | 1926 | endpoint.bus.mipi_csi2.num_data_lanes == 0 || |
1927 | endpoint->nr_of_link_frequencies == 0) { | 1927 | endpoint.nr_of_link_frequencies == 0) { |
1928 | dev_err(dev, "missing CSI-2 properties in endpoint\n"); | 1928 | dev_err(dev, "missing CSI-2 properties in endpoint\n"); |
1929 | ret = -EINVAL; | ||
1929 | goto free_endpoint; | 1930 | goto free_endpoint; |
1930 | } | 1931 | } |
1931 | 1932 | ||
1932 | if (endpoint->bus.mipi_csi2.num_data_lanes > 4) { | 1933 | if (endpoint.bus.mipi_csi2.num_data_lanes > 4) { |
1933 | dev_err(dev, "invalid number of lanes\n"); | 1934 | dev_err(dev, "invalid number of lanes\n"); |
1935 | ret = -EINVAL; | ||
1934 | goto free_endpoint; | 1936 | goto free_endpoint; |
1935 | } | 1937 | } |
1936 | 1938 | ||
1937 | state->bus = endpoint->bus.mipi_csi2; | 1939 | state->bus = endpoint.bus.mipi_csi2; |
1938 | 1940 | ||
1939 | ret = clk_prepare_enable(refclk); | 1941 | ret = clk_prepare_enable(refclk); |
1940 | if (ret) { | 1942 | if (ret) { |
@@ -1967,7 +1969,7 @@ static int tc358743_probe_of(struct tc358743_state *state) | |||
1967 | * The CSI bps per lane must be between 62.5 Mbps and 1 Gbps. | 1969 | * The CSI bps per lane must be between 62.5 Mbps and 1 Gbps. |
1968 | * The default is 594 Mbps for 4-lane 1080p60 or 2-lane 720p60. | 1970 | * The default is 594 Mbps for 4-lane 1080p60 or 2-lane 720p60. |
1969 | */ | 1971 | */ |
1970 | bps_pr_lane = 2 * endpoint->link_frequencies[0]; | 1972 | bps_pr_lane = 2 * endpoint.link_frequencies[0]; |
1971 | if (bps_pr_lane < 62500000U || bps_pr_lane > 1000000000U) { | 1973 | if (bps_pr_lane < 62500000U || bps_pr_lane > 1000000000U) { |
1972 | dev_err(dev, "unsupported bps per lane: %u bps\n", bps_pr_lane); | 1974 | dev_err(dev, "unsupported bps per lane: %u bps\n", bps_pr_lane); |
1973 | goto disable_clk; | 1975 | goto disable_clk; |
@@ -2013,7 +2015,7 @@ static int tc358743_probe_of(struct tc358743_state *state) | |||
2013 | disable_clk: | 2015 | disable_clk: |
2014 | clk_disable_unprepare(refclk); | 2016 | clk_disable_unprepare(refclk); |
2015 | free_endpoint: | 2017 | free_endpoint: |
2016 | v4l2_fwnode_endpoint_free(endpoint); | 2018 | v4l2_fwnode_endpoint_free(&endpoint); |
2017 | put_node: | 2019 | put_node: |
2018 | of_node_put(ep); | 2020 | of_node_put(ep); |
2019 | return ret; | 2021 | return ret; |
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 54162217bb36..d6ba3e5d4356 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c | |||
@@ -290,23 +290,17 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep) | |||
290 | return; | 290 | return; |
291 | 291 | ||
292 | kfree(vep->link_frequencies); | 292 | kfree(vep->link_frequencies); |
293 | kfree(vep); | ||
294 | } | 293 | } |
295 | EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_free); | 294 | EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_free); |
296 | 295 | ||
297 | struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse( | 296 | int v4l2_fwnode_endpoint_alloc_parse( |
298 | struct fwnode_handle *fwnode) | 297 | struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep) |
299 | { | 298 | { |
300 | struct v4l2_fwnode_endpoint *vep; | ||
301 | int rval; | 299 | int rval; |
302 | 300 | ||
303 | vep = kzalloc(sizeof(*vep), GFP_KERNEL); | ||
304 | if (!vep) | ||
305 | return ERR_PTR(-ENOMEM); | ||
306 | |||
307 | rval = __v4l2_fwnode_endpoint_parse(fwnode, vep); | 301 | rval = __v4l2_fwnode_endpoint_parse(fwnode, vep); |
308 | if (rval < 0) | 302 | if (rval < 0) |
309 | goto out_err; | 303 | return rval; |
310 | 304 | ||
311 | rval = fwnode_property_read_u64_array(fwnode, "link-frequencies", | 305 | rval = fwnode_property_read_u64_array(fwnode, "link-frequencies", |
312 | NULL, 0); | 306 | NULL, 0); |
@@ -316,18 +310,18 @@ struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse( | |||
316 | vep->link_frequencies = | 310 | vep->link_frequencies = |
317 | kmalloc_array(rval, sizeof(*vep->link_frequencies), | 311 | kmalloc_array(rval, sizeof(*vep->link_frequencies), |
318 | GFP_KERNEL); | 312 | GFP_KERNEL); |
319 | if (!vep->link_frequencies) { | 313 | if (!vep->link_frequencies) |
320 | rval = -ENOMEM; | 314 | return -ENOMEM; |
321 | goto out_err; | ||
322 | } | ||
323 | 315 | ||
324 | vep->nr_of_link_frequencies = rval; | 316 | vep->nr_of_link_frequencies = rval; |
325 | 317 | ||
326 | rval = fwnode_property_read_u64_array( | 318 | rval = fwnode_property_read_u64_array( |
327 | fwnode, "link-frequencies", vep->link_frequencies, | 319 | fwnode, "link-frequencies", vep->link_frequencies, |
328 | vep->nr_of_link_frequencies); | 320 | vep->nr_of_link_frequencies); |
329 | if (rval < 0) | 321 | if (rval < 0) { |
330 | goto out_err; | 322 | v4l2_fwnode_endpoint_free(vep); |
323 | return rval; | ||
324 | } | ||
331 | 325 | ||
332 | for (i = 0; i < vep->nr_of_link_frequencies; i++) | 326 | for (i = 0; i < vep->nr_of_link_frequencies; i++) |
333 | pr_info("link-frequencies %u value %llu\n", i, | 327 | pr_info("link-frequencies %u value %llu\n", i, |
@@ -336,11 +330,7 @@ struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse( | |||
336 | 330 | ||
337 | pr_debug("===== end V4L2 endpoint properties\n"); | 331 | pr_debug("===== end V4L2 endpoint properties\n"); |
338 | 332 | ||
339 | return vep; | 333 | return 0; |
340 | |||
341 | out_err: | ||
342 | v4l2_fwnode_endpoint_free(vep); | ||
343 | return ERR_PTR(rval); | ||
344 | } | 334 | } |
345 | EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_alloc_parse); | 335 | EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_alloc_parse); |
346 | 336 | ||
@@ -392,9 +382,9 @@ static int v4l2_async_notifier_fwnode_parse_endpoint( | |||
392 | struct v4l2_fwnode_endpoint *vep, | 382 | struct v4l2_fwnode_endpoint *vep, |
393 | struct v4l2_async_subdev *asd)) | 383 | struct v4l2_async_subdev *asd)) |
394 | { | 384 | { |
385 | struct v4l2_fwnode_endpoint vep = { .bus_type = 0 }; | ||
395 | struct v4l2_async_subdev *asd; | 386 | struct v4l2_async_subdev *asd; |
396 | struct v4l2_fwnode_endpoint *vep; | 387 | int ret; |
397 | int ret = 0; | ||
398 | 388 | ||
399 | asd = kzalloc(asd_struct_size, GFP_KERNEL); | 389 | asd = kzalloc(asd_struct_size, GFP_KERNEL); |
400 | if (!asd) | 390 | if (!asd) |
@@ -409,23 +399,22 @@ static int v4l2_async_notifier_fwnode_parse_endpoint( | |||
409 | goto out_err; | 399 | goto out_err; |
410 | } | 400 | } |
411 | 401 | ||
412 | vep = v4l2_fwnode_endpoint_alloc_parse(endpoint); | 402 | ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &vep); |
413 | if (IS_ERR(vep)) { | 403 | if (ret) { |
414 | ret = PTR_ERR(vep); | ||
415 | dev_warn(dev, "unable to parse V4L2 fwnode endpoint (%d)\n", | 404 | dev_warn(dev, "unable to parse V4L2 fwnode endpoint (%d)\n", |
416 | ret); | 405 | ret); |
417 | goto out_err; | 406 | goto out_err; |
418 | } | 407 | } |
419 | 408 | ||
420 | ret = parse_endpoint ? parse_endpoint(dev, vep, asd) : 0; | 409 | ret = parse_endpoint ? parse_endpoint(dev, &vep, asd) : 0; |
421 | if (ret == -ENOTCONN) | 410 | if (ret == -ENOTCONN) |
422 | dev_dbg(dev, "ignoring port@%u/endpoint@%u\n", vep->base.port, | 411 | dev_dbg(dev, "ignoring port@%u/endpoint@%u\n", vep.base.port, |
423 | vep->base.id); | 412 | vep.base.id); |
424 | else if (ret < 0) | 413 | else if (ret < 0) |
425 | dev_warn(dev, | 414 | dev_warn(dev, |
426 | "driver could not parse port@%u/endpoint@%u (%d)\n", | 415 | "driver could not parse port@%u/endpoint@%u (%d)\n", |
427 | vep->base.port, vep->base.id, ret); | 416 | vep.base.port, vep.base.id, ret); |
428 | v4l2_fwnode_endpoint_free(vep); | 417 | v4l2_fwnode_endpoint_free(&vep); |
429 | if (ret < 0) | 418 | if (ret < 0) |
430 | goto out_err; | 419 | goto out_err; |
431 | 420 | ||
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 8b4873c37098..4a371c3ad86c 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h | |||
@@ -161,6 +161,7 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); | |||
161 | /** | 161 | /** |
162 | * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties | 162 | * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties |
163 | * @fwnode: pointer to the endpoint's fwnode handle | 163 | * @fwnode: pointer to the endpoint's fwnode handle |
164 | * @vep: pointer to the V4L2 fwnode data structure | ||
164 | * | 165 | * |
165 | * All properties are optional. If none are found, we don't set any flags. This | 166 | * All properties are optional. If none are found, we don't set any flags. This |
166 | * means the port has a static configuration and no properties have to be | 167 | * means the port has a static configuration and no properties have to be |
@@ -170,6 +171,8 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); | |||
170 | * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a | 171 | * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a |
171 | * reference to @fwnode. | 172 | * reference to @fwnode. |
172 | * | 173 | * |
174 | * The caller must set the bus_type field of @vep to zero. | ||
175 | * | ||
173 | * v4l2_fwnode_endpoint_alloc_parse() has two important differences to | 176 | * v4l2_fwnode_endpoint_alloc_parse() has two important differences to |
174 | * v4l2_fwnode_endpoint_parse(): | 177 | * v4l2_fwnode_endpoint_parse(): |
175 | * | 178 | * |
@@ -178,11 +181,10 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); | |||
178 | * 2. The memory it has allocated to store the variable size data must be freed | 181 | * 2. The memory it has allocated to store the variable size data must be freed |
179 | * using v4l2_fwnode_endpoint_free() when no longer needed. | 182 | * using v4l2_fwnode_endpoint_free() when no longer needed. |
180 | * | 183 | * |
181 | * Return: Pointer to v4l2_fwnode_endpoint if successful, on an error pointer | 184 | * Return: 0 on success or a negative error code on failure. |
182 | * on error. | ||
183 | */ | 185 | */ |
184 | struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse( | 186 | int v4l2_fwnode_endpoint_alloc_parse( |
185 | struct fwnode_handle *fwnode); | 187 | struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); |
186 | 188 | ||
187 | /** | 189 | /** |
188 | * v4l2_fwnode_parse_link() - parse a link between two endpoints | 190 | * v4l2_fwnode_parse_link() - parse a link between two endpoints |