From patchwork Mon Apr 15 14:22:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2445331 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 812E1DFF66 for ; Mon, 15 Apr 2013 14:23:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751896Ab3DOOXX (ORCPT ); Mon, 15 Apr 2013 10:23:23 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:49331 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022Ab3DOOXV (ORCPT ); Mon, 15 Apr 2013 10:23:21 -0400 Received: by mail-wg0-f47.google.com with SMTP id j13so2223329wgh.2 for ; Mon, 15 Apr 2013 07:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Jqw2voVcUaKFH54Wj06Vq0MXtmKuWotvPfRH3rQ7gsU=; b=QfSLnXbvV90JGvhg0/ILDTsAGXXKZBbF0WsH/kIxqpl6uIr1P20wqPKntkf+i4LVFi grPfMclnzyWtPPOxr09+YlTRZzjx9QYnaER6fz2yBx7z56pit83RmKu4IhyH9aWVKCtH z3UYE0NaKoWNY1LXfjDWy+8IfG38dCj1LQYYQn0AAi89FdO0gEnMB0Wbgarjwg7L7wJc 7B3lgM2465eYrYkJX/zT2wVsTeKbIx8vMQj95pmHnY3sW8xmk9ggGXqYbvJ2r04tKMeu Nqpkww2ZZdQyGZ2inxIvXeZnF0spn3Jf7Lf/yXtxjUsDF8nl6xwZn0BZN0Biyr2/2NpB OQkg== X-Received: by 10.180.73.228 with SMTP id o4mr3898392wiv.12.1366035799738; Mon, 15 Apr 2013 07:23:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.143.20 with HTTP; Mon, 15 Apr 2013 07:22:58 -0700 (PDT) In-Reply-To: <1365781240-16149-3-git-send-email-g.liakhovetski@gmx.de> References: <1365781240-16149-1-git-send-email-g.liakhovetski@gmx.de> <1365781240-16149-3-git-send-email-g.liakhovetski@gmx.de> From: Prabhakar Lad Date: Mon, 15 Apr 2013 19:52:58 +0530 Message-ID: Subject: Re: [PATCH v9 02/20] V4L2: support asynchronous subdevice registration To: Guennadi Liakhovetski Cc: linux-media@vger.kernel.org, Sylwester Nawrocki , Laurent Pinchart , Hans Verkuil , linux-sh@vger.kernel.org, Magnus Damm , Sakari Ailus , Prabhakar Lad Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Hi Guennadi, On Fri, Apr 12, 2013 at 9:10 PM, Guennadi Liakhovetski wrote: > Currently bridge device drivers register devices for all subdevices > synchronously, tupically, during their probing. E.g. if an I2C CMOS sensor > is attached to a video bridge device, the bridge driver will create an I2C > device and wait for the respective I2C driver to probe. This makes linking > of devices straight forward, but this approach cannot be used with > intrinsically asynchronous and unordered device registration systems like > the Flattened Device Tree. To support such systems this patch adds an > asynchronous subdevice registration framework to V4L2. To use it respective > (e.g. I2C) subdevice drivers must register themselves with the framework. > A bridge driver on the other hand must register notification callbacks, > that will be called upon various related events. > > Signed-off-by: Guennadi Liakhovetski > --- > > v9: addressed Laurent's comments (thanks) > 1. moved valid hw->bus_type check > 2. made v4l2_async_unregister() void > 3. renamed struct v4l2_async_hw_device to struct v4l2_async_hw_info > 4. merged struct v4l2_async_subdev_list into struct v4l2_subdev > 5. fixed a typo > 6. made subdev_num unsigned > > drivers/media/v4l2-core/Makefile | 3 +- > drivers/media/v4l2-core/v4l2-async.c | 284 ++++++++++++++++++++++++++++++++++ > include/media/v4l2-async.h | 99 ++++++++++++ > include/media/v4l2-subdev.h | 10 ++ > 4 files changed, 395 insertions(+), 1 deletions(-) > create mode 100644 drivers/media/v4l2-core/v4l2-async.c > create mode 100644 include/media/v4l2-async.h Cant wait until its stable, so thought of fixing it! Finally I removed some spare time to fix the issue which i was being pointing from past so many versions. What was happening is bound() callback was being called for the bridge driver for every subdevice in the subdevlist. This should not happen the bound callback in the bridge driver should only be called only if the interested subdev is present in subdev list. Following is the fix for it. Regards, --Prabhakar Lad list_del(&asd->list); --- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 98db2e0..d817cda 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -83,7 +83,20 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev_list *asdl, struct v4l2_async_subdev *asd) { - int ret; + int ret, i, found = 0; + + /* scan through the waiting list and see if the async + * subdev is present in it. + */ + for (i = 0; i < notifier->subdev_num; i++) { + if (asd == notifier->subdev[i]) { + found = 1; + break; + } + } + /* The async subdev 'asd' is not intrseted by waiting list */ + if (!found) + return 0; /* Remove from the waiting list */