Commit d10c9894 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Mauro Carvalho Chehab

[media] media: use entity.graph_obj.mdev instead of .parent

The struct media_entity has a .parent field that stores a pointer
to the parent struct media_device. But recently a media_gobj was
embedded into the entities and since struct media_gojb already has
a pointer to a struct media_device in the .mdev field, the .parent
field becomes redundant and can be removed.

This patch replaces all the usage of .parent by .graph_obj.mdev so
that field will become unused and can be removed on a later patch.

No functional changes.

The transformation was made using the following coccinelle spatch:

@@
struct media_entity *me;
@@

- me->parent
+ me->graph_obj.mdev

@@
struct media_entity *link;
@@

- link->source->entity->parent
+ link->source->entity->graph_obj.mdev

@@
struct exynos_video_entity *ve;
@@

- ve->vdev.entity.parent
+ ve->vdev.entity.graph_obj.mdev
Suggested-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 8df00a15
...@@ -435,8 +435,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, ...@@ -435,8 +435,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
int i; int i;
/* Warn if we apparently re-register an entity */ /* Warn if we apparently re-register an entity */
WARN_ON(entity->parent != NULL); WARN_ON(entity->graph_obj.mdev != NULL);
entity->parent = mdev; entity->graph_obj.mdev = mdev;
spin_lock(&mdev->lock); spin_lock(&mdev->lock);
/* Initialize media_gobj embedded at the entity */ /* Initialize media_gobj embedded at the entity */
...@@ -471,7 +471,7 @@ EXPORT_SYMBOL_GPL(media_device_register_entity); ...@@ -471,7 +471,7 @@ EXPORT_SYMBOL_GPL(media_device_register_entity);
void media_device_unregister_entity(struct media_entity *entity) void media_device_unregister_entity(struct media_entity *entity)
{ {
int i; int i;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
if (mdev == NULL) if (mdev == NULL)
return; return;
...@@ -484,7 +484,7 @@ void media_device_unregister_entity(struct media_entity *entity) ...@@ -484,7 +484,7 @@ void media_device_unregister_entity(struct media_entity *entity)
media_gobj_remove(&entity->graph_obj); media_gobj_remove(&entity->graph_obj);
list_del(&entity->list); list_del(&entity->list);
spin_unlock(&mdev->lock); spin_unlock(&mdev->lock);
entity->parent = NULL; entity->graph_obj.mdev = NULL;
} }
EXPORT_SYMBOL_GPL(media_device_unregister_entity); EXPORT_SYMBOL_GPL(media_device_unregister_entity);
......
...@@ -332,7 +332,7 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); ...@@ -332,7 +332,7 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
__must_check int media_entity_pipeline_start(struct media_entity *entity, __must_check int media_entity_pipeline_start(struct media_entity *entity,
struct media_pipeline *pipe) struct media_pipeline *pipe)
{ {
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph graph; struct media_entity_graph graph;
struct media_entity *entity_err = entity; struct media_entity *entity_err = entity;
int ret; int ret;
...@@ -387,7 +387,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, ...@@ -387,7 +387,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
ret = entity->ops->link_validate(link); ret = entity->ops->link_validate(link);
if (ret < 0 && ret != -ENOIOCTLCMD) { if (ret < 0 && ret != -ENOIOCTLCMD) {
dev_dbg(entity->parent->dev, dev_dbg(entity->graph_obj.mdev->dev,
"link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n", "link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n",
link->source->entity->name, link->source->entity->name,
link->source->index, link->source->index,
...@@ -401,7 +401,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, ...@@ -401,7 +401,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,
if (!bitmap_full(active, entity->num_pads)) { if (!bitmap_full(active, entity->num_pads)) {
ret = -EPIPE; ret = -EPIPE;
dev_dbg(entity->parent->dev, dev_dbg(entity->graph_obj.mdev->dev,
"\"%s\":%u must be connected by an enabled link\n", "\"%s\":%u must be connected by an enabled link\n",
entity->name, entity->name,
(unsigned)find_first_zero_bit( (unsigned)find_first_zero_bit(
...@@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start); ...@@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
*/ */
void media_entity_pipeline_stop(struct media_entity *entity) void media_entity_pipeline_stop(struct media_entity *entity)
{ {
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
struct media_entity_graph graph; struct media_entity_graph graph;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
...@@ -490,8 +490,8 @@ struct media_entity *media_entity_get(struct media_entity *entity) ...@@ -490,8 +490,8 @@ struct media_entity *media_entity_get(struct media_entity *entity)
if (entity == NULL) if (entity == NULL)
return NULL; return NULL;
if (entity->parent->dev && if (entity->graph_obj.mdev->dev &&
!try_module_get(entity->parent->dev->driver->owner)) !try_module_get(entity->graph_obj.mdev->dev->driver->owner))
return NULL; return NULL;
return entity; return entity;
...@@ -511,8 +511,8 @@ void media_entity_put(struct media_entity *entity) ...@@ -511,8 +511,8 @@ void media_entity_put(struct media_entity *entity)
if (entity == NULL) if (entity == NULL)
return; return;
if (entity->parent->dev) if (entity->graph_obj.mdev->dev)
module_put(entity->parent->dev->driver->owner); module_put(entity->graph_obj.mdev->dev->driver->owner);
} }
EXPORT_SYMBOL_GPL(media_entity_put); EXPORT_SYMBOL_GPL(media_entity_put);
...@@ -561,7 +561,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, ...@@ -561,7 +561,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
link->flags = flags; link->flags = flags;
/* Initialize graph object embedded at the new link */ /* Initialize graph object embedded at the new link */
media_gobj_init(source->parent, MEDIA_GRAPH_LINK, &link->graph_obj); media_gobj_init(source->graph_obj.mdev, MEDIA_GRAPH_LINK,
&link->graph_obj);
/* Create the backlink. Backlinks are used to help graph traversal and /* Create the backlink. Backlinks are used to help graph traversal and
* are not reported to userspace. * are not reported to userspace.
...@@ -577,7 +578,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, ...@@ -577,7 +578,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
backlink->flags = flags; backlink->flags = flags;
/* Initialize graph object embedded at the new link */ /* Initialize graph object embedded at the new link */
media_gobj_init(sink->parent, MEDIA_GRAPH_LINK, &backlink->graph_obj); media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
&backlink->graph_obj);
link->reverse = backlink; link->reverse = backlink;
backlink->reverse = link; backlink->reverse = link;
...@@ -629,12 +631,12 @@ EXPORT_SYMBOL_GPL(__media_entity_remove_links); ...@@ -629,12 +631,12 @@ EXPORT_SYMBOL_GPL(__media_entity_remove_links);
void media_entity_remove_links(struct media_entity *entity) void media_entity_remove_links(struct media_entity *entity)
{ {
/* Do nothing if the entity is not registered. */ /* Do nothing if the entity is not registered. */
if (entity->parent == NULL) if (entity->graph_obj.mdev == NULL)
return; return;
mutex_lock(&entity->parent->graph_mutex); mutex_lock(&entity->graph_obj.mdev->graph_mutex);
__media_entity_remove_links(entity); __media_entity_remove_links(entity);
mutex_unlock(&entity->parent->graph_mutex); mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
} }
EXPORT_SYMBOL_GPL(media_entity_remove_links); EXPORT_SYMBOL_GPL(media_entity_remove_links);
...@@ -703,7 +705,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags) ...@@ -703,7 +705,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
(source->stream_count || sink->stream_count)) (source->stream_count || sink->stream_count))
return -EBUSY; return -EBUSY;
mdev = source->parent; mdev = source->graph_obj.mdev;
if (mdev->link_notify) { if (mdev->link_notify) {
ret = mdev->link_notify(link, flags, ret = mdev->link_notify(link, flags,
...@@ -724,9 +726,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags) ...@@ -724,9 +726,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags)
{ {
int ret; int ret;
mutex_lock(&link->source->entity->parent->graph_mutex); mutex_lock(&link->source->entity->graph_obj.mdev->graph_mutex);
ret = __media_entity_setup_link(link, flags); ret = __media_entity_setup_link(link, flags);
mutex_unlock(&link->source->entity->parent->graph_mutex); mutex_unlock(&link->source->entity->graph_obj.mdev->graph_mutex);
return ret; return ret;
} }
......
...@@ -287,7 +287,7 @@ static int isp_video_open(struct file *file) ...@@ -287,7 +287,7 @@ static int isp_video_open(struct file *file)
goto rel_fh; goto rel_fh;
if (v4l2_fh_is_singular_file(file)) { if (v4l2_fh_is_singular_file(file)) {
mutex_lock(&me->parent->graph_mutex); mutex_lock(&me->graph_obj.mdev->graph_mutex);
ret = fimc_pipeline_call(ve, open, me, true); ret = fimc_pipeline_call(ve, open, me, true);
...@@ -295,7 +295,7 @@ static int isp_video_open(struct file *file) ...@@ -295,7 +295,7 @@ static int isp_video_open(struct file *file)
if (ret == 0) if (ret == 0)
me->use_count++; me->use_count++;
mutex_unlock(&me->parent->graph_mutex); mutex_unlock(&me->graph_obj.mdev->graph_mutex);
} }
if (!ret) if (!ret)
goto unlock; goto unlock;
...@@ -311,7 +311,7 @@ static int isp_video_release(struct file *file) ...@@ -311,7 +311,7 @@ static int isp_video_release(struct file *file)
struct fimc_isp *isp = video_drvdata(file); struct fimc_isp *isp = video_drvdata(file);
struct fimc_is_video *ivc = &isp->video_capture; struct fimc_is_video *ivc = &isp->video_capture;
struct media_entity *entity = &ivc->ve.vdev.entity; struct media_entity *entity = &ivc->ve.vdev.entity;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
mutex_lock(&isp->video_lock); mutex_lock(&isp->video_lock);
......
...@@ -494,7 +494,7 @@ static int fimc_lite_open(struct file *file) ...@@ -494,7 +494,7 @@ static int fimc_lite_open(struct file *file)
atomic_read(&fimc->out_path) != FIMC_IO_DMA) atomic_read(&fimc->out_path) != FIMC_IO_DMA)
goto unlock; goto unlock;
mutex_lock(&me->parent->graph_mutex); mutex_lock(&me->graph_obj.mdev->graph_mutex);
ret = fimc_pipeline_call(&fimc->ve, open, me, true); ret = fimc_pipeline_call(&fimc->ve, open, me, true);
...@@ -502,7 +502,7 @@ static int fimc_lite_open(struct file *file) ...@@ -502,7 +502,7 @@ static int fimc_lite_open(struct file *file)
if (ret == 0) if (ret == 0)
me->use_count++; me->use_count++;
mutex_unlock(&me->parent->graph_mutex); mutex_unlock(&me->graph_obj.mdev->graph_mutex);
if (!ret) { if (!ret) {
fimc_lite_clear_event_counters(fimc); fimc_lite_clear_event_counters(fimc);
...@@ -535,9 +535,9 @@ static int fimc_lite_release(struct file *file) ...@@ -535,9 +535,9 @@ static int fimc_lite_release(struct file *file)
fimc_pipeline_call(&fimc->ve, close); fimc_pipeline_call(&fimc->ve, close);
clear_bit(ST_FLITE_IN_USE, &fimc->state); clear_bit(ST_FLITE_IN_USE, &fimc->state);
mutex_lock(&entity->parent->graph_mutex); mutex_lock(&entity->graph_obj.mdev->graph_mutex);
entity->use_count--; entity->use_count--;
mutex_unlock(&entity->parent->graph_mutex); mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
} }
_vb2_fop_release(file, NULL); _vb2_fop_release(file, NULL);
......
...@@ -1046,7 +1046,7 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable) ...@@ -1046,7 +1046,7 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable)
return ret; return ret;
} }
/* Locking: called with entity->parent->graph_mutex mutex held. */ /* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */
static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)
{ {
struct media_entity *entity_err = entity; struct media_entity *entity_err = entity;
......
...@@ -164,8 +164,8 @@ struct fimc_sensor_info *source_to_sensor_info(struct fimc_source_info *si) ...@@ -164,8 +164,8 @@ struct fimc_sensor_info *source_to_sensor_info(struct fimc_source_info *si)
static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me) static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
{ {
return me->parent == NULL ? NULL : return me->graph_obj.mdev == NULL ? NULL :
container_of(me->parent, struct fimc_md, media_dev); container_of(me->graph_obj.mdev, struct fimc_md, media_dev);
} }
static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n) static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n)
...@@ -175,12 +175,12 @@ static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n) ...@@ -175,12 +175,12 @@ static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n)
static inline void fimc_md_graph_lock(struct exynos_video_entity *ve) static inline void fimc_md_graph_lock(struct exynos_video_entity *ve)
{ {
mutex_lock(&ve->vdev.entity.parent->graph_mutex); mutex_lock(&ve->vdev.entity.graph_obj.mdev->graph_mutex);
} }
static inline void fimc_md_graph_unlock(struct exynos_video_entity *ve) static inline void fimc_md_graph_unlock(struct exynos_video_entity *ve)
{ {
mutex_unlock(&ve->vdev.entity.parent->graph_mutex); mutex_unlock(&ve->vdev.entity.graph_obj.mdev->graph_mutex);
} }
int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on); int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
......
...@@ -787,7 +787,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) ...@@ -787,7 +787,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
int change = use ? 1 : -1; int change = use ? 1 : -1;
int ret; int ret;
mutex_lock(&entity->parent->graph_mutex); mutex_lock(&entity->graph_obj.mdev->graph_mutex);
/* Apply use count to node. */ /* Apply use count to node. */
entity->use_count += change; entity->use_count += change;
...@@ -798,7 +798,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) ...@@ -798,7 +798,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
if (ret < 0) if (ret < 0)
entity->use_count -= change; entity->use_count -= change;
mutex_unlock(&entity->parent->graph_mutex); mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
return ret; return ret;
} }
......
...@@ -226,7 +226,7 @@ static int isp_video_get_graph_data(struct isp_video *video, ...@@ -226,7 +226,7 @@ static int isp_video_get_graph_data(struct isp_video *video,
{ {
struct media_entity_graph graph; struct media_entity_graph graph;
struct media_entity *entity = &video->video.entity; struct media_entity *entity = &video->video.entity;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
struct isp_video *far_end = NULL; struct isp_video *far_end = NULL;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
......
...@@ -380,7 +380,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, ...@@ -380,7 +380,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
{ {
struct media_entity_graph graph; struct media_entity_graph graph;
struct media_entity *entity = &video->video.entity; struct media_entity *entity = &video->video.entity;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
unsigned int i; unsigned int i;
int ret; int ret;
......
...@@ -181,7 +181,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, ...@@ -181,7 +181,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe,
{ {
struct media_entity_graph graph; struct media_entity_graph graph;
struct media_entity *entity = &start->video.entity; struct media_entity *entity = &start->video.entity;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
unsigned int num_inputs = 0; unsigned int num_inputs = 0;
unsigned int num_outputs = 0; unsigned int num_outputs = 0;
......
...@@ -130,7 +130,7 @@ __vpfe_video_get_format(struct vpfe_video_device *video, ...@@ -130,7 +130,7 @@ __vpfe_video_get_format(struct vpfe_video_device *video,
static void vpfe_prepare_pipeline(struct vpfe_video_device *video) static void vpfe_prepare_pipeline(struct vpfe_video_device *video)
{ {
struct media_entity *entity = &video->video_dev.entity; struct media_entity *entity = &video->video_dev.entity;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
struct vpfe_pipeline *pipe = &video->pipe; struct vpfe_pipeline *pipe = &video->pipe;
struct vpfe_video_device *far_end = NULL; struct vpfe_video_device *far_end = NULL;
struct media_entity_graph graph; struct media_entity_graph graph;
...@@ -288,7 +288,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) ...@@ -288,7 +288,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
else else
entity = &pipe->inputs[0]->video_dev.entity; entity = &pipe->inputs[0]->video_dev.entity;
mdev = entity->parent; mdev = entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
media_entity_graph_walk_start(&graph, entity); media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) { while ((entity = media_entity_graph_walk_next(&graph))) {
...@@ -328,7 +328,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) ...@@ -328,7 +328,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
else else
entity = &pipe->inputs[0]->video_dev.entity; entity = &pipe->inputs[0]->video_dev.entity;
mdev = entity->parent; mdev = entity->graph_obj.mdev;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
media_entity_graph_walk_start(&graph, entity); media_entity_graph_walk_start(&graph, entity);
......
...@@ -494,7 +494,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) ...@@ -494,7 +494,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)
int change = use ? 1 : -1; int change = use ? 1 : -1;
int ret; int ret;
mutex_lock(&entity->parent->graph_mutex); mutex_lock(&entity->graph_obj.mdev->graph_mutex);
/* Apply use count to node. */ /* Apply use count to node. */
entity->use_count += change; entity->use_count += change;
...@@ -505,7 +505,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) ...@@ -505,7 +505,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use)
if (ret < 0) if (ret < 0)
entity->use_count -= change; entity->use_count -= change;
mutex_unlock(&entity->parent->graph_mutex); mutex_unlock(&entity->graph_obj.mdev->graph_mutex);
return ret; return ret;
} }
......
...@@ -206,7 +206,7 @@ iss_video_far_end(struct iss_video *video) ...@@ -206,7 +206,7 @@ iss_video_far_end(struct iss_video *video)
{ {
struct media_entity_graph graph; struct media_entity_graph graph;
struct media_entity *entity = &video->video.entity; struct media_entity *entity = &video->video.entity;
struct media_device *mdev = entity->parent; struct media_device *mdev = entity->graph_obj.mdev;
struct iss_video *far_end = NULL; struct iss_video *far_end = NULL;
mutex_lock(&mdev->graph_mutex); mutex_lock(&mdev->graph_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment