hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/platform/cadence/cdns-csi2rx.c
....@@ -361,7 +361,7 @@
361361
362362 static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx)
363363 {
364
- struct v4l2_fwnode_endpoint v4l2_ep;
364
+ struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
365365 struct fwnode_handle *fwh;
366366 struct device_node *ep;
367367 int ret;
....@@ -378,7 +378,7 @@
378378 return ret;
379379 }
380380
381
- if (v4l2_ep.bus_type != V4L2_MBUS_CSI2) {
381
+ if (v4l2_ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
382382 dev_err(csi2rx->dev, "Unsupported media bus type: 0x%x\n",
383383 v4l2_ep.bus_type);
384384 of_node_put(ep);
....@@ -399,18 +399,22 @@
399399 csi2rx->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
400400 of_node_put(ep);
401401
402
- csi2rx->notifier.subdevs = devm_kzalloc(csi2rx->dev,
403
- sizeof(*csi2rx->notifier.subdevs),
404
- GFP_KERNEL);
405
- if (!csi2rx->notifier.subdevs)
406
- return -ENOMEM;
402
+ v4l2_async_notifier_init(&csi2rx->notifier);
407403
408
- csi2rx->notifier.subdevs[0] = &csi2rx->asd;
409
- csi2rx->notifier.num_subdevs = 1;
404
+ ret = v4l2_async_notifier_add_subdev(&csi2rx->notifier, &csi2rx->asd);
405
+ if (ret) {
406
+ fwnode_handle_put(csi2rx->asd.match.fwnode);
407
+ return ret;
408
+ }
409
+
410410 csi2rx->notifier.ops = &csi2rx_notifier_ops;
411411
412
- return v4l2_async_subdev_notifier_register(&csi2rx->subdev,
413
- &csi2rx->notifier);
412
+ ret = v4l2_async_subdev_notifier_register(&csi2rx->subdev,
413
+ &csi2rx->notifier);
414
+ if (ret)
415
+ v4l2_async_notifier_cleanup(&csi2rx->notifier);
416
+
417
+ return ret;
414418 }
415419
416420 static int csi2rx_probe(struct platform_device *pdev)
....@@ -450,11 +454,11 @@
450454 ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX,
451455 csi2rx->pads);
452456 if (ret)
453
- goto err_free_priv;
457
+ goto err_cleanup;
454458
455459 ret = v4l2_async_register_subdev(&csi2rx->subdev);
456460 if (ret < 0)
457
- goto err_free_priv;
461
+ goto err_cleanup;
458462
459463 dev_info(&pdev->dev,
460464 "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n",
....@@ -463,6 +467,8 @@
463467
464468 return 0;
465469
470
+err_cleanup:
471
+ v4l2_async_notifier_cleanup(&csi2rx->notifier);
466472 err_free_priv:
467473 kfree(csi2rx);
468474 return ret;