Hi Andy
On 25/02/2022 17:01, Andy Shevchenko wrote:
On Fri, Feb 25, 2022 at 12:07:46AM +0000, Daniel Scally wrote:
Move the endpoint checking from .probe() to a dedicated function,
and additionally check that the firmware provided link frequencies
are a match for those supported by the driver. Store the index to the
matching link frequency so it can be easily identified later.
...
+ ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &bus_cfg);
+ fwnode_handle_put(endpoint);
+ if (ret)
+ return dev_err_probe(ov7251->dev, ret,
+ "parsing endpoint node failed\n");
+
+ if (!bus_cfg.nr_of_link_frequencies) {
+ dev_err(ov7251->dev, "no link frequencies defined\n");
+ ret = -EINVAL;
It's also fine to use dev_err_probe() here.
Yup will switch to that.
+ goto out_free_bus_cfg;
+ }
+
+ for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) {
+ for (j = 0; j < ARRAY_SIZE(link_freq); j++)
+ if (bus_cfg.link_frequencies[i] == link_freq[j]) {
+ freq_found = true;
+ break;
+ }
+
+ if (freq_found)
+ break;
freq_found may be replaced by the
if (j < ARRAY_SIZE(link_freq))
here.
Huh oh yeah. I don't know why that never occurred to me...I was
originally even using a goto and swapped it because it was ugly. Thanks!
+ }
+
+ if (i == bus_cfg.nr_of_link_frequencies) {
+ dev_err(ov7251->dev, "no supported link freq found\n");
+ ret = -EINVAL;
dev_err_probe()
+ goto out_free_bus_cfg;
+ }
+
+ ov7251->link_freq_idx = i;
+
+out_free_bus_cfg:
+ v4l2_fwnode_endpoint_free(&bus_cfg);
+
+ return ret;
+}