Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp943245rdb; Wed, 1 Nov 2023 07:13:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQlZFWY6/2MCmc2IMtnDfzh6B9rhLF+1Rv8EQ0s0kmwZ7sw+YzLDMdtX5skWBaroNKeY2X X-Received: by 2002:a05:6870:2b05:b0:1ef:b588:94b5 with SMTP id ld5-20020a0568702b0500b001efb58894b5mr14943752oab.27.1698848035230; Wed, 01 Nov 2023 07:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698848035; cv=none; d=google.com; s=arc-20160816; b=RRwooWl06HK/5cgpYb8BC0pYGl/KLYN2fxs8JtvxEbLVWjkg+Db4q/crcwelMIOZfu DrGgVgpwvdeslaH+a9aWWAyNEKJKwh1BJ5n1xK+vI7W8OFTVxmtk/rJ5aViwhDH7OOa6 IhuIVxqGjy3Ajtbsq+gbd0CO39GDDlpWPZX/E63o3wVAiT/e9AknLfVWdWJpVAVYe6Wy 3pz4zZB9k/XlL1GqNjm35GHAV9hiFEhJU3/P9a4qvVo4sLlT9ozhd5hfjfx9OuXbNETL D++jOpKWd8yJJr1uDMiYNS/YeZIK5lB8Q9aLc184vuGQxsnaiu9cz2CWqZq6LWCw7scf NHQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Dc5ICU3mMXJ+9WN43+++iQbTFuGZZSFp6lM2c8kvds0=; fh=qPCFJQQlQt/mlORHSHTTRdM04HlixR1GjG4hOPx5hsM=; b=TwZUCBCu/MFY3O7pRoJ3toKU5Zc8UECeBYD5oPhMbuOqWSOJuy4R/dNPH90lzitZau lkVuUAYwRMhe0LjW8824ksdzVB70/+F+r813S3VSdZuZpG9T+t3LSfne/B6q83aU3MyG 42Zgg7QOAZOFF+uphhQy9ArVMl9xTlp3Izp1pZ5hSTq7EWOp3ormhTBTUzZuNAMffAGr wObSCsZ1f00mAUsXDNQLRpO4j8TlhpbE+BgVV2J3AcbybJqs9Y823zoKcFDQTz7xMTVv rKLM5SzlZ/BSm/cFTNmRJWJjMYUE05XUmelKI8DtlT4wGBlwGG6AbvIClXh05gujG2ll KUgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EGs4eVu7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k23-20020a63ba17000000b005ab2613a571si3143817pgf.495.2023.11.01.07.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 07:13:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EGs4eVu7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1034480FA858; Wed, 1 Nov 2023 07:13:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344340AbjKAONc (ORCPT + 99 others); Wed, 1 Nov 2023 10:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235182AbjKAONa (ORCPT ); Wed, 1 Nov 2023 10:13:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E4883; Wed, 1 Nov 2023 07:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698848006; x=1730384006; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=wGBu3/j706WJmrxU7xAqNyUmg5FN/DVlyjcIaMJULUM=; b=EGs4eVu7assSGMJlYEqaQqF37wpyzXuKQpBhLyNCDNRxNrHVv06xwLpF K98U3MiJocvbWf6w54ywwrLYyboh7ORhh7ASv9pkGw2GCR3BtBsxT6blS Hc7FUK2SYkOyh/o3JQJq7j4irz1RUImyKV5l7gdqmyS9iP/9dn9QrDcMk Rg3KZW8AGWwI4V1zuNz8S7QQ2GgpZ9XG1CVv0XjoIr1DOWHMuU3wd72qp k/7+Oe+Z94mWHpDovygo+apsrwJI5xZFTDGpbc6vHfHZRmkc1Kf+7iKbp gSsQmsyzAQYq5UiOkWOUx5CxRztFZWwkrxp5i3p7DSw5QLu7j+n4+3hMX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="7122329" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="7122329" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 07:13:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="826783310" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="826783310" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 07:13:17 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 405DB1207A3; Wed, 1 Nov 2023 16:13:14 +0200 (EET) Date: Wed, 1 Nov 2023 14:13:14 +0000 From: Sakari Ailus To: Tommaso Merciai Cc: Christophe JAILLET , martin.hecht@avnet.eu, michael.roeder@avnet.eu, mhecht73@gmail.com, linuxfancy@googlegroups.com, Mauro Carvalho Chehab , Liam Girdwood , Mark Brown , Laurent Pinchart , Hans de Goede , Hans Verkuil , Tomi Valkeinen , Marco Felsch , Gerald Loacker , Andy Shevchenko , Daniel Scally , Shawn Tu , Linus Walleij , linux-kernel@vger.kernel.org, Linux Media Mailing List Subject: Re: [PATCH v10 3/3] media: i2c: Add support for alvium camera Message-ID: References: <20231020141354.2500602-1-tomm.merciai@gmail.com> <20231020141354.2500602-4-tomm.merciai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 07:13:33 -0700 (PDT) Hi Tommaso, On Tue, Oct 31, 2023 at 12:46:09PM +0100, Tommaso Merciai wrote: > > > +static int alvium_get_dt_data(struct alvium_dev *alvium) > > > +{ > > > + struct device *dev = &alvium->i2c_client->dev; > > > + struct fwnode_handle *fwnode = dev_fwnode(dev); > > > + struct fwnode_handle *endpoint; > > > + int ret = -EINVAL; > > > + > > > + if (!fwnode) > > > + return -EINVAL; > > > + > > > + /* Only CSI2 is supported for now: */ > > > + alvium->ep.bus_type = V4L2_MBUS_CSI2_DPHY; > > > + > > > + endpoint = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0); > > > + if (!endpoint) { > > > + dev_err(dev, "endpoint node not found\n"); > > > + return -EINVAL; > > > + } > > > + > > > + if (v4l2_fwnode_endpoint_alloc_parse(endpoint, &alvium->ep)) { > > > + dev_err(dev, "could not parse endpoint\n"); > > > + goto error_out; > > > > This could go to another label to be less confusing, but > > v4l2_fwnode_endpoint_free() looks to be a no-op here, so good enough. > > Thanks for the comment. > To be honest right now this is clear to me > I prefere to stay on the following :) > Prefer to keep just only one path. You can safely call v4l2_fwnode_endpoint_free() on an unparsed endpoint (or on and endpoint the parsing of which failed). I prefer this too. > > > + ret = -ENODEV; > > > + goto err_powerdown; > > > + } > > > + > > > + ret = alvium_get_hw_info(alvium); > > > + if (ret) { > > > + dev_err(dev, "get_hw_info fail %d\n", ret); > > > + goto err_powerdown; > > > + } > > > + > > > + ret = alvium_hw_init(alvium); > > > + if (ret) { > > > + dev_err(dev, "hw_init fail %d\n", ret); > > > + goto err_powerdown; > > > + } > > > + > > > + ret = alvium_setup_mipi_fmt(alvium); > > > + if (ret) { > > > + dev_err(dev, "setup_mipi_fmt fail %d\n", ret); > > > + goto err_powerdown; > > > + } > > > + > > > + /* > > > + * Enable runtime PM without autosuspend: > > > + * > > > + * Don't use pm autosuspend (alvium have ~7s boot time). > > > + * Alvium has been powered manually: > > > + * - mark it as active > > > + * - increase the usage count without resuming the device. > > > + */ > > > + pm_runtime_set_active(dev); > > > + pm_runtime_get_noresume(dev); > > > + pm_runtime_enable(dev); > > > + > > > + /* Initialize the V4L2 subdev. */ > > > + ret = alvium_subdev_init(alvium); > > > + if (ret) > > > + goto err_pm; > > > + > > > + ret = v4l2_async_register_subdev(&alvium->sd); > > > + if (ret < 0) { > > > + dev_err(dev, "Could not register v4l2 device\n"); > > > + goto err_subdev; > > > + } > > > + > > > + return 0; > > > + > > > +err_subdev: > > > + alvium_subdev_cleanup(alvium); > > > > Should this also be called by the remove function? > > Or is it already handled by an un-register mechanism? > > Right, I miss this. > Thanks. > I put this to remove function like: > > static void alvium_remove(struct i2c_client *client) > { > struct v4l2_subdev *sd = i2c_get_clientdata(client); > struct alvium_dev *alvium = sd_to_alvium(sd); > struct device *dev = &alvium->i2c_client->dev; > > /* > * Disable runtime PM. In case runtime PM is disabled in the kernel, > * make sure to turn power off manually. > */ > pm_runtime_disable(dev); > if (!pm_runtime_status_suspended(dev)) > alvium_power_on(alvium, false); > pm_runtime_set_suspended(dev); > > alvium_subdev_cleanup(alvium); > i2c_unregister_device(alvium->i2c_client); This doesn't belong here (as you didn't register it). It was missed in the review earlier. > } > > > If for you Cristophe, Sakari, Laurent, > it's ok I prefer to skip v11 that I sent this morning too early. > I collected hints from Cristophe right now and I plan to send v12 > this afternoon/evening if for you all is ok. > > https://github.com/avs-sas/linux/blob/tm/media_stage/v6.6.0-rc3/alvium_drv/v12/drivers/media/i2c/alvium-csi2.c > > Please let me know. > > Thanks again to all! :) -- Regards, Sakari Ailus