Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp24988lqo; Wed, 15 May 2024 06:49:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX//yY4qp8ajfc/B7u53UViHVVEpxqkBP2gGoOCSgI6zBH6NXibFPqbzDY+DKuraHd7kzSDL3JerbkKw8m7ezYKfNgsZHvxZYqlV0kOvw== X-Google-Smtp-Source: AGHT+IHZ56dCY5/E7FPi+skx2qbBHx715WPZpC1YSi5EkTGJ8UwkcTCzH4jX3bM7F1UXF5fUz6i0 X-Received: by 2002:a50:9fc9:0:b0:572:ad86:d317 with SMTP id 4fb4d7f45d1cf-5734d5b90e3mr11519966a12.11.1715780979568; Wed, 15 May 2024 06:49:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715780979; cv=pass; d=google.com; s=arc-20160816; b=izRKLqcyuJ+9pfIrR3DSFSDAtWGJ9kkSC8fJpRjSO04VXC4QdUvzi5OD7K9p4aFkxq j85GWC2634Hw50bFiC3g3Pwf20eU1CQ8ze06GSNTI+1Xxdchnladfpwro+asqzhgv/+w oWCsHkJQcUnt/o2irasGohS5qdElmo0xOychgzeK7jR12RSlMeDvaW9/JTQ31+ROfwdu QdMFGvz8ti+7n3qdEuhxi/gg8U8FAJ4mQ0WVxXerAMP4hnNsmDDc06nDa9PUNO1Br+c+ AWp+pgDcb3tydynn4g4QkSytTil3hUi0fV7vMP0kpId8QUinxyOURzUQLhCkCNjfvj5O aGVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=f/XUg0G5HNBM0Do0C8UdXuXwEzE90yrUPRuR7LaA0RY=; fh=MOw1k6t5wUtjQh+RDQTOGhUjMjFO7ZC2XZsgQ1IQxDU=; b=qmR7uB84y5fnzAOrsSvbkL7GrGxZmavtIqTZdNrWYX1M5hqcQWRi5EANyJc4cKDDfj qkKa7/w+qsxTsVGGV3Ok8WOr4fTM0pZKjXqoM2z2BufPH3p52bMpacgKjlGQyCx7UAm8 Q9IFRnEyf4CQgSwdAiCU4Y+hK8oF2TnnBOpSrdpRhP0nCZdHAE5yeyKr+iY0E7YqEKXD KKIcDUhPNkyo1+QNkQ14IVWUcgT87XejIqgO0eFtB8kOCRnOK4J7AtGOkKIDcrM/DNR5 ntnt+tVYINp8jF68SNZn74s7ZnEWXvpkMnafnExzDo7xjqMt1V5T1CI4U764ecmr29m1 VxtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=6dAdjaGe; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-179936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733beac59esi7594028a12.33.2024.05.15.06.49.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=6dAdjaGe; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-179936-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2C7491F2277A for ; Wed, 15 May 2024 13:49:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C65EB13F00C; Wed, 15 May 2024 13:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="6dAdjaGe" Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 004A38615E; Wed, 15 May 2024 13:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715780966; cv=none; b=qRq92CL4M9kn6+RD28651fcsnVcYcv3EQiUykbZ9GLvhGiRS1YwKplQjbYI+SRp3agAOB6QyXeyiA6Y8lsSBZcA4DLHAd8Xf4/A1q6ZRXg0LnCq2jlAf6WZCsmkQqgll2LJRNk7mlWBVQbtWTJzHHKnC5a3ifn7OdVc4dhbLpcY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715780966; c=relaxed/simple; bh=ma0SDy1/Ty0yp0Zp6U88INF7i/YGDyZBL7lmsJZsJOo=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=SMFtF49h4YkC5NQkRrXK3MduANuGCm1ZFdzfZhPaRvKZSTpfYX7DOOyBGuhJKl8aZeNyi75i6QgGPB3tV1FyBemOL6h759ZeArSmMRfllFfwStJFJCcN2As3+G5bBCpOqVyvhDSQAInU0rBPbYKCWCHD4NXnZPqEMNiQyV+T/xg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=6dAdjaGe; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44FDVMe8005405; Wed, 15 May 2024 15:49:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= selector1; bh=f/XUg0G5HNBM0Do0C8UdXuXwEzE90yrUPRuR7LaA0RY=; b=6d AdjaGenQxFFuJQ2zwbia4eeJdPTLGAFsblB3oPbRxwE0S3AmGW4dPC4bFnIZr61N 7QAVFJtkXX3aAWn/cRraBPZXbbPn0p9qhzLEU2H0XLyzvtb1DVXMCYgpefBUmeUs ztM4pWDpXH8aZi03e2t+gI4gLJJAsxHQ0gYRa3Y+tUjjzDeMFkOuN12uZXMOFRbH LwGa28DN0R8KPefekMYdzRmFKPelhwnZDD4zkvdHNFdAWY2ccJYRKgBMtX/HSBIh 8EXsprNXwfAs5vdugd4bZV+0AU62iDccByB/mt5A//YgOcFbz5Ob6ersNUujoTRf r6t2wX7fEaTe6FQHBasA== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3y4sym9atv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 May 2024 15:49:07 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 818F440046; Wed, 15 May 2024 15:49:00 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0F2992194D5; Wed, 15 May 2024 15:47:52 +0200 (CEST) Received: from [10.252.29.14] (10.252.29.14) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 15 May 2024 15:47:51 +0200 Message-ID: Date: Wed, 15 May 2024 15:47:50 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 linux-next] media: i2c: st-mipid02: replace of_node_put() with __free To: R Sundar , , , , CC: , , , , Julia Lawall References: <20240429163736.11544-1-prosunofficial@gmail.com> Content-Language: en-US From: Benjamin Mugnier In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-15_07,2024-05-15_01,2023-05-22_02 Hi, On 5/14/24 17:20, R Sundar wrote: > Hi, > > Thanks for the comments. > > On 13/05/24 17:13, Benjamin Mugnier wrote: >> Hi, >> >> I took sometime to reflect on this. Currently I favor drivers >> consistency. > > >> Merging this patch as is would introduce some differences between the >> vgxy61 and other drivers that follow the 'of_node_put' flow, which I >> think is not an improvement. >> > > I checked st-vgxy61.c file, I didn't find of_node_put(). Apologize, I meant st-mipid02. > Any file apart from this,  you want to see those changes? If yes let me > know, please. > Meanwhile I am also looking into it. > > This patch mainly reduce the goto error statements and increases > readability of the code. > >> Now, this patch is certainly good. Would it be possible to extend it to >> all other drivers using the 'of_node_put' ? >> > yes, people are working on it to replace of_node_put() in many places. > soon many patches can be expected to come in , for replacing of_node_put > with auto cleanup module. > I am also adding these changes to few other files also. Good, I'd rather see a series with all these files then to ease the review. But I only maintain the st-mipid02 so other people opinion may differ. > > Thanks, > >> That would the consistency issue while improving code quality at the >> same time. >> >> Thank you. >>  > >> On 4/29/24 18:37, R Sundar wrote: >>> Use the new cleanup magic to replace of_node_put() with >>> __free(device_node) marking to auto release and to simplify the error >>> paths. >>> >>> Suggested-by: Julia Lawall >>> Signed-off-by: R Sundar >>> --- >>> >>> Changes since v1 - >>> >>> - Added missed out __free() marking in mipid02_parse_tx_ep(). >>> - In mipid02_parse_tx_ep(), In error case, return value is always >>> -EINVAL.  so >>> sending the -EINVAL instead of ret variable value. >>> >>> Link to v1 - >>> https://lore.kernel.org/all/20240427095643.11486-1-prosunofficial@gmail.com/#t >>> >>>   drivers/media/i2c/st-mipid02.c | 37 +++++++++------------------------- >>>   1 file changed, 9 insertions(+), 28 deletions(-) >>> >>> diff --git a/drivers/media/i2c/st-mipid02.c >>> b/drivers/media/i2c/st-mipid02.c >>> index f250640729ca..bd3cf94f8534 100644 >>> --- a/drivers/media/i2c/st-mipid02.c >>> +++ b/drivers/media/i2c/st-mipid02.c >>> @@ -715,31 +715,28 @@ static int mipid02_parse_rx_ep(struct >>> mipid02_dev *bridge) >>>       struct v4l2_fwnode_endpoint ep = { .bus_type = >>> V4L2_MBUS_CSI2_DPHY }; >>>       struct i2c_client *client = bridge->i2c_client; >>>       struct v4l2_async_connection *asd; >>> -    struct device_node *ep_node; >>>       int ret; >>>         /* parse rx (endpoint 0) */ >>> -    ep_node = >>> of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node, >>> -                        0, 0); >>> +    struct device_node *ep_node __free(device_node) = >>> +        >>> of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node, 0, 0); >>>       if (!ep_node) { >>>           dev_err(&client->dev, "unable to find port0 ep"); >>> -        ret = -EINVAL; >>> -        goto error; >>> +        return -EINVAL; >>>       } >>>         ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), >>> &ep); >>>       if (ret) { >>>           dev_err(&client->dev, "Could not parse v4l2 endpoint %d\n", >>>               ret); >>> -        goto error_of_node_put; >>> +        return ret; >>>       } >>>         /* do some sanity checks */ >>>       if (ep.bus.mipi_csi2.num_data_lanes > 2) { >>>           dev_err(&client->dev, "max supported data lanes is 2 / got >>> %d", >>>               ep.bus.mipi_csi2.num_data_lanes); >>> -        ret = -EINVAL; >>> -        goto error_of_node_put; >>> +        return -EINVAL; >>>       } >>>         /* register it for later use */ >>> @@ -750,7 +747,6 @@ static int mipid02_parse_rx_ep(struct mipid02_dev >>> *bridge) >>>       asd = v4l2_async_nf_add_fwnode_remote(&bridge->notifier, >>>                             of_fwnode_handle(ep_node), >>>                             struct v4l2_async_connection); >>> -    of_node_put(ep_node); >>>         if (IS_ERR(asd)) { >>>           dev_err(&client->dev, "fail to register asd to notifier %ld", >>> @@ -764,46 +760,31 @@ static int mipid02_parse_rx_ep(struct >>> mipid02_dev *bridge) >>>           v4l2_async_nf_cleanup(&bridge->notifier); >>>         return ret; >>> - >>> -error_of_node_put: >>> -    of_node_put(ep_node); >>> -error: >>> - >>> -    return ret; >>>   } >>>     static int mipid02_parse_tx_ep(struct mipid02_dev *bridge) >>>   { >>>       struct v4l2_fwnode_endpoint ep = { .bus_type = >>> V4L2_MBUS_PARALLEL }; >>>       struct i2c_client *client = bridge->i2c_client; >>> -    struct device_node *ep_node; >>>       int ret; >>>         /* parse tx (endpoint 2) */ >>> -    ep_node = >>> of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node, >>> -                        2, 0); >>> +    struct device_node *ep_node __free(device_node) = >>> +        >>> of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node, 2, 0); >>>       if (!ep_node) { >>>           dev_err(&client->dev, "unable to find port1 ep"); >>> -        ret = -EINVAL; >>> -        goto error; >>> +        return -EINVAL; >>>       } >>>         ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), >>> &ep); >>>       if (ret) { >>>           dev_err(&client->dev, "Could not parse v4l2 endpoint\n"); >>> -        goto error_of_node_put; >>> +        return -EINVAL; >>>       } >>>   -    of_node_put(ep_node); >>>       bridge->tx = ep; >>>         return 0; >>> - >>> -error_of_node_put: >>> -    of_node_put(ep_node); >>> -error: >>> - >>> -    return -EINVAL; >>>   } >>>     static int mipid02_probe(struct i2c_client *client) >> > -- Regards, Benjamin