Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2434233imm; Tue, 4 Sep 2018 04:31:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY73RotOjY1XO9/jJNxCjX1HTLf0gSLyup476XjXVL9AxSWa+JqV32zyBD9/3HoE+5ND+1x X-Received: by 2002:a62:a05:: with SMTP id s5-v6mr34895869pfi.147.1536060717456; Tue, 04 Sep 2018 04:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536060717; cv=none; d=google.com; s=arc-20160816; b=Ks3OHIRqmv4qChX1/E6tgunIpyi4oPKlACS+BZ3DiNoeIT1NPqtoVMQ/CfPq7I0IPR i+eMUHPHQzGroO2JFNlBWYqBFUHSdMaBTNm8Orqc9cpIKU2Pqxg+7Dc2YQ8uc2Lfju17 RvdmpBkUSghAYwd7Q8XQ0BcSgJ3IJh55g4MThfboOfJVfRqYKn5pwsrFtVc4IdUIk3lA FCdvuzrYeggKU7dX1g0A+0T+7sZA3MIGm8I2P2brhjvJDwCurgHLgZeZX175Sn2PI3QR G6do9RqGLwIqkTGvQhPUcKF6NzMn3oQLmM5jPlgBu94fTcByLGodMNYvMwaTHc/+2gWt UEiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WB1TW8MQOIIaVMO7optC93NOQh2/hSLfCLv/mRuXx44=; b=bxLqf+7uZ/sSFKRzZMYWWZexqYNY3JkTG48KcpRD+1YVKpQN1kIxwCfUxWmLJ9KTn3 UoSj9XMpRqbV2qy5Bgqy0H9ouL1MuEphz57DOiaeQ2Qg9iOAY28dtPsl2LE7mRWXIqeE DcGfgQ/Dw4VIyEvQ8aRwabGTTzE+dXpMc2Et2on3bQ3nlzn5g4XCGw94MzqzkMfdI70R uhk74lEj6BQIL2pu96jV4GTUZzoOFkB1TJ4jv30YB+/7y15aS2L6B3AABodFKKf5EgUf AAzitXB0ltJIYUnRKl2aoFg4yscGX0WRZc2fsJ73zpg4F5N5cEa+qNcSJFjMP8ZoXHFu dY4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z123-v6si23723334pfc.289.2018.09.04.04.31.42; Tue, 04 Sep 2018 04:31:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727154AbeIDPzQ (ORCPT + 99 others); Tue, 4 Sep 2018 11:55:16 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46196 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727043AbeIDPzQ (ORCPT ); Tue, 4 Sep 2018 11:55:16 -0400 Received: by mail-wr1-f67.google.com with SMTP id a108-v6so3528663wrc.13 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=F5LMtBHM/iTvxMxdbgmXcDpoNJ8iAeSfXCsPGt7y3Jgl9zVLxNs50RRJ5SkTghqLQM vWcxW6DWZkICFoZ6dj0WjZIpSP2MuzYj2rNw12KruZQ6kHz2lVgE9IVpU3+GJQs6GCyP ccrK69pJoH1qu9PCCtRgYpnVA6fSP4EEduzuJAin/vyNRrryp1G0X4yd1nS2Njd9tqgO arfQnBI/3nSl3KME7ZiJJoF8hGrImJVRwhxoUnSnLpvrQl/ylNPgqTkHnK7/ve4g9Vyj hsNhBSjUDFLUY0VKQRIhd7zvMEWG01r0hx3rJ6wQJ5BzQ4i64dlM0dsb7DmKehy2s5xq 2CcA== X-Gm-Message-State: APzg51DD/4kzugUo7nNyLrCgPxsLJknUYYaYDmyuoDUQwpetUl17ViPt 2bO8bxaLdBHD2tOYXJVurHbEm6Sv5qo= 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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, -- 2.17.1