Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2192386lqa; Tue, 30 Apr 2024 10:25:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXq+83wMmGb0ey4I/mlKIwTR/+/xjNbG4//VH2GIKJ9ofUTLRYC5uzyB9BvlG1lAjh+71/Rfkhx+1Xg3P2vaO2GLXUWwULQgZYpykOV5A== X-Google-Smtp-Source: AGHT+IE1TsPqZVilLeDp5DEbk356vTOUfI2+Oc5p2dR3al3oQS8ee0MMtZ7BfIEc0BQUHArGhMj4 X-Received: by 2002:a05:6870:c14d:b0:23d:5285:5dc6 with SMTP id g13-20020a056870c14d00b0023d52855dc6mr98325oad.52.1714497917800; Tue, 30 Apr 2024 10:25:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714497917; cv=pass; d=google.com; s=arc-20160816; b=hXsyLml/YieHYxKNdknAsfnwBGLqksPkDtp7Y8DRVgCXltoqQLCpPrnbzwvBxd4sRi ELz8c7CAe5PbNXmiZFsu4BcOOwaKHr0IJElqFu+JsfmStIlGLMNr0MYCVG7pA1QG0s4X WU0r5cPENuioWTFWx7HbalEjSzVYGgsS5oLf7A6rW4FWkmRBBXM4slpeQZgUqE3DpVVn rodr9/Gwl7MeQYBFGBjCozOVrtn/2le5sRcT7juMh9t56Wb6fLLhZyL4uo/sPFJbbf4A hqywnHuDZEy1vC0Zj50bPP4gHrbOSr06q1ghiX/Ol9mXIeqd2ukokVeJXXEKYxUa7Nfq zAHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=Z+7S7yss0Z/3HfrJHfsoOEnXPR0d6itI8idhdLjGVt8=; fh=DRAJHn2RokvZqcem6ICNy5NFo1dUQikmdHA7DQ6mFeo=; b=i1RAsJ2JxkDHcyVvwwAaIZVVaG8j5EId9nkio1zfGQXcG6dFnx0evRddPx2VhGNxnR vjq/1irTsfD/0VbI1jEV8313zmGy/+62MsAgb4SwchKmxJSTmvixEgziowrXI1GwHbaN U3mp0t9q0eBHGTg+zbiDrvYS/hUukiTXTSE8sOUK0MLIj3nG6oci1uxAMLnitb9L71JC W1ziN0LLWOwHKEvw4kAAdmKeRD1MPWbuczvMSESmkQdBA9cbV2JtQyWo4u0ypf2zzteF MYh+0oMA/9rSMCWewig9gwO2EQ0cpa9I3BjZ+dsl+C8glzQokQ4rufdK/fcSI7DLflF7 UhTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=CSoyvMe5; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-164506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l5-20020a63da45000000b005dbde399b23si19620223pgj.901.2024.04.30.10.25.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 10:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=CSoyvMe5; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-164506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 78ECAB21686 for ; Tue, 30 Apr 2024 17:24:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A623318133A; Tue, 30 Apr 2024 17:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="CSoyvMe5" Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) (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 9FF1717F385; Tue, 30 Apr 2024 17:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714497862; cv=none; b=UqA60kMxGMLZ0IL7v0rtyYjNQHZfgIO5nz14NkXR/fokFUypt7cwSi7Ly8jTAHBJPQrFHGhr5Cs1i0aNOJgauibeuZtSA9qYENZu3eBx8wlk0cGuZa75dBplFDSaPFdLdmiFDwzU4ISUfG8ikefJgM4MS/mM++U5+Ez/eDsEuEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714497862; c=relaxed/simple; bh=wyni/P2zqYEIwz4b2jPFOn7K/o20R+rMhqEI4gvwYGQ=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=d19M+lG+DqN1/Eutlq46JzgRgVPsHuLov1r3uyq/ietPdJW16Rrnlp6bqGD4L9LsUgwQ68U5UWG/O0MEIbs305pwaP1cMsiwFLZXP9DKPrGttK70AOYoEOlIjvFtBdu+KlIkjcBt9hvMUlb90KV9lZb2+9aqLHpkPsAXLIJWTG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=CSoyvMe5; arc=none smtp.client-ip=192.134.164.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Z+7S7yss0Z/3HfrJHfsoOEnXPR0d6itI8idhdLjGVt8=; b=CSoyvMe5xwRTMoiNMuI683b7Jk5rHr0SbfmYxPKCgJLai1z/UPqyMfsm kNOpdONPLwTO+QNaP116cerg0SZxKUsJOad+FL87HaJdh8c1GeV1W2fzc o0ZvYDgwl+IsXKIUDWLsjocO/xaqULgHUxKbneo06ZRlnM+DKXdKpUcqB E=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.07,242,1708383600"; d="scan'208";a="86109162" Received: from 12-176-169-194.cust.keyyo.net (HELO hadrien) ([194.169.176.12]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2024 19:23:08 +0200 Date: Tue, 30 Apr 2024 19:23:07 +0200 (CEST) From: Julia Lawall To: R Sundar cc: Christophe JAILLET , mripard@kernel.org, mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com Subject: Re: [PATCH linux-next] media:cdns-csi2tx: replace of_node_put() with __free In-Reply-To: Message-ID: <76b3d25-2ba3-2f9f-3ed6-61a63983a225@inria.fr> References: <20240429171543.13032-1-prosunofficial@gmail.com> <6df5d715-3e31-40a5-9db3-2c3b9f12efac@wanadoo.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-728899255-1714497787=:3106" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-728899255-1714497787=:3106 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Tue, 30 Apr 2024, R Sundar wrote: > On 30/04/24 00:10, Christophe JAILLET wrote: > > Le 29/04/2024 à 19:15, R Sundar a écrit : > > > Use the new cleanup magic to replace of_node_put() with > > > __free(device_node) marking to auto release when they get out of scope. > > > > > > Suggested-by: Julia Lawall > > > Signed-off-by: R Sundar > > > --- > > >   drivers/media/platform/cadence/cdns-csi2tx.c | 19 +++++++------------ > > >   1 file changed, 7 insertions(+), 12 deletions(-) > > > > > > diff --git a/drivers/media/platform/cadence/cdns-csi2tx.c > > > b/drivers/media/platform/cadence/cdns-csi2tx.c > > > index 3d98f91f1bee..88aed2f299fd 100644 > > > --- a/drivers/media/platform/cadence/cdns-csi2tx.c > > > +++ b/drivers/media/platform/cadence/cdns-csi2tx.c > > > @@ -496,48 +496,43 @@ static int csi2tx_get_resources(struct csi2tx_priv > > > *csi2tx, > > >   static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx) > > >   { > > >       struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 }; > > > -    struct device_node *ep; > > >       int ret, i; > > > - > > > -    ep = of_graph_get_endpoint_by_regs(csi2tx->dev->of_node, 0, 0); > > > +    struct device_node *ep __free(device_node) = > > > +        of_graph_get_endpoint_by_regs(csi2tx->dev->of_node, 0, 0); > > > + > > >       if (!ep) > > >           return -EINVAL; > > >       ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &v4l2_ep); > > >       if (ret) { > > >           dev_err(csi2tx->dev, "Could not parse v4l2 endpoint\n"); > > > -        goto out; > > > +        return ret; > > >       } > > >       if (v4l2_ep.bus_type != V4L2_MBUS_CSI2_DPHY) { > > >           dev_err(csi2tx->dev, "Unsupported media bus type: 0x%x\n", > > >               v4l2_ep.bus_type); > > > -        ret = -EINVAL; > > > -        goto out; > > > +        return -EINVAL; > > >       } > > >       csi2tx->num_lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes; > > >       if (csi2tx->num_lanes > csi2tx->max_lanes) { > > >           dev_err(csi2tx->dev, > > >               "Current configuration uses more lanes than supported\n"); > > > -        ret = -EINVAL; > > > -        goto out; > > > +        return -EINVAL; > > >       } > > >       for (i = 0; i < csi2tx->num_lanes; i++) { > > >           if (v4l2_ep.bus.mipi_csi2.data_lanes[i] < 1) { > > >               dev_err(csi2tx->dev, "Invalid lane[%d] number: %u\n", > > >                   i, v4l2_ep.bus.mipi_csi2.data_lanes[i]); > > > -            ret = -EINVAL; > > > -            goto out; > > > +            return -EINVAL; > > >           } > > >       } > > >       memcpy(csi2tx->lanes, v4l2_ep.bus.mipi_csi2.data_lanes, > > >              sizeof(csi2tx->lanes)); > > > -out: > > > -    of_node_put(ep); > > >       return ret; > > > > Hi, > > > > Nit: return 0; ? > > > > CJ > > > > >   } > > > Hi, > > In success case, ret variable value also will be zero, else for non-zero ret > value it will return from v4l2_fwnode_endpoint_parse()'s error case handling > block. Indeed, but it seems that the return ret at the end of the function always returns 0? If that is the case, return 0 would be better, as one can see that that code is only reached in the success case. julia --8323329-728899255-1714497787=:3106--