diff options
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-async.c | 26 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls.c | 3 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-device.c | 2 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-event.c | 5 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-fh.c | 5 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-mc.c | 44 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-of.c | 13 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-subdev.c | 4 |
8 files changed, 57 insertions, 45 deletions
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 5bada202b2d3..96cc733f35ef 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd, static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { - return sd->of_node == asd->match.of.node; + return !of_node_cmp(of_node_full_name(sd->of_node), + of_node_full_name(asd->match.of.node)); } static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) @@ -99,18 +100,11 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier, { int ret; - /* Remove from the waiting list */ - list_del(&asd->list); - sd->asd = asd; - sd->notifier = notifier; - if (notifier->bound) { ret = notifier->bound(notifier, sd, asd); if (ret < 0) return ret; } - /* Move from the global subdevice list to notifier's done */ - list_move(&sd->async_list, ¬ifier->done); ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd); if (ret < 0) { @@ -119,6 +113,14 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier, return ret; } + /* Remove from the waiting list */ + list_del(&asd->list); + sd->asd = asd; + sd->notifier = notifier; + + /* Move from the global subdevice list to notifier's done */ + list_move(&sd->async_list, ¬ifier->done); + if (list_empty(¬ifier->waiting) && notifier->complete) return notifier->complete(notifier); @@ -168,9 +170,6 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, mutex_lock(&list_lock); - /* Keep also completed notifiers on the list */ - list_add(¬ifier->list, ¬ifier_list); - list_for_each_entry_safe(sd, tmp, &subdev_list, async_list) { int ret; @@ -185,6 +184,9 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, } } + /* Keep also completed notifiers on the list */ + list_add(¬ifier->list, ¬ifier_list); + mutex_unlock(&list_lock); return 0; @@ -202,7 +204,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier) if (!notifier->v4l2_dev) return; - dev = kmalloc(n_subdev * sizeof(*dev), GFP_KERNEL); + dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL); if (!dev) { dev_err(notifier->v4l2_dev->dev, "Failed to allocate device cache!\n"); diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 47001e25fd9e..b9e08e3d6e0e 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3367,6 +3367,9 @@ static void v4l2_ctrl_del_event(struct v4l2_subscribed_event *sev) { struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); + if (ctrl == NULL) + return; + v4l2_ctrl_lock(ctrl); list_del(&sev->node); v4l2_ctrl_unlock(ctrl); diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 62bbed76dbbc..f364cc1b521d 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -253,6 +253,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) kfree(vdev); goto clean_up; } + sd->devnode = vdev; #if defined(CONFIG_MEDIA_CONTROLLER) sd->entity.info.dev.major = VIDEO_MAJOR; sd->entity.info.dev.minor = vdev->minor; @@ -270,7 +271,6 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) } } #endif - sd->devnode = vdev; } return 0; diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c index 8d3171c6bee8..a75df6cb141f 100644 --- a/drivers/media/v4l2-core/v4l2-event.c +++ b/drivers/media/v4l2-core/v4l2-event.c @@ -15,11 +15,6 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA */ #include <media/v4l2-dev.h> diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c index c183f0996fa1..3895999bf880 100644 --- a/drivers/media/v4l2-core/v4l2-fh.c +++ b/drivers/media/v4l2-core/v4l2-fh.c @@ -15,11 +15,6 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA */ #include <linux/bitops.h> diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 8bef4331bd51..303980b71aae 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -198,14 +198,20 @@ EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph); int v4l_enable_media_source(struct video_device *vdev) { struct media_device *mdev = vdev->entity.graph_obj.mdev; - int ret; + int ret = 0, err; - if (!mdev || !mdev->enable_source) + if (!mdev) return 0; - ret = mdev->enable_source(&vdev->entity, &vdev->pipe); - if (ret) - return -EBUSY; - return 0; + + mutex_lock(&mdev->graph_mutex); + if (!mdev->enable_source) + goto end; + err = mdev->enable_source(&vdev->entity, &vdev->pipe); + if (err) + ret = -EBUSY; +end: + mutex_unlock(&mdev->graph_mutex); + return ret; } EXPORT_SYMBOL_GPL(v4l_enable_media_source); @@ -213,8 +219,12 @@ void v4l_disable_media_source(struct video_device *vdev) { struct media_device *mdev = vdev->entity.graph_obj.mdev; - if (mdev && mdev->disable_source) - mdev->disable_source(&vdev->entity); + if (mdev) { + mutex_lock(&mdev->graph_mutex); + if (mdev->disable_source) + mdev->disable_source(&vdev->entity); + mutex_unlock(&mdev->graph_mutex); + } } EXPORT_SYMBOL_GPL(v4l_disable_media_source); @@ -256,13 +266,13 @@ EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source); * Return the total number of users of all video device nodes in the pipeline. */ static int pipeline_pm_use_count(struct media_entity *entity, - struct media_entity_graph *graph) + struct media_graph *graph) { int use = 0; - media_entity_graph_walk_start(graph, entity); + media_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(graph))) { + while ((entity = media_graph_walk_next(graph))) { if (is_media_entity_v4l2_video_device(entity)) use += entity->use_count; } @@ -315,7 +325,7 @@ static int pipeline_pm_power_one(struct media_entity *entity, int change) * Return 0 on success or a negative error code on failure. */ static int pipeline_pm_power(struct media_entity *entity, int change, - struct media_entity_graph *graph) + struct media_graph *graph) { struct media_entity *first = entity; int ret = 0; @@ -323,18 +333,18 @@ static int pipeline_pm_power(struct media_entity *entity, int change, if (!change) return 0; - media_entity_graph_walk_start(graph, entity); + media_graph_walk_start(graph, entity); - while (!ret && (entity = media_entity_graph_walk_next(graph))) + while (!ret && (entity = media_graph_walk_next(graph))) if (is_media_entity_v4l2_subdev(entity)) ret = pipeline_pm_power_one(entity, change); if (!ret) return ret; - media_entity_graph_walk_start(graph, first); + media_graph_walk_start(graph, first); - while ((first = media_entity_graph_walk_next(graph)) + while ((first = media_graph_walk_next(graph)) && first != entity) if (is_media_entity_v4l2_subdev(first)) pipeline_pm_power_one(first, -change); @@ -368,7 +378,7 @@ EXPORT_SYMBOL_GPL(v4l2_pipeline_pm_use); int v4l2_pipeline_link_notify(struct media_link *link, u32 flags, unsigned int notification) { - struct media_entity_graph *graph = &link->graph_obj.mdev->pm_count_walk; + struct media_graph *graph = &link->graph_obj.mdev->pm_count_walk; struct media_entity *source = link->source->entity; struct media_entity *sink = link->sink->entity; int source_use; diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c index 93b33681776c..4f59f442dd0a 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2; struct property *prop; bool have_clk_lane = false; - unsigned int flags = 0; + unsigned int flags = 0, lanes_used = 0; u32 v; prop = of_find_property(node, "data-lanes", NULL); @@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, lane = of_prop_next_u32(prop, lane, &v); if (!lane) break; + + if (lanes_used & BIT(v)) + pr_warn("%s: duplicated lane %u in data-lanes\n", + node->full_name, v); + lanes_used |= BIT(v); + bus->data_lanes[i] = v; } bus->num_data_lanes = i; @@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, } if (!of_property_read_u32(node, "clock-lanes", &v)) { + if (lanes_used & BIT(v)) + pr_warn("%s: duplicated lane %u in clock-lanes\n", + node->full_name, v); + lanes_used |= BIT(v); + bus->clock_lane = v; have_clk_lane = true; } diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 34a1e7c8b306..da78497ae5ed 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -14,10 +14,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/ioctl.h> |