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

media: Zero-initialize all structures passed to subdev pad operations

Several drivers call subdev pad operations, passing structures that are
not fully zeroed. While the drivers initialize the fields they care
about explicitly, this results in reserved fields having uninitialized
values. Future kernel API changes that make use of those fields thus
risk breaking proper driver operation in ways that could be hard to
detect.

To avoid this, make the code more robust by zero-initializing all the
structures passed to subdev pad operation. Maintain a consistent coding
style by preferring designated initializers (which zero-initialize all
the fields that are not specified) over memset() where possible, and
make variable declarations local to inner scopes where applicable. One
notable exception to this rule is in the ipu3 driver, where a memset()
is needed as the structure is not a local variable but a function
parameter provided by the caller.

Not all fields of those structures can be initialized when declaring the
variables, as the values for those fields are computed later in the
code. Initialize the 'which' field in all cases, and other fields when
the variable declaration is so close to the v4l2_subdev_call() call that
it keeps all the context easily visible when reading the code, to avoid
hindering readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org> # For vimc
Reviewed-by: Lad Prabhakar <prabhakar.csengg@gmail.com> # For am437x
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> # For drivers/staging/media/imx/
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Laurent Pinchart and committed by
Hans Verkuil
ecefa105 a8ca0cf1

+120 -82
+10 -6
drivers/media/pci/cobalt/cobalt-v4l2.c
··· 708 708 { 709 709 struct cobalt_stream *s = video_drvdata(file); 710 710 struct v4l2_pix_format *pix = &f->fmt.pix; 711 - struct v4l2_subdev_format sd_fmt; 712 711 713 712 pix->width = s->width; 714 713 pix->height = s->height; ··· 717 718 if (s->input == 1) { 718 719 pix->colorspace = V4L2_COLORSPACE_SRGB; 719 720 } else { 720 - sd_fmt.pad = s->pad_source; 721 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 721 + struct v4l2_subdev_format sd_fmt = { 722 + .pad = s->pad_source, 723 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 724 + }; 725 + 722 726 v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt); 723 727 v4l2_fill_pix_format(pix, &sd_fmt.format); 724 728 } ··· 737 735 { 738 736 struct cobalt_stream *s = video_drvdata(file); 739 737 struct v4l2_pix_format *pix = &f->fmt.pix; 740 - struct v4l2_subdev_format sd_fmt; 741 738 742 739 /* Check for min (QCIF) and max (Full HD) size */ 743 740 if ((pix->width < 176) || (pix->height < 144)) { ··· 761 760 pix->height = 1080; 762 761 pix->colorspace = V4L2_COLORSPACE_SRGB; 763 762 } else { 764 - sd_fmt.pad = s->pad_source; 765 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 763 + struct v4l2_subdev_format sd_fmt = { 764 + .pad = s->pad_source, 765 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 766 + }; 767 + 766 768 v4l2_subdev_call(s->sd, pad, get_fmt, NULL, &sd_fmt); 767 769 v4l2_fill_pix_format(pix, &sd_fmt.format); 768 770 }
+1
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
··· 1305 1305 struct v4l2_subdev *sd = 1306 1306 media_entity_to_v4l2_subdev(pad->entity); 1307 1307 1308 + memset(fmt, 0, sizeof(*fmt)); 1308 1309 fmt->which = V4L2_SUBDEV_FORMAT_ACTIVE; 1309 1310 fmt->pad = pad->index; 1310 1311 return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
+3 -2
drivers/media/platform/qcom/camss/camss-video.c
··· 342 342 static int video_get_subdev_format(struct camss_video *video, 343 343 struct v4l2_format *format) 344 344 { 345 - struct v4l2_subdev_format fmt; 345 + struct v4l2_subdev_format fmt = { 346 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 347 + }; 346 348 struct v4l2_subdev *subdev; 347 349 u32 pad; 348 350 int ret; ··· 355 353 356 354 memset(&fmt, 0, sizeof(fmt)); 357 355 fmt.pad = pad; 358 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 359 356 360 357 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); 361 358 if (ret)
+3 -2
drivers/media/platform/renesas/vsp1/vsp1_video.c
··· 62 62 63 63 static int vsp1_video_verify_format(struct vsp1_video *video) 64 64 { 65 - struct v4l2_subdev_format fmt; 65 + struct v4l2_subdev_format fmt = { 66 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 67 + }; 66 68 struct v4l2_subdev *subdev; 67 69 int ret; 68 70 ··· 72 70 if (subdev == NULL) 73 71 return -EINVAL; 74 72 75 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 76 73 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); 77 74 if (ret < 0) 78 75 return ret == -ENOIOCTLCMD ? -EINVAL : ret;
+7 -4
drivers/media/platform/samsung/exynos4-is/fimc-capture.c
··· 854 854 struct v4l2_plane_pix_format *plane_fmt, 855 855 unsigned int num_planes, bool try) 856 856 { 857 - struct v4l2_mbus_frame_desc fd; 857 + struct v4l2_mbus_frame_desc fd = { }; 858 858 int i, ret; 859 859 int pad; 860 860 ··· 1095 1095 */ 1096 1096 static int fimc_pipeline_validate(struct fimc_dev *fimc) 1097 1097 { 1098 - struct v4l2_subdev_format sink_fmt, src_fmt; 1098 + struct v4l2_subdev_format sink_fmt = { 1099 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1100 + }; 1101 + struct v4l2_subdev_format src_fmt = { 1102 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1103 + }; 1099 1104 struct fimc_vid_cap *vc = &fimc->vid_cap; 1100 1105 struct v4l2_subdev *sd = &vc->subdev; 1101 1106 struct fimc_pipeline *p = to_fimc_pipeline(vc->ve.pipe); ··· 1137 1132 sink_fmt.format.code = ff->fmt ? ff->fmt->mbus_code : 0; 1138 1133 } else { 1139 1134 sink_fmt.pad = sink_pad->index; 1140 - sink_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1141 1135 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &sink_fmt); 1142 1136 if (ret < 0 && ret != -ENOIOCTLCMD) 1143 1137 return -EPIPE; ··· 1145 1141 /* Retrieve format at the source pad */ 1146 1142 sd = media_entity_to_v4l2_subdev(src_pad->entity); 1147 1143 src_fmt.pad = src_pad->index; 1148 - src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1149 1144 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &src_fmt); 1150 1145 if (ret < 0 && ret != -ENOIOCTLCMD) 1151 1146 return -EPIPE;
+7 -3
drivers/media/platform/samsung/exynos4-is/fimc-isp-video.c
··· 449 449 static int isp_video_pipeline_validate(struct fimc_isp *isp) 450 450 { 451 451 struct v4l2_subdev *sd = &isp->subdev; 452 - struct v4l2_subdev_format sink_fmt, src_fmt; 453 452 struct media_pad *pad; 454 453 int ret; 455 454 456 455 while (1) { 456 + struct v4l2_subdev_format sink_fmt = { 457 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 458 + }; 459 + struct v4l2_subdev_format src_fmt = { 460 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 461 + }; 462 + 457 463 /* Retrieve format at the sink pad */ 458 464 pad = &sd->entity.pads[0]; 459 465 if (!(pad->flags & MEDIA_PAD_FL_SINK)) 460 466 break; 461 467 sink_fmt.pad = pad->index; 462 - sink_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 463 468 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &sink_fmt); 464 469 if (ret < 0 && ret != -ENOIOCTLCMD) 465 470 return -EPIPE; ··· 476 471 477 472 sd = media_entity_to_v4l2_subdev(pad->entity); 478 473 src_fmt.pad = pad->index; 479 - src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 480 474 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &src_fmt); 481 475 if (ret < 0 && ret != -ENOIOCTLCMD) 482 476 return -EPIPE;
+6 -3
drivers/media/platform/samsung/exynos4-is/fimc-lite.c
··· 765 765 static int fimc_pipeline_validate(struct fimc_lite *fimc) 766 766 { 767 767 struct v4l2_subdev *sd = &fimc->subdev; 768 - struct v4l2_subdev_format sink_fmt, src_fmt; 768 + struct v4l2_subdev_format sink_fmt = { 769 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 770 + }; 771 + struct v4l2_subdev_format src_fmt = { 772 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 773 + }; 769 774 struct media_pad *pad; 770 775 int ret; 771 776 ··· 787 782 sink_fmt.format.code = fimc->inp_frame.fmt->mbus_code; 788 783 } else { 789 784 sink_fmt.pad = pad->index; 790 - sink_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 791 785 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, 792 786 &sink_fmt); 793 787 if (ret < 0 && ret != -ENOIOCTLCMD) ··· 799 795 800 796 sd = media_entity_to_v4l2_subdev(pad->entity); 801 797 src_fmt.pad = pad->index; 802 - src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 803 798 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &src_fmt); 804 799 if (ret < 0 && ret != -ENOIOCTLCMD) 805 800 return -EPIPE;
+3 -2
drivers/media/platform/samsung/s3c-camif/camif-capture.c
··· 806 806 /* Only check pixel formats at the sensor and the camif subdev pads */ 807 807 static int camif_pipeline_validate(struct camif_dev *camif) 808 808 { 809 - struct v4l2_subdev_format src_fmt; 809 + struct v4l2_subdev_format src_fmt = { 810 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 811 + }; 810 812 struct media_pad *pad; 811 813 int ret; 812 814 ··· 818 816 return -EPIPE; 819 817 820 818 src_fmt.pad = pad->index; 821 - src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 822 819 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt); 823 820 if (ret < 0 && ret != -ENOIOCTLCMD) 824 821 return -EPIPE;
+3 -2
drivers/media/platform/samsung/s3c-camif/camif-core.c
··· 190 190 struct s3c_camif_sensor_info *sensor = &camif->pdata.sensor; 191 191 struct v4l2_device *v4l2_dev = &camif->v4l2_dev; 192 192 struct i2c_adapter *adapter; 193 - struct v4l2_subdev_format format; 193 + struct v4l2_subdev_format format = { 194 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 195 + }; 194 196 struct v4l2_subdev *sd; 195 197 int ret; 196 198 ··· 222 220 223 221 /* Get initial pixel format and set it at the camif sink pad */ 224 222 format.pad = 0; 225 - format.which = V4L2_SUBDEV_FORMAT_ACTIVE; 226 223 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &format); 227 224 228 225 if (ret < 0)
+11 -9
drivers/media/platform/ti/am437x/am437x-vpfe.c
··· 1285 1285 struct v4l2_mbus_framefmt *fmt) 1286 1286 { 1287 1287 struct v4l2_subdev *sd = vpfe->current_subdev->sd; 1288 - struct v4l2_subdev_format sd_fmt; 1288 + struct v4l2_subdev_format sd_fmt = { 1289 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1290 + .pad = 0, 1291 + }; 1289 1292 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format; 1290 1293 int ret; 1291 - 1292 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1293 - sd_fmt.pad = 0; 1294 1294 1295 1295 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &sd_fmt); 1296 1296 if (ret) ··· 1309 1309 struct v4l2_mbus_framefmt *fmt) 1310 1310 { 1311 1311 struct v4l2_subdev *sd = vpfe->current_subdev->sd; 1312 - struct v4l2_subdev_format sd_fmt; 1312 + struct v4l2_subdev_format sd_fmt = { 1313 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1314 + .pad = 0, 1315 + }; 1313 1316 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format; 1314 1317 int ret; 1315 1318 1316 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1317 - sd_fmt.pad = 0; 1318 1319 *mbus_fmt = *fmt; 1319 1320 1320 1321 ret = v4l2_subdev_call(sd, pad, set_fmt, NULL, &sd_fmt); ··· 1394 1393 struct vpfe_device *vpfe = video_drvdata(file); 1395 1394 struct v4l2_subdev *sd = vpfe->current_subdev->sd; 1396 1395 const struct vpfe_fmt *fmt; 1397 - struct v4l2_subdev_frame_size_enum fse; 1396 + struct v4l2_subdev_frame_size_enum fse = { 1397 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1398 + }; 1398 1399 int ret, found; 1399 1400 1400 1401 fmt = find_format_by_pix(vpfe, f->fmt.pix.pixelformat); ··· 1415 1412 found = false; 1416 1413 fse.pad = 0; 1417 1414 fse.code = fmt->code; 1418 - fse.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1419 1415 for (fse.index = 0; ; fse.index++) { 1420 1416 ret = v4l2_subdev_call(sd, pad, enum_frame_size, 1421 1417 NULL, &fse);
+16 -13
drivers/media/platform/ti/cal/cal-video.c
··· 117 117 static int __subdev_get_format(struct cal_ctx *ctx, 118 118 struct v4l2_mbus_framefmt *fmt) 119 119 { 120 - struct v4l2_subdev_format sd_fmt; 120 + struct v4l2_subdev_format sd_fmt = { 121 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 122 + .pad = 0, 123 + }; 121 124 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format; 122 125 int ret; 123 - 124 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 125 - sd_fmt.pad = 0; 126 126 127 127 ret = v4l2_subdev_call(ctx->phy->source, pad, get_fmt, NULL, &sd_fmt); 128 128 if (ret) ··· 139 139 static int __subdev_set_format(struct cal_ctx *ctx, 140 140 struct v4l2_mbus_framefmt *fmt) 141 141 { 142 - struct v4l2_subdev_format sd_fmt; 142 + struct v4l2_subdev_format sd_fmt = { 143 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 144 + .pad = 0, 145 + }; 143 146 struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format; 144 147 int ret; 145 148 146 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 147 - sd_fmt.pad = 0; 148 149 *mbus_fmt = *fmt; 149 150 150 151 ret = v4l2_subdev_call(ctx->phy->source, pad, set_fmt, NULL, &sd_fmt); ··· 191 190 { 192 191 struct cal_ctx *ctx = video_drvdata(file); 193 192 const struct cal_format_info *fmtinfo; 194 - struct v4l2_subdev_frame_size_enum fse; 193 + struct v4l2_subdev_frame_size_enum fse = { 194 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 195 + }; 195 196 int found; 196 197 197 198 fmtinfo = find_format_by_pix(ctx, f->fmt.pix.pixelformat); ··· 212 209 found = false; 213 210 fse.pad = 0; 214 211 fse.code = fmtinfo->code; 215 - fse.which = V4L2_SUBDEV_FORMAT_ACTIVE; 216 212 for (fse.index = 0; ; fse.index++) { 217 213 int ret; 218 214 ··· 304 302 { 305 303 struct cal_ctx *ctx = video_drvdata(file); 306 304 const struct cal_format_info *fmtinfo; 307 - struct v4l2_subdev_frame_size_enum fse; 305 + struct v4l2_subdev_frame_size_enum fse = { 306 + .index = fsize->index, 307 + .pad = 0, 308 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 309 + }; 308 310 int ret; 309 311 310 312 /* check for valid format */ ··· 319 313 return -EINVAL; 320 314 } 321 315 322 - fse.index = fsize->index; 323 - fse.pad = 0; 324 316 fse.code = fmtinfo->code; 325 - fse.which = V4L2_SUBDEV_FORMAT_ACTIVE; 326 317 327 318 ret = v4l2_subdev_call(ctx->phy->source, pad, enum_frame_size, NULL, 328 319 &fse);
+3 -2
drivers/media/platform/ti/omap3isp/ispccdc.c
··· 1118 1118 struct v4l2_mbus_framefmt *format; 1119 1119 const struct v4l2_rect *crop; 1120 1120 const struct isp_format_info *fmt_info; 1121 - struct v4l2_subdev_format fmt_src; 1121 + struct v4l2_subdev_format fmt_src = { 1122 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1123 + }; 1122 1124 unsigned int depth_out; 1123 1125 unsigned int depth_in = 0; 1124 1126 struct media_pad *pad; ··· 1152 1150 * input format is a non-BT.656 YUV variant. 1153 1151 */ 1154 1152 fmt_src.pad = pad->index; 1155 - fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1156 1153 if (!v4l2_subdev_call(sensor, pad, get_fmt, NULL, &fmt_src)) { 1157 1154 fmt_info = omap3isp_video_format_info(fmt_src.format.code); 1158 1155 depth_in = fmt_info->width;
+12 -8
drivers/media/platform/ti/omap3isp/ispvideo.c
··· 268 268 static int 269 269 __isp_video_get_format(struct isp_video *video, struct v4l2_format *format) 270 270 { 271 - struct v4l2_subdev_format fmt; 271 + struct v4l2_subdev_format fmt = { 272 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 273 + }; 272 274 struct v4l2_subdev *subdev; 273 275 u32 pad; 274 276 int ret; ··· 280 278 return -EINVAL; 281 279 282 280 fmt.pad = pad; 283 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 284 281 285 282 mutex_lock(&video->mutex); 286 283 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); ··· 732 731 isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format) 733 732 { 734 733 struct isp_video *video = video_drvdata(file); 735 - struct v4l2_subdev_format fmt; 734 + struct v4l2_subdev_format fmt = { 735 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 736 + }; 736 737 struct v4l2_subdev *subdev; 737 738 u32 pad; 738 739 int ret; ··· 749 746 isp_video_pix_to_mbus(&format->fmt.pix, &fmt.format); 750 747 751 748 fmt.pad = pad; 752 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 753 749 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); 754 750 if (ret) 755 751 return ret == -ENOIOCTLCMD ? -ENOTTY : ret; ··· 761 759 isp_video_get_selection(struct file *file, void *fh, struct v4l2_selection *sel) 762 760 { 763 761 struct isp_video *video = video_drvdata(file); 764 - struct v4l2_subdev_format format; 762 + struct v4l2_subdev_format format = { 763 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 764 + }; 765 765 struct v4l2_subdev *subdev; 766 766 struct v4l2_subdev_selection sdsel = { 767 767 .which = V4L2_SUBDEV_FORMAT_ACTIVE, ··· 803 799 return ret; 804 800 805 801 format.pad = pad; 806 - format.which = V4L2_SUBDEV_FORMAT_ACTIVE; 807 802 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &format); 808 803 if (ret < 0) 809 804 return ret == -ENOIOCTLCMD ? -ENOTTY : ret; ··· 960 957 struct media_pad *source_pad; 961 958 struct media_entity *source = NULL; 962 959 struct media_entity *sink; 963 - struct v4l2_subdev_format fmt; 960 + struct v4l2_subdev_format fmt = { 961 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 962 + }; 964 963 struct v4l2_ext_controls ctrls; 965 964 struct v4l2_ext_control ctrl; 966 965 unsigned int i; ··· 998 993 pipe->external = media_entity_to_v4l2_subdev(source); 999 994 1000 995 fmt.pad = source_pad->index; 1001 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 1002 996 ret = v4l2_subdev_call(media_entity_to_v4l2_subdev(sink), 1003 997 pad, get_fmt, NULL, &fmt); 1004 998 if (unlikely(ret < 0)) {
+3 -2
drivers/media/platform/xilinx/xilinx-dma.c
··· 56 56 57 57 static int xvip_dma_verify_format(struct xvip_dma *dma) 58 58 { 59 - struct v4l2_subdev_format fmt; 59 + struct v4l2_subdev_format fmt = { 60 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 61 + }; 60 62 struct v4l2_subdev *subdev; 61 63 int ret; 62 64 ··· 66 64 if (subdev == NULL) 67 65 return -EPIPE; 68 66 69 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 70 67 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); 71 68 if (ret < 0) 72 69 return ret == -ENOIOCTLCMD ? -EINVAL : ret;
+4 -4
drivers/media/test-drivers/vimc/vimc-common.c
··· 241 241 if (is_media_entity_v4l2_subdev(pad->entity)) { 242 242 struct v4l2_subdev *sd = 243 243 media_entity_to_v4l2_subdev(pad->entity); 244 - struct v4l2_subdev_format sd_fmt; 244 + struct v4l2_subdev_format sd_fmt = { 245 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 246 + .pad = pad->index, 247 + }; 245 248 const struct vimc_pix_map *pix_map; 246 249 int ret; 247 - 248 - sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 249 - sd_fmt.pad = pad->index; 250 250 251 251 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &sd_fmt); 252 252 if (ret)
+16 -12
drivers/staging/media/imx/imx-media-capture.c
··· 353 353 { 354 354 struct capture_priv *priv = video_drvdata(file); 355 355 const struct imx_media_pixfmt *cc_src; 356 - struct v4l2_subdev_format fmt_src; 356 + struct v4l2_subdev_format fmt_src = { 357 + .pad = priv->src_sd_pad, 358 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 359 + }; 357 360 u32 fourcc; 358 361 int ret; 359 362 360 - fmt_src.pad = priv->src_sd_pad; 361 - fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; 362 363 ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); 363 364 if (ret) { 364 365 dev_err(priv->dev, "failed to get src_sd format\n"); ··· 427 426 struct v4l2_format *f) 428 427 { 429 428 struct capture_priv *priv = video_drvdata(file); 430 - struct v4l2_subdev_format fmt_src; 429 + struct v4l2_subdev_format fmt_src = { 430 + .pad = priv->src_sd_pad, 431 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 432 + }; 431 433 int ret; 432 434 433 - fmt_src.pad = priv->src_sd_pad; 434 - fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; 435 435 ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); 436 436 if (ret) 437 437 return ret; ··· 447 445 struct v4l2_format *f) 448 446 { 449 447 struct capture_priv *priv = video_drvdata(file); 450 - struct v4l2_subdev_format fmt_src; 448 + struct v4l2_subdev_format fmt_src = { 449 + .pad = priv->src_sd_pad, 450 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 451 + }; 451 452 const struct imx_media_pixfmt *cc; 452 453 int ret; 453 454 ··· 459 454 return -EBUSY; 460 455 } 461 456 462 - fmt_src.pad = priv->src_sd_pad; 463 - fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; 464 457 ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); 465 458 if (ret) 466 459 return ret; ··· 673 670 674 671 static int capture_validate_fmt(struct capture_priv *priv) 675 672 { 676 - struct v4l2_subdev_format fmt_src; 673 + struct v4l2_subdev_format fmt_src = { 674 + .pad = priv->src_sd_pad, 675 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 676 + }; 677 677 const struct imx_media_pixfmt *cc; 678 678 int ret; 679 679 680 680 /* Retrieve the media bus format on the source subdev. */ 681 - fmt_src.pad = priv->src_sd_pad; 682 - fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; 683 681 ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); 684 682 if (ret) 685 683 return ret;
+6 -4
drivers/staging/media/omap4iss/iss_video.c
··· 610 610 iss_video_try_format(struct file *file, void *fh, struct v4l2_format *format) 611 611 { 612 612 struct iss_video *video = video_drvdata(file); 613 - struct v4l2_subdev_format fmt; 613 + struct v4l2_subdev_format fmt = { 614 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 615 + }; 614 616 struct v4l2_subdev *subdev; 615 617 u32 pad; 616 618 int ret; ··· 627 625 iss_video_pix_to_mbus(&format->fmt.pix, &fmt.format); 628 626 629 627 fmt.pad = pad; 630 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 631 628 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); 632 629 if (ret) 633 630 return ret; ··· 639 638 iss_video_get_selection(struct file *file, void *fh, struct v4l2_selection *sel) 640 639 { 641 640 struct iss_video *video = video_drvdata(file); 642 - struct v4l2_subdev_format format; 641 + struct v4l2_subdev_format format = { 642 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 643 + }; 643 644 struct v4l2_subdev *subdev; 644 645 struct v4l2_subdev_selection sdsel = { 645 646 .which = V4L2_SUBDEV_FORMAT_ACTIVE, ··· 682 679 return ret; 683 680 684 681 format.pad = pad; 685 - format.which = V4L2_SUBDEV_FORMAT_ACTIVE; 686 682 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &format); 687 683 if (ret < 0) 688 684 return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
+6 -4
drivers/staging/media/tegra-video/vi.c
··· 493 493 const struct tegra_video_format *fmtinfo; 494 494 static struct lock_class_key key; 495 495 struct v4l2_subdev *subdev; 496 - struct v4l2_subdev_format fmt; 496 + struct v4l2_subdev_format fmt = { 497 + .which = V4L2_SUBDEV_FORMAT_TRY, 498 + }; 497 499 struct v4l2_subdev_state *sd_state; 498 500 struct v4l2_subdev_frame_size_enum fse = { 499 501 .which = V4L2_SUBDEV_FORMAT_TRY, ··· 531 529 } 532 530 533 531 pix->field = V4L2_FIELD_NONE; 534 - fmt.which = V4L2_SUBDEV_FORMAT_TRY; 535 532 fmt.pad = 0; 536 533 v4l2_fill_mbus_format(&fmt.format, pix, fmtinfo->code); 537 534 ··· 591 590 { 592 591 struct tegra_vi_channel *chan = video_drvdata(file); 593 592 const struct tegra_video_format *fmtinfo; 594 - struct v4l2_subdev_format fmt; 593 + struct v4l2_subdev_format fmt = { 594 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 595 + }; 595 596 struct v4l2_subdev *subdev; 596 597 struct v4l2_pix_format *pix = &format->fmt.pix; 597 598 int ret; ··· 608 605 609 606 fmtinfo = tegra_get_format_by_fourcc(chan->vi, pix->pixelformat); 610 607 611 - fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 612 608 fmt.pad = 0; 613 609 v4l2_fill_mbus_format(&fmt.format, pix, fmtinfo->code); 614 610 subdev = tegra_channel_get_remote_source_subdev(chan);