Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4202805imm; Mon, 17 Sep 2018 09:47:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZtGLqI2SsxbgWVoEXVEN1ne0QEbqHRyB3grAT7zBNZXysk8mFErkuR2e7I/S03zRsnlYL4 X-Received: by 2002:a63:ac54:: with SMTP id z20-v6mr23491640pgn.74.1537202857958; Mon, 17 Sep 2018 09:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537202857; cv=none; d=google.com; s=arc-20160816; b=qGEn8frL9ADqT7F83pSHsOpAKckc2NzCATvMcI2utxRruH4qJYccvaw03Snnqi7ccR D+DQ5M/v1i/ePix8INEItfjtZPMr2T6hbPV/7orNk5NaGwmW+gbkUsuPq72gLEuq6Cqy qpDXN6uqdfjPnyUoLAl5mSUOcORJlu4N1er9g5gPWxBunM3hNXiw1QEwLFyh6Oqy+FT5 27hWar1jNPKJiF/n111lfzHyi9xzDoVRZZJltqyXtAVNXZHDaAxKZ8+Tc/MNg6NpkhIo 1nFY5tJ6KFQyRUaIJJZvmx8lVbG3GXS0+9d47ppfjm7R8RrLk+QqFOWOi1btb3oYzk1o QFSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CLckrSZvRjADsEKxvJi64mDgI4JBTEicYW3H1LTwEXU=; b=gf9eqKN8j9hmB0zYQHoGs6XrDWXjlPIo8K/HJ9AvqvtmhsUGarQu/QtYFlp+zukUQz biZs1PYWb9zBXKKiHcggsUADWOMVNrfBXEZopj49clhh1DRvk7oACxygBUG/bbOVkYgO 45QtnSCxjrnKexmSXHoGnmtPmXTSHSlNS3gjrzAOEFpB5vrdQtMQ2wDVuVzeY8OKolVO 1e14QXY29wwvK0cfqI2zy0KKr8nmAsRgxg4nlQ66ioCp5WNrxO6979BcnxkHbHhjZRBV rHG/u29DQ1E18Z14pZh+O6u79xsTMyRSdJbwDg/JpkYG+hyLvS2W4NvyXwf2ZpIWh72P NyQQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h89-v6si15674538pld.517.2018.09.17.09.47.16; Mon, 17 Sep 2018 09:47:37 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbeIQWPT (ORCPT + 99 others); Mon, 17 Sep 2018 18:15:19 -0400 Received: from mga18.intel.com ([134.134.136.126]:4446 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbeIQWPT (ORCPT ); Mon, 17 Sep 2018 18:15:19 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2018 09:47:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,386,1531810800"; d="scan'208";a="73937006" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga008.jf.intel.com with ESMTP; 17 Sep 2018 09:46:35 -0700 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id A0ECC2069E; Mon, 17 Sep 2018 19:46:34 +0300 (EEST) Date: Mon, 17 Sep 2018 19:46:34 +0300 From: Sakari Ailus To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, Tian Shu Qiu , Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org Subject: Re: [PATCH 1/2] [media] v4l: allow to register dev nodes for individual v4l2 subdevs Message-ID: <20180917164634.arevvwkrvdmmteem@paasikivi.fi.intel.com> References: <20180904113018.14428-1-javierm@redhat.com> <20180904113018.14428-2-javierm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180904113018.14428-2-javierm@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Javier, On Tue, Sep 04, 2018 at 01:30:17PM +0200, Javier Martinez Canillas wrote: > Currently there's only a function to register device nodes for all subdevs > of a v4l2 device that are marked with the V4L2_SUBDEV_FL_HAS_DEVNODE flag. > > But drivers may want to register device nodes for individual subdevices, > so add a v4l2_device_register_subdev_node() for this purpose. > > A use case for this function is for media device drivers to register the > device nodes in the v4l2 async notifier .bound callback instead of doing > a registration for all subdevices in the .complete callback. Thanks for the set. I've been doing some work to add events to MC; with Hans's property API set, assuming it could be used to tell the registration is complete, we have all bits for a complete solution. As the driver is buggy and fails to work correctly in the case if not every sub-devices probes successfully, I see no reason to postpone applying the two patches now. One more comment below. (No need to resend just for that IMO.) > > Signed-off-by: Javier Martinez Canillas > --- > > drivers/media/v4l2-core/v4l2-device.c | 90 ++++++++++++++++----------- > include/media/v4l2-device.h | 10 +++ > 2 files changed, 63 insertions(+), 37 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c > index 3940e55c72f1..e5fc51b6604c 100644 > --- a/drivers/media/v4l2-core/v4l2-device.c > +++ b/drivers/media/v4l2-core/v4l2-device.c > @@ -222,9 +222,59 @@ static void v4l2_device_release_subdev_node(struct video_device *vdev) > kfree(vdev); > } > > -int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) > +int v4l2_device_register_subdev_node(struct v4l2_device *v4l2_dev, > + struct v4l2_subdev *sd) > { > struct video_device *vdev; > + int err; > + > + if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) > + return -EINVAL; > + > + vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); > + if (!vdev) > + return -ENOMEM; > + > + video_set_drvdata(vdev, sd); > + strlcpy(vdev->name, sd->name, sizeof(vdev->name)); > + vdev->v4l2_dev = v4l2_dev; > + vdev->fops = &v4l2_subdev_fops; > + vdev->release = v4l2_device_release_subdev_node; > + vdev->ctrl_handler = sd->ctrl_handler; > + err = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1, > + sd->owner); > + if (err < 0) { > + kfree(vdev); > + return err; > + } > + sd->devnode = vdev; > +#if defined(CONFIG_MEDIA_CONTROLLER) > + sd->entity.info.dev.major = VIDEO_MAJOR; > + sd->entity.info.dev.minor = vdev->minor; > + > + /* Interface is created by __video_register_device() */ > + if (vdev->v4l2_dev->mdev) { > + struct media_link *link; > + > + link = media_create_intf_link(&sd->entity, > + &vdev->intf_devnode->intf, > + MEDIA_LNK_FL_ENABLED | > + MEDIA_LNK_FL_IMMUTABLE); > + if (!link) { > + err = -ENOMEM; > + video_unregister_device(sd->devnode); > + return err; > + } > + } > +#endif > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(v4l2_device_register_subdev_node); > + > +int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) > +{ > + > struct v4l2_subdev *sd; > int err; > > @@ -238,43 +288,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) > if (sd->devnode) > continue; > > - vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); > - if (!vdev) { > - err = -ENOMEM; > - goto clean_up; > - } > - > - video_set_drvdata(vdev, sd); > - strlcpy(vdev->name, sd->name, sizeof(vdev->name)); > - vdev->v4l2_dev = v4l2_dev; > - vdev->fops = &v4l2_subdev_fops; > - vdev->release = v4l2_device_release_subdev_node; > - vdev->ctrl_handler = sd->ctrl_handler; > - err = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1, > - sd->owner); > - if (err < 0) { > - kfree(vdev); > + err = v4l2_device_register_subdev_node(v4l2_dev, sd); > + if (err) > 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; > - > - /* Interface is created by __video_register_device() */ > - if (vdev->v4l2_dev->mdev) { > - struct media_link *link; > - > - link = media_create_intf_link(&sd->entity, > - &vdev->intf_devnode->intf, > - MEDIA_LNK_FL_ENABLED | > - MEDIA_LNK_FL_IMMUTABLE); > - if (!link) { > - err = -ENOMEM; > - goto clean_up; > - } > - } > -#endif > } > return 0; > > diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h > index b330e4a08a6b..bf25418a1ad6 100644 > --- a/include/media/v4l2-device.h > +++ b/include/media/v4l2-device.h > @@ -185,6 +185,16 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, > */ > void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); > > +/** > + * v4l2_device_register_subdev_node - Registers a device node for a subdev > + * of the v4l2 device. > + * > + * @v4l2_dev: pointer to struct v4l2_device struct -> &struct > + * @sd: pointer to &struct v4l2_subdev > + */ > +int __must_check v4l2_device_register_subdev_node(struct v4l2_device *v4l2_dev, > + struct v4l2_subdev *sd); > + > /** > * v4l2_device_register_subdev_nodes - Registers device nodes for all subdevs > * of the v4l2 device that are marked with -- Regards, Sakari Ailus sakari.ailus@linux.intel.com