u32 function,
                         u16 num_pads,
                         const unsigned long *pads_flag,
+                        const struct v4l2_subdev_internal_ops *sd_int_ops,
                         const struct v4l2_subdev_ops *sd_ops)
 {
        int ret;
 
        /* Initialize the subdev */
        v4l2_subdev_init(sd, sd_ops);
+       sd->internal_ops = sd_int_ops;
        sd->entity.function = function;
        sd->entity.ops = &vimc_ent_sd_mops;
        sd->owner = THIS_MODULE;
 
 void vimc_ent_sd_unregister(struct vimc_ent_device *ved, struct v4l2_subdev *sd)
 {
-       v4l2_device_unregister_subdev(sd);
        media_entity_cleanup(ved->ent);
        vimc_pads_cleanup(ved->pads);
+       v4l2_device_unregister_subdev(sd);
 }
 EXPORT_SYMBOL_GPL(vimc_ent_sd_unregister);
 
 
  * @function:  media entity function defined by MEDIA_ENT_F_* macros
  * @num_pads:  number of pads to initialize
  * @pads_flag: flags to use in each pad
+ * @sd_int_ops:        pointer to &struct v4l2_subdev_internal_ops
  * @sd_ops:    pointer to &struct v4l2_subdev_ops.
  *
  * Helper function initialize and register the struct vimc_ent_device and struct
                         u32 function,
                         u16 num_pads,
                         const unsigned long *pads_flag,
+                        const struct v4l2_subdev_internal_ops *sd_int_ops,
                         const struct v4l2_subdev_ops *sd_ops);
 
 /**
 
 
 }
 
+static void vimc_deb_release(struct v4l2_subdev *sd)
+{
+       struct vimc_deb_device *vdeb =
+                               container_of(sd, struct vimc_deb_device, sd);
+
+       kfree(vdeb);
+}
+
+static const struct v4l2_subdev_internal_ops vimc_deb_int_ops = {
+       .release = vimc_deb_release,
+};
+
 static void vimc_deb_comp_unbind(struct device *comp, struct device *master,
                                 void *master_data)
 {
                                                    ved);
 
        vimc_ent_sd_unregister(ved, &vdeb->sd);
-       kfree(vdeb);
 }
 
 static int vimc_deb_comp_bind(struct device *comp, struct device *master,
                                   MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV, 2,
                                   (const unsigned long[2]) {MEDIA_PAD_FL_SINK,
                                   MEDIA_PAD_FL_SOURCE},
-                                  &vimc_deb_ops);
+                                  &vimc_deb_int_ops, &vimc_deb_ops);
        if (ret) {
                kfree(vdeb);
                return ret;
 
        return vsca->src_frame;
 };
 
+static void vimc_sca_release(struct v4l2_subdev *sd)
+{
+       struct vimc_sca_device *vsca =
+                               container_of(sd, struct vimc_sca_device, sd);
+
+       kfree(vsca);
+}
+
+static const struct v4l2_subdev_internal_ops vimc_sca_int_ops = {
+       .release = vimc_sca_release,
+};
+
 static void vimc_sca_comp_unbind(struct device *comp, struct device *master,
                                 void *master_data)
 {
                                                    ved);
 
        vimc_ent_sd_unregister(ved, &vsca->sd);
-       kfree(vsca);
 }
 
 
                                   MEDIA_ENT_F_PROC_VIDEO_SCALER, 2,
                                   (const unsigned long[2]) {MEDIA_PAD_FL_SINK,
                                   MEDIA_PAD_FL_SOURCE},
-                                  &vimc_sca_ops);
+                                  &vimc_sca_int_ops, &vimc_sca_ops);
        if (ret) {
                kfree(vsca);
                return ret;
 
        .s_ctrl = vimc_sen_s_ctrl,
 };
 
+static void vimc_sen_release(struct v4l2_subdev *sd)
+{
+       struct vimc_sen_device *vsen =
+                               container_of(sd, struct vimc_sen_device, sd);
+
+       v4l2_ctrl_handler_free(&vsen->hdl);
+       tpg_free(&vsen->tpg);
+       kfree(vsen);
+}
+
+static const struct v4l2_subdev_internal_ops vimc_sen_int_ops = {
+       .release = vimc_sen_release,
+};
+
 static void vimc_sen_comp_unbind(struct device *comp, struct device *master,
                                 void *master_data)
 {
                                container_of(ved, struct vimc_sen_device, ved);
 
        vimc_ent_sd_unregister(ved, &vsen->sd);
-       v4l2_ctrl_handler_free(&vsen->hdl);
-       tpg_free(&vsen->tpg);
-       kfree(vsen);
 }
 
 /* Image Processing Controls */
                                   pdata->entity_name,
                                   MEDIA_ENT_F_CAM_SENSOR, 1,
                                   (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE},
-                                  &vimc_sen_ops);
+                                  &vimc_sen_int_ops, &vimc_sen_ops);
        if (ret)
                goto err_free_hdl;