static int ivtv_g_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
 
        vbifmt->reserved[0] = 0;
 
 static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
 
 
 static int ivtv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
 
        vbifmt->sampling_rate = 27000000;
 static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
        struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
 
        vbifmt->reserved[0] = 0;
 
 static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
 
 
 static int ivtv_g_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        struct v4l2_window *winfmt = &fmt->fmt.win;
 
        if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
 
 static int ivtv_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        int w = fmt->fmt.pix.width;
        int h = fmt->fmt.pix.height;
 static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
        struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
 
        if (id->type == IVTV_DEC_STREAM_TYPE_VBI)
 
 static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        s32 w = fmt->fmt.pix.width;
        s32 h = fmt->fmt.pix.height;
        int field = fmt->fmt.pix.field;
 
 static int ivtv_try_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        u32 chromakey = fmt->fmt.win.chromakey;
        u8 global_alpha = fmt->fmt.win.global_alpha;
 
 
 static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct v4l2_mbus_framefmt mbus_fmt;
        int ret = ivtv_try_fmt_vid_cap(file, fh, fmt);
 
 static int ivtv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (!ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0)
                return -EBUSY;
 static int ivtv_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
 {
        struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        int ret = ivtv_try_fmt_sliced_vbi_cap(file, fh, fmt);
 
 
 static int ivtv_s_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct yuv_playback_info *yi = &itv->yuv_info;
        int ret = ivtv_try_fmt_vid_out(file, fh, fmt);
 
 static int ivtv_s_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        int ret = ivtv_try_fmt_vid_out_overlay(file, fh, fmt);
 
        if (ret == 0) {
 
 static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_ident *chip)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        chip->ident = V4L2_IDENT_NONE;
        chip->revision = 0;
 
 static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (v4l2_chip_match_host(®->match))
                return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
 
 static int ivtv_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (v4l2_chip_match_host(®->match))
                return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
 
 static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vcap)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
        strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
 
 static int ivtv_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        return ivtv_get_audio_input(itv, vin->index, vin);
 }
 
 static int ivtv_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        vin->index = itv->audio_input;
        return ivtv_get_audio_input(itv, vin->index, vin);
 
 static int ivtv_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (vout->index >= itv->nof_audio_inputs)
                return -EINVAL;
 
 static int ivtv_enumaudout(struct file *file, void *fh, struct v4l2_audioout *vin)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        /* set it to defaults from our table */
        return ivtv_get_audio_output(itv, vin->index, vin);
 
 static int ivtv_g_audout(struct file *file, void *fh, struct v4l2_audioout *vin)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        vin->index = 0;
        return ivtv_get_audio_output(itv, vin->index, vin);
 
 static int ivtv_s_audout(struct file *file, void *fh, struct v4l2_audioout *vout)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        return ivtv_get_audio_output(itv, vout->index, vout);
 }
 
 static int ivtv_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        /* set it to defaults from our table */
        return ivtv_get_input(itv, vin->index, vin);
 
 static int ivtv_enum_output(struct file *file, void *fh, struct v4l2_output *vout)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        return ivtv_get_output(itv, vout->index, vout);
 }
 
 static int ivtv_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropcap)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct yuv_playback_info *yi = &itv->yuv_info;
        int streamtype;
 
 static int ivtv_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct yuv_playback_info *yi = &itv->yuv_info;
        int streamtype;
 
 static int ivtv_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct yuv_playback_info *yi = &itv->yuv_info;
        int streamtype;
 
 static int ivtv_enum_fmt_vid_out(struct file *file, void *fh, struct v4l2_fmtdesc *fmt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        static struct v4l2_fmtdesc formats[] = {
                { 0, 0, 0,
 
 static int ivtv_g_input(struct file *file, void *fh, unsigned int *i)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        *i = itv->active_input;
 
 
 int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (inp < 0 || inp >= itv->nof_inputs)
                return -EINVAL;
 
 static int ivtv_g_output(struct file *file, void *fh, unsigned int *i)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
                return -EINVAL;
 
 static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (outp >= itv->card->nof_outputs)
                return -EINVAL;
 
 static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (vf->tuner != 0)
                return -EINVAL;
 
 int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (vf->tuner != 0)
                return -EINVAL;
 
 static int ivtv_g_std(struct file *file, void *fh, v4l2_std_id *std)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        *std = itv->std;
        return 0;
 int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std)
 {
        DEFINE_WAIT(wait);
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        struct yuv_playback_info *yi = &itv->yuv_info;
        int f;
 
 
 static int ivtv_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
 
        if (vt->index != 0)
 
 static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (vt->index != 0)
                return -EINVAL;
 
 static int ivtv_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
        int f, l;
 
 
 static int ivtv_g_enc_index(struct file *file, void *fh, struct v4l2_enc_idx *idx)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        struct v4l2_enc_idx_entry *e = idx->entry;
        int entries;
        int i;
 
 static int ivtv_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *enc)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
 
 
 
 static int ivtv_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *enc)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        switch (enc->cmd) {
        case V4L2_ENC_CMD_START:
 
 static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        u32 data[CX2341X_MBOX_MAX_DATA];
        struct yuv_playback_info *yi = &itv->yuv_info;
 
 
 static int ivtv_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
        struct yuv_playback_info *yi = &itv->yuv_info;
 
 
 static int ivtv_overlay(struct file *file, void *fh, unsigned int on)
 {
-       struct ivtv_open_id *id = fh;
+       struct ivtv_open_id *id = fh2id(fh);
        struct ivtv *itv = id->itv;
 
        if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
 
 static int ivtv_log_status(struct file *file, void *fh)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
        u32 data[CX2341X_MBOX_MAX_DATA];
 
        int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT;
 static long ivtv_default(struct file *file, void *fh, bool valid_prio,
                         int cmd, void *arg)
 {
-       struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
+       struct ivtv *itv = fh2id(fh)->itv;
 
        if (!valid_prio) {
                switch (cmd) {