From patchwork Tue Sep 4 11:30:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 51859 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fx9Xd-0002ce-PY; Tue, 04 Sep 2018 11:30:42 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbeIDPzQ (ORCPT + 1 other); Tue, 4 Sep 2018 11:55:16 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36204 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbeIDPzQ (ORCPT ); Tue, 4 Sep 2018 11:55:16 -0400 Received: by mail-wr1-f68.google.com with SMTP id m27-v6so3603184wrf.3 for ; Tue, 04 Sep 2018 04:30:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WB1TW8MQOIIaVMO7optC93NOQh2/hSLfCLv/mRuXx44=; b=DQPks2Rkh9HCUA4TqYYnuRJV54fvp1GBOvVSc8OsPVBgEpcYQ3wBrIqWuyWhYdO07P zPDlWEt3efE+VxULxv8awiiRfGUN/165dP3nEeyVk9lUMVFE8zBt5CSUd2CokcnKCyso UQQIlhQ0w5LRmxexlJ2A2uw95JdlD4zKZOrgSO9KhFtPrn6ueE8uxnOTRDPCi2RzBOfA 3u2ryzngmEm+QW8wEu5d5RtmJ/pqW6ZyadJLQzPbTs9MA4WTCyjEdud0O45B4BqnAc9z PoqTS61EpKuX6EG7nisijXzi8UP1LfCBOKLOzSFDBPy7I2geH5ElaBrc0X7W1pMdQg8d FExQ== X-Gm-Message-State: APzg51BApZ2Fc2PCvAnIVqR1mr7jo+a5SS+KQmLNik1+x8it9QPuGb5h GoJ8R5THjSHiMmyjk2xpYUo9Ng== X-Google-Smtp-Source: ANB0Vdbmar8GK3LUlZBYm4tyYeRy6GpHPDvYprvgxx6IQ0TQ0XBmYbPkCHo25inwAWGOJ1VgLigsZg== X-Received: by 2002:adf:959a:: with SMTP id p26-v6mr15660808wrp.202.1536060631528; Tue, 04 Sep 2018 04:30:31 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id s13-v6sm22574155wrq.39.2018.09.04.04.30.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Sep 2018 04:30:31 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Tian Shu Qiu , Sakari Ailus , Javier Martinez Canillas , Mauro Carvalho Chehab , Jian Xu Zheng , Yong Zhi , Bingbu Cao , linux-media@vger.kernel.org Subject: [PATCH 2/2] media: intel-ipu3: create pad links and register subdev nodes at bound time Date: Tue, 4 Sep 2018 13:30:18 +0200 Message-Id: <20180904113018.14428-3-javierm@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180904113018.14428-1-javierm@redhat.com> References: <20180904113018.14428-1-javierm@redhat.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The driver create the pad links and registers the device nodes for bound subdevices in the v4l2 async notififer .complete callback. But that will prevent the media graph to be usable if for example one of the drivers for a subdevice fails to probe. In that case, the media entity will be registered but there will be not pad links created nor the subdev device node will be registered. So do these operations in the .bound callback instead of doing it at .complete time. Signed-off-by: Javier Martinez Canillas --- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 66 ++++++++---------------- 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 29027159eced..4eb80b690e3f 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1403,6 +1403,8 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier, struct sensor_async_subdev *s_asd = container_of(asd, struct sensor_async_subdev, asd); struct cio2_queue *q; + unsigned int pad; + int ret; if (cio2->queue[s_asd->csi2.port].sensor) return -EBUSY; @@ -1413,7 +1415,26 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier, q->sensor = sd; q->csi_rx_base = cio2->base + CIO2_REG_PIPE_BASE(q->csi2.port); - return 0; + for (pad = 0; pad < q->sensor->entity.num_pads; pad++) + if (q->sensor->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE) + break; + + if (pad == q->sensor->entity.num_pads) { + dev_err(&cio2->pci_dev->dev, + "failed to find src pad for %s\n", + q->sensor->name); + return -ENXIO; + } + + ret = media_create_pad_link(&q->sensor->entity, pad, &q->subdev.entity, + CIO2_PAD_SINK, 0); + if (ret) { + dev_err(&cio2->pci_dev->dev, "failed to create link for %s\n", + q->sensor->name); + return ret; + } + + return v4l2_device_register_subdev_node(&cio2->v4l2_dev, sd); } /* The .unbind callback */ @@ -1429,52 +1450,9 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier, cio2->queue[s_asd->csi2.port].sensor = NULL; } -/* .complete() is called after all subdevices have been located */ -static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) -{ - struct cio2_device *cio2 = container_of(notifier, struct cio2_device, - notifier); - struct sensor_async_subdev *s_asd; - struct cio2_queue *q; - unsigned int i, pad; - int ret; - - for (i = 0; i < notifier->num_subdevs; i++) { - s_asd = container_of(cio2->notifier.subdevs[i], - struct sensor_async_subdev, asd); - q = &cio2->queue[s_asd->csi2.port]; - - for (pad = 0; pad < q->sensor->entity.num_pads; pad++) - if (q->sensor->entity.pads[pad].flags & - MEDIA_PAD_FL_SOURCE) - break; - - if (pad == q->sensor->entity.num_pads) { - dev_err(&cio2->pci_dev->dev, - "failed to find src pad for %s\n", - q->sensor->name); - return -ENXIO; - } - - ret = media_create_pad_link( - &q->sensor->entity, pad, - &q->subdev.entity, CIO2_PAD_SINK, - 0); - if (ret) { - dev_err(&cio2->pci_dev->dev, - "failed to create link for %s\n", - cio2->queue[i].sensor->name); - return ret; - } - } - - return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev); -} - static const struct v4l2_async_notifier_operations cio2_async_ops = { .bound = cio2_notifier_bound, .unbind = cio2_notifier_unbind, - .complete = cio2_notifier_complete, }; static int cio2_fwnode_parse(struct device *dev,