Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp949735rdb; Wed, 1 Nov 2023 07:23:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZB/rqiGPxBT5WHdQe3W1bpmZMJvFZ5e8Jtt99FbgYtPNiGA5jDs35sdyQL635wIFH5QpP X-Received: by 2002:a05:6358:6f09:b0:168:e2d5:ddcc with SMTP id r9-20020a0563586f0900b00168e2d5ddccmr20307723rwn.7.1698848598118; Wed, 01 Nov 2023 07:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698848598; cv=none; d=google.com; s=arc-20160816; b=Rz4UoYkgqaGO1k+aFt85R3G6Q8bcLVThQdF4LFHs31LmW6PtlGqrlMCQ6kwMBr/sMq iUohJvMlGZqXnisXDHOXjxRsEGfAl0TMEAbeuvkPLZfkdLYIarAIqdjd54ikCaask7qy RPOhExvu2DdddR/KRxn513UsVkvpp7vJDS5pOe+bv8Y+DhH8HRh4Jnad4KpQ3oXFOtIO 578q1fzCohkCgF1P4I9ShOkTjWr21IPIJp+FiHPhHoNfLd8zKM/3ZhWORlkc2M2vtRZw Efrum5uqhDoOqgcSZc2yg8z7fWKIvOa2kO+1HbwOPG+78jGU4OOF+q2kjrevOq6r6m5y /G4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=yTTkxonjjkCj0qjxs67rkFejmb39idaptBO5b60I1VA=; fh=UqJDW/iFaPQP/+euyMmKCNJOgVap/7bAiz83/lQBJ08=; b=dw6xvHqBUFlfrBlNPcCsvuMbj8FucNIwhQG/CMB8LGBCIFBdRuwDP65oxdK2kCHFo6 39LyJVzaV/MICFXm/RjD6xubh1qkwcSJcesKNyluNqaClTHAamPI/QokxM8x780i11vJ Qza9FT5/elbOEbQtBLtXfxtV0bptobezSG7i4Gb1V7vpRu2Y8e7x5/56wvh0WZHrJNmk AROgJ9MpQSwN18hWyzNvBaN9tLoowitvhhBVe0Jtc2RNv8u+I5WgeYSdFzTONk7TsSPg y7s04elVOKNNxrdCGhhoadi1Rk8WMPMnchwYrKhGVRpX0ZFA76bMog7xRGuDVzAmKAnM HOOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=cP4MrS6K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y71-20020a638a4a000000b005aca8ed90c3si3026504pgd.271.2023.11.01.07.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 07:23:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=cP4MrS6K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 986C980CBF1F; Wed, 1 Nov 2023 07:23:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344388AbjKAOWq (ORCPT + 99 others); Wed, 1 Nov 2023 10:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235623AbjKAOWo (ORCPT ); Wed, 1 Nov 2023 10:22:44 -0400 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D6413E for ; Wed, 1 Nov 2023 07:22:28 -0700 (PDT) Received: from [192.168.1.18] ([86.243.2.178]) by smtp.orange.fr with ESMTPA id yC6sqhqedRx6cyC6sqXPQB; Wed, 01 Nov 2023 15:22:26 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698848546; bh=yTTkxonjjkCj0qjxs67rkFejmb39idaptBO5b60I1VA=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=cP4MrS6K43gLWkLhB67YLR1kNsojwY8mB0brjqolHErWWk/hrjOoizK6o193/o2gC F058P04mk7n3VVDS8bZ/HHfuZHpmHN8ehaTuYnABhYWZun7/ayBYG9CMANkfl33XwL 51vty3krTg820rOHwQHfF+4ws6KDa3sH+/PnbuUhND61f2KgzT/BmVmK/DmzfFa3x1 4yvyqvL+RnAZ+j0mYqH1jpTcmaLUIiEDl/Ij4ReKAGEquEYKYYsz3DcleiAG35Lxl7 Yz+S75xmAn61nhDuttsqB6i4o1dHgyHjIpJyUiWYN4eTDnz9geOOpTmMjS/d/RotgI 0IbIOx+HNB/jw== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 01 Nov 2023 15:22:26 +0100 X-ME-IP: 86.243.2.178 Message-ID: <7fc8435a-6a96-447b-af85-8ae5242cabfd@wanadoo.fr> Date: Wed, 1 Nov 2023 15:22:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v10 3/3] media: i2c: Add support for alvium camera Content-Language: fr To: Sakari Ailus , Tommaso Merciai Cc: 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 References: <20231020141354.2500602-1-tomm.merciai@gmail.com> <20231020141354.2500602-4-tomm.merciai@gmail.com> From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 01 Nov 2023 07:23:11 -0700 (PDT) Le 01/11/2023 à 15:13, Sakari Ailus a écrit : > 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. Should be v4l2_async_unregister_subdev()? CJ > >> } >> >> >> 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! :) >