hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/platform/rcar_drif.c
....@@ -185,7 +185,6 @@
185185 /* OF graph endpoint's V4L2 async data */
186186 struct rcar_drif_graph_ep {
187187 struct v4l2_subdev *subdev; /* Async matched subdev */
188
- struct v4l2_async_subdev asd; /* Async sub-device descriptor */
189188 };
190189
191190 /* DMA buffer */
....@@ -275,10 +274,14 @@
275274 for_each_rcar_drif_channel(i, &sdr->cur_ch_mask) {
276275 struct rcar_drif *ch = sdr->ch[i];
277276
278
- ch->dmach = dma_request_slave_channel(&ch->pdev->dev, "rx");
279
- if (!ch->dmach) {
280
- rdrif_err(sdr, "ch%u: dma channel req failed\n", i);
281
- ret = -ENODEV;
277
+ ch->dmach = dma_request_chan(&ch->pdev->dev, "rx");
278
+ if (IS_ERR(ch->dmach)) {
279
+ ret = PTR_ERR(ch->dmach);
280
+ if (ret != -EPROBE_DEFER)
281
+ rdrif_err(sdr,
282
+ "ch%u: dma channel req failed: %pe\n",
283
+ i, ch->dmach);
284
+ ch->dmach = NULL;
282285 goto dmach_error;
283286 }
284287
....@@ -870,8 +873,8 @@
870873 {
871874 struct rcar_drif_sdr *sdr = video_drvdata(file);
872875
873
- strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
874
- strlcpy(cap->card, sdr->vdev->name, sizeof(cap->card));
876
+ strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
877
+ strscpy(cap->card, sdr->vdev->name, sizeof(cap->card));
875878 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
876879 sdr->vdev->name);
877880
....@@ -1104,12 +1107,6 @@
11041107 struct rcar_drif_sdr *sdr =
11051108 container_of(notifier, struct rcar_drif_sdr, notifier);
11061109
1107
- if (sdr->ep.asd.match.fwnode !=
1108
- of_fwnode_handle(subdev->dev->of_node)) {
1109
- rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name);
1110
- return -EINVAL;
1111
- }
1112
-
11131110 v4l2_set_subdev_hostdata(subdev, sdr);
11141111 sdr->ep.subdev = subdev;
11151112 rdrif_dbg(sdr, "bound asd %s\n", subdev->name);
....@@ -1164,7 +1161,7 @@
11641161 }
11651162
11661163 ret = v4l2_ctrl_add_handler(&sdr->ctrl_hdl,
1167
- sdr->ep.subdev->ctrl_handler, NULL);
1164
+ sdr->ep.subdev->ctrl_handler, NULL, true);
11681165 if (ret) {
11691166 rdrif_err(sdr, "failed: ctrl add hdlr ret %d\n", ret);
11701167 goto error;
....@@ -1213,34 +1210,30 @@
12131210 {
12141211 struct v4l2_async_notifier *notifier = &sdr->notifier;
12151212 struct fwnode_handle *fwnode, *ep;
1213
+ struct v4l2_async_subdev *asd;
12161214
1217
- notifier->subdevs = devm_kzalloc(sdr->dev, sizeof(*notifier->subdevs),
1218
- GFP_KERNEL);
1219
- if (!notifier->subdevs)
1220
- return -ENOMEM;
1215
+ v4l2_async_notifier_init(notifier);
12211216
12221217 ep = fwnode_graph_get_next_endpoint(of_fwnode_handle(sdr->dev->of_node),
12231218 NULL);
12241219 if (!ep)
12251220 return 0;
12261221
1227
- notifier->subdevs[notifier->num_subdevs] = &sdr->ep.asd;
1228
- fwnode = fwnode_graph_get_remote_port_parent(ep);
1229
- if (!fwnode) {
1230
- dev_warn(sdr->dev, "bad remote port parent\n");
1231
- fwnode_handle_put(ep);
1232
- return -EINVAL;
1233
- }
1234
-
1235
- sdr->ep.asd.match.fwnode = fwnode;
1236
- sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
1237
- notifier->num_subdevs++;
1238
-
12391222 /* Get the endpoint properties */
12401223 rcar_drif_get_ep_properties(sdr, ep);
12411224
1242
- fwnode_handle_put(fwnode);
1225
+ fwnode = fwnode_graph_get_remote_port_parent(ep);
12431226 fwnode_handle_put(ep);
1227
+ if (!fwnode) {
1228
+ dev_warn(sdr->dev, "bad remote port parent\n");
1229
+ return -EINVAL;
1230
+ }
1231
+
1232
+ asd = v4l2_async_notifier_add_fwnode_subdev(notifier, fwnode,
1233
+ sizeof(*asd));
1234
+ fwnode_handle_put(fwnode);
1235
+ if (IS_ERR(asd))
1236
+ return PTR_ERR(asd);
12441237
12451238 return 0;
12461239 }
....@@ -1356,11 +1349,13 @@
13561349 ret = v4l2_async_notifier_register(&sdr->v4l2_dev, &sdr->notifier);
13571350 if (ret < 0) {
13581351 dev_err(sdr->dev, "failed: notifier register ret %d\n", ret);
1359
- goto error;
1352
+ goto cleanup;
13601353 }
13611354
13621355 return ret;
13631356
1357
+cleanup:
1358
+ v4l2_async_notifier_cleanup(&sdr->notifier);
13641359 error:
13651360 v4l2_device_unregister(&sdr->v4l2_dev);
13661361
....@@ -1371,6 +1366,7 @@
13711366 static void rcar_drif_sdr_remove(struct rcar_drif_sdr *sdr)
13721367 {
13731368 v4l2_async_notifier_unregister(&sdr->notifier);
1369
+ v4l2_async_notifier_cleanup(&sdr->notifier);
13741370 v4l2_device_unregister(&sdr->v4l2_dev);
13751371 }
13761372
....@@ -1401,11 +1397,9 @@
14011397 /* Register map */
14021398 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
14031399 ch->base = devm_ioremap_resource(&pdev->dev, res);
1404
- if (IS_ERR(ch->base)) {
1405
- ret = PTR_ERR(ch->base);
1406
- dev_err(&pdev->dev, "ioremap failed (%d)\n", ret);
1407
- return ret;
1408
- }
1400
+ if (IS_ERR(ch->base))
1401
+ return PTR_ERR(ch->base);
1402
+
14091403 ch->start = res->start;
14101404 platform_set_drvdata(pdev, ch);
14111405