From patchwork Thu Oct 26 07:53:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 10027601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 507646032C for ; Thu, 26 Oct 2017 07:54:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 413FE27F98 for ; Thu, 26 Oct 2017 07:54:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3652F2851E; Thu, 26 Oct 2017 07:54:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B615727F98 for ; Thu, 26 Oct 2017 07:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932327AbdJZHyh (ORCPT ); Thu, 26 Oct 2017 03:54:37 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:39220 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932284AbdJZHyc (ORCPT ); Thu, 26 Oct 2017 03:54:32 -0400 Received: from lanttu.localdomain (unknown [IPv6:2001:1bc8:1a6:d3d5::e1:1002]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id B8444600EF; Thu, 26 Oct 2017 10:54:28 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: niklas.soderlund@ragnatech.se, maxime.ripard@free-electrons.com, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, pavel@ucw.cz, sre@kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v16 16/32] v4l: async: Allow async notifier register call succeed with no subdevs Date: Thu, 26 Oct 2017 10:53:26 +0300 Message-Id: <20171026075342.5760-17-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171026075342.5760-1-sakari.ailus@linux.intel.com> References: <20171026075342.5760-1-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The information on how many async sub-devices would be bindable to a notifier is typically dependent on information from platform firmware and it's not driver's business to be aware of that. Many V4L2 main drivers are perfectly usable (and useful) without async sub-devices and so if there aren't any around, just proceed call the notifier's complete callback immediately without registering the notifier itself. If a driver needs to check whether there are async sub-devices available, it can be done by inspecting the notifier's num_subdevs field which tells the number of async sub-devices. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil Acked-by: Niklas Söderlund Reviewed-by: Sebastian Reichel --- drivers/media/v4l2-core/v4l2-async.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 46db85685894..1b536d68cedf 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -180,14 +180,22 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, int ret; int i; - if (!v4l2_dev || !notifier->num_subdevs || - notifier->num_subdevs > V4L2_MAX_SUBDEVS) + if (!v4l2_dev || notifier->num_subdevs > V4L2_MAX_SUBDEVS) return -EINVAL; notifier->v4l2_dev = v4l2_dev; INIT_LIST_HEAD(¬ifier->waiting); INIT_LIST_HEAD(¬ifier->done); + if (!notifier->num_subdevs) { + int ret; + + ret = v4l2_async_notifier_call_complete(notifier); + notifier->v4l2_dev = NULL; + + return ret; + } + for (i = 0; i < notifier->num_subdevs; i++) { asd = notifier->subdevs[i];