[media] Use a named union in struct v4l2_ioctl_info
authorHans Verkuil <hverkuil@xs4all.nl>
Thu, 12 Jul 2012 15:06:24 +0000 (12:06 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 31 Jul 2012 00:43:25 +0000 (21:43 -0300)
Hi Mauro,

struct v4l2_ioctl_info uses an anonymous union, which is initialized
in the v4l2_ioctls table.

Unfortunately gcc < 4.6 uses a non-standard syntax for that, so trying to
compile v4l2-ioctl.c with an older gcc will fail.

It is possible to work around this by testing the gcc version, but in this
case it is easier to make the union named since it is used in only a few
places.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/v4l2-ioctl.c

index 0f54f8efe66b52e46b90707dbfa08a9805a5ebe1..c3b7b5f59b328a8beea170977261e4d650da88b7 100644 (file)
@@ -1891,7 +1891,7 @@ struct v4l2_ioctl_info {
                u32 offset;
                int (*func)(const struct v4l2_ioctl_ops *ops,
                                struct file *file, void *fh, void *p);
-       };
+       } u;
        void (*debug)(const void *arg, bool write_only);
 };
 
@@ -1916,7 +1916,7 @@ struct v4l2_ioctl_info {
                .ioctl = _ioctl,                                        \
                .flags = _flags | INFO_FL_STD,                          \
                .name = #_ioctl,                                        \
-               .offset = offsetof(struct v4l2_ioctl_ops, _vidioc),     \
+               .u.offset = offsetof(struct v4l2_ioctl_ops, _vidioc),   \
                .debug = _debug,                                        \
        }
 
@@ -1925,7 +1925,7 @@ struct v4l2_ioctl_info {
                .ioctl = _ioctl,                                        \
                .flags = _flags | INFO_FL_FUNC,                         \
                .name = #_ioctl,                                        \
-               .func = _func,                                          \
+               .u.func = _func,                                        \
                .debug = _debug,                                        \
        }
 
@@ -2124,11 +2124,11 @@ static long __video_do_ioctl(struct file *file,
        if (info->flags & INFO_FL_STD) {
                typedef int (*vidioc_op)(struct file *file, void *fh, void *p);
                const void *p = vfd->ioctl_ops;
-               const vidioc_op *vidioc = p + info->offset;
+               const vidioc_op *vidioc = p + info->u.offset;
 
                ret = (*vidioc)(file, fh, arg);
        } else if (info->flags & INFO_FL_FUNC) {
-               ret = info->func(ops, file, fh, arg);
+               ret = info->u.func(ops, file, fh, arg);
        } else if (!ops->vidioc_default) {
                ret = -ENOTTY;
        } else {