Kernel: v4l2: tegra-video: All unhandled ioctl's are acknowledged with 0 return code

In the linux-nvidia repository (branch l4t/l4t-r32.5) the tegra-video driver implement v4l2_ioctl_ops::default_ioctl like this:

static long tegra_channel_default_ioctl(struct file *file, void *fh,
			bool use_prio, unsigned int cmd, void *arg)
{
	struct tegra_channel *chan = video_drvdata(file);
	struct tegra_mc_vi *vi = chan->vi;
	long ret = 0;

	if (vi->fops && vi->fops->vi_default_ioctl)
		ret = vi->fops->vi_default_ioctl(file, fh, use_prio, cmd, arg);

	return ret;
}

and vi_default_ioctl isn’t implemented by any of the different fops versions:

$ grep -Rin vi_default_ioctl 
include/media/mc_common.h:417:	long (*vi_default_ioctl)(struct file *file, void *fh,
drivers/media/platform/tegra/camera/vi/channel.c:2062:	if (vi->fops && vi->fops->vi_default_ioctl)
drivers/media/platform/tegra/camera/vi/channel.c:2063:		ret = vi->fops->vi_default_ioctl(file, fh, use_prio, cmd, arg);

This results in every ioctl call on the video device to return with 0 since it’s not handled by vi->fops. The expected behaviour here would be that a non-zero error code is returned for unhandled ioctls. From a cursory look how some mainline drivers implement this it seems -ENOTTY, -ENOIOCTLCMD or just -EINVAL are common error codes here.
Would be great if the code could be changed to return one of those instead of 0, because we currently have to work around it in userspace

Thanks and best regards,
Marvin

hello marvin.schmidt,

may I know what’s the “other” private IOCTLs you would like to achieve?
according to v4l2-ioctl.h,
for example,

286  struct v4l2_ioctl_ops {
...
567  	/* For other private ioctls */
568  	long (*vidioc_default)(struct file *file, void *fh,
569  			       bool valid_prio, unsigned int cmd, void *arg);

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.