|
@@ -90,18 +90,13 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id)
|
|
|
|
|
|
id &= ~MEDIA_ENT_ID_FLAG_NEXT;
|
|
|
|
|
|
- spin_lock(&mdev->lock);
|
|
|
-
|
|
|
media_device_for_each_entity(entity, mdev) {
|
|
|
if (((media_entity_id(entity) == id) && !next) ||
|
|
|
((media_entity_id(entity) > id) && next)) {
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
return entity;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
-
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
@@ -431,6 +426,7 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
|
|
|
struct media_device *dev = to_media_device(devnode);
|
|
|
long ret;
|
|
|
|
|
|
+ mutex_lock(&dev->graph_mutex);
|
|
|
switch (cmd) {
|
|
|
case MEDIA_IOC_DEVICE_INFO:
|
|
|
ret = media_device_get_info(dev,
|
|
@@ -443,29 +439,24 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
|
|
|
break;
|
|
|
|
|
|
case MEDIA_IOC_ENUM_LINKS:
|
|
|
- mutex_lock(&dev->graph_mutex);
|
|
|
ret = media_device_enum_links(dev,
|
|
|
(struct media_links_enum __user *)arg);
|
|
|
- mutex_unlock(&dev->graph_mutex);
|
|
|
break;
|
|
|
|
|
|
case MEDIA_IOC_SETUP_LINK:
|
|
|
- mutex_lock(&dev->graph_mutex);
|
|
|
ret = media_device_setup_link(dev,
|
|
|
(struct media_link_desc __user *)arg);
|
|
|
- mutex_unlock(&dev->graph_mutex);
|
|
|
break;
|
|
|
|
|
|
case MEDIA_IOC_G_TOPOLOGY:
|
|
|
- mutex_lock(&dev->graph_mutex);
|
|
|
ret = media_device_get_topology(dev,
|
|
|
(struct media_v2_topology __user *)arg);
|
|
|
- mutex_unlock(&dev->graph_mutex);
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
ret = -ENOIOCTLCMD;
|
|
|
}
|
|
|
+ mutex_unlock(&dev->graph_mutex);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -590,12 +581,12 @@ int __must_check media_device_register_entity(struct media_device *mdev,
|
|
|
if (!ida_pre_get(&mdev->entity_internal_idx, GFP_KERNEL))
|
|
|
return -ENOMEM;
|
|
|
|
|
|
- spin_lock(&mdev->lock);
|
|
|
+ mutex_lock(&mdev->graph_mutex);
|
|
|
|
|
|
ret = ida_get_new_above(&mdev->entity_internal_idx, 1,
|
|
|
&entity->internal_idx);
|
|
|
if (ret < 0) {
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
+ mutex_unlock(&mdev->graph_mutex);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -615,9 +606,6 @@ int __must_check media_device_register_entity(struct media_device *mdev,
|
|
|
(notify)->notify(entity, notify->notify_data);
|
|
|
}
|
|
|
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
-
|
|
|
- mutex_lock(&mdev->graph_mutex);
|
|
|
if (mdev->entity_internal_idx_max
|
|
|
>= mdev->pm_count_walk.ent_enum.idx_max) {
|
|
|
struct media_entity_graph new = { .top = 0 };
|
|
@@ -680,9 +668,9 @@ void media_device_unregister_entity(struct media_entity *entity)
|
|
|
if (mdev == NULL)
|
|
|
return;
|
|
|
|
|
|
- spin_lock(&mdev->lock);
|
|
|
+ mutex_lock(&mdev->graph_mutex);
|
|
|
__media_device_unregister_entity(entity);
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
+ mutex_unlock(&mdev->graph_mutex);
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(media_device_unregister_entity);
|
|
|
|
|
@@ -703,7 +691,6 @@ void media_device_init(struct media_device *mdev)
|
|
|
INIT_LIST_HEAD(&mdev->pads);
|
|
|
INIT_LIST_HEAD(&mdev->links);
|
|
|
INIT_LIST_HEAD(&mdev->entity_notify);
|
|
|
- spin_lock_init(&mdev->lock);
|
|
|
mutex_init(&mdev->graph_mutex);
|
|
|
ida_init(&mdev->entity_internal_idx);
|
|
|
|
|
@@ -752,9 +739,9 @@ EXPORT_SYMBOL_GPL(__media_device_register);
|
|
|
int __must_check media_device_register_entity_notify(struct media_device *mdev,
|
|
|
struct media_entity_notify *nptr)
|
|
|
{
|
|
|
- spin_lock(&mdev->lock);
|
|
|
+ mutex_lock(&mdev->graph_mutex);
|
|
|
list_add_tail(&nptr->list, &mdev->entity_notify);
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
+ mutex_unlock(&mdev->graph_mutex);
|
|
|
return 0;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(media_device_register_entity_notify);
|
|
@@ -771,9 +758,9 @@ static void __media_device_unregister_entity_notify(struct media_device *mdev,
|
|
|
void media_device_unregister_entity_notify(struct media_device *mdev,
|
|
|
struct media_entity_notify *nptr)
|
|
|
{
|
|
|
- spin_lock(&mdev->lock);
|
|
|
+ mutex_lock(&mdev->graph_mutex);
|
|
|
__media_device_unregister_entity_notify(mdev, nptr);
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
+ mutex_unlock(&mdev->graph_mutex);
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(media_device_unregister_entity_notify);
|
|
|
|
|
@@ -787,11 +774,11 @@ void media_device_unregister(struct media_device *mdev)
|
|
|
if (mdev == NULL)
|
|
|
return;
|
|
|
|
|
|
- spin_lock(&mdev->lock);
|
|
|
+ mutex_lock(&mdev->graph_mutex);
|
|
|
|
|
|
/* Check if mdev was ever registered at all */
|
|
|
if (!media_devnode_is_registered(&mdev->devnode)) {
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
+ mutex_unlock(&mdev->graph_mutex);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -811,7 +798,7 @@ void media_device_unregister(struct media_device *mdev)
|
|
|
kfree(intf);
|
|
|
}
|
|
|
|
|
|
- spin_unlock(&mdev->lock);
|
|
|
+ mutex_unlock(&mdev->graph_mutex);
|
|
|
|
|
|
device_remove_file(&mdev->devnode.dev, &dev_attr_model);
|
|
|
media_devnode_unregister(&mdev->devnode);
|