Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1196698iog; Thu, 16 Jun 2022 00:41:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1QMSCWkok4sFc9HqZBtq7SQxj7YQ6FkKIij7CQKnTqaZqsM/JPTiHUwFnqlpo059sP/f7 X-Received: by 2002:a17:906:708:b0:712:174:8745 with SMTP id y8-20020a170906070800b0071201748745mr3246265ejb.268.1655365292211; Thu, 16 Jun 2022 00:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655365292; cv=none; d=google.com; s=arc-20160816; b=ed9ozQa3LBG5FUTT23+Miu3vv99JABT/izYlpBTNi5bqr0t/PKTvyyYYGkwAevXldy AZ4WoNUpVFFD7CU3nti8swqoOSEdsg0HsP8X9tTYf5vST45jyxwxbV5NZ/R/vkMFp7cv gl3HoTqs3aw2vbP1M6ty17Z+gY0Qu2EcDJODyZEFu0fOppzVdVzr15eLoV5zsXX3LDi3 /X4p2SQAXrRWYd9nxT2Snc1LXstXxJQxG5lOHE1zt5kY4QUbuHgyKnHvjHobLsMHpEmM S13n8gQtfDQd+BtK8bQww0cDdYz/LTegZkePk42zhuWalVzozSvrhWUE7DcHIKCl/CfF uR1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=/ylwRydwSJ1vl505rIcsqlZRV8qHAjzTkuzOn3IJaxY=; b=lOiJY2ox2QAQ535cH9daZiEnIXQlz5X+G8ikm/u3Zul3uH+AYCxnAnRZmQj8LK6A6R 4u0jHWYCUkDRUwN9EYN+apsr85O5VljgU1gXAF8vIb8IJk4q7MROc7YbGmi7c0IH2shv G27YRwlhen03IglCbUDWRok/njzbrUvkN/niZvmWZH8/flZSvbexQpKxFadCK2E3HITw 5tGEmkkz6EQD9Lf8q4bIZAW2ptor2e/evDb+Ed7zKnOEu9CipC4mdZKIja/0ERQkaDiJ ucDx3TWrZ+eU/pxcgWiNexWe5+RmYJWRIBb417DxPzaSGZwgqoGo1kWo8WIoT3hkA377 /Kag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LJPb2Nd1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a170906839400b00711ce25e88esi928894ejx.427.2022.06.16.00.41.07; Thu, 16 Jun 2022 00:41:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LJPb2Nd1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbiFPHNb (ORCPT + 99 others); Thu, 16 Jun 2022 03:13:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359041AbiFPHNY (ORCPT ); Thu, 16 Jun 2022 03:13:24 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335B123143; Thu, 16 Jun 2022 00:13:21 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id BD72E240004; Thu, 16 Jun 2022 07:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1655363600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ylwRydwSJ1vl505rIcsqlZRV8qHAjzTkuzOn3IJaxY=; b=LJPb2Nd1CvgSZLX2nP41tGlPv6KZN9tbzWLxHLWLbPbK9vWbVOfa2G9oJIScPODdB0HHDT puwfaAEjZa/qWjni4mrATRg9Hz7OeZLFCOsfBJ5FR2sDgQ0iYz2EWLU+zzqnlR3ISNN+UK kCJLFH1N7RiaMBpRqW0k5sHPRqdAanVW2V35vB4PwRIGqsSXtZhvyvpr08lMa/PYhf0rzh j0L0DdnBx+4gdnxlLgaDcPB7nEqxhKeGBT5RpzJg64e9nAoYbPNGq1GX+GoOneNGxY4BsT QDhKQKrPWQl1OIiQlFTNoZgWS+brgsq7PcScRJNlKSfPZw2mD7Kk/onqljfLqA== Date: Thu, 16 Jun 2022 09:12:22 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Jakub Kicinski Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , Russell King , Vivien Didelot , "David S . Miller" , Eric Dumazet , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Magnus Damm , Heiner Kallweit , Alexandre Torgue , Giuseppe Cavallaro , Jose Abreu , Thomas Petazzoni , Herve Codina , =?UTF-8?B?TWlxdcOobA==?= Raynal , Milan Stevanovic , Jimmy Lalande , Pascal Eberhard , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII converter driver Message-ID: <20220616091222.4dbf9de3@fixe.home> In-Reply-To: <20220614223109.603935fb@kernel.org> References: <20220610103712.550644-1-clement.leger@bootlin.com> <20220610103712.550644-6-clement.leger@bootlin.com> <20220614223109.603935fb@kernel.org> Organization: Bootlin X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Le Tue, 14 Jun 2022 22:31:09 -0700, Jakub Kicinski a =C3=A9crit : > On Fri, 10 Jun 2022 12:37:01 +0200 Cl=C3=A9ment L=C3=A9ger wrote: > > Subject: [PATCH RESEND net-next v7 05/16] net: pcs: add Renesas MII con= verter driver > >=20 > > Add a PCS driver for the MII converter that is present on the Renesas > > RZ/N1 SoC. This MII converter is reponsible for converting MII to > > RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to > > reuse it in both the switch driver and the stmmac driver. Currently, > > this driver only allows the PCS to be used by the dual Cortex-A7 > > subsystem since the register locking system is not used. =20 >=20 > Could someone with MII &| PCS knowledge cast an eye over this code? > All I can do is point out error path issues... >=20 > > +struct phylink_pcs *miic_create(struct device *dev, struct device_node= *np) > > +{ > > + struct platform_device *pdev; > > + struct miic_port *miic_port; > > + struct device_node *pcs_np; > > + struct miic *miic; > > + u32 port; > > + > > + if (!of_device_is_available(np)) > > + return ERR_PTR(-ENODEV); > > + > > + if (of_property_read_u32(np, "reg", &port)) > > + return ERR_PTR(-EINVAL); > > + > > + if (port > MIIC_MAX_NR_PORTS || port < 1) > > + return ERR_PTR(-EINVAL); > > + > > + /* The PCS pdev is attached to the parent node */ > > + pcs_np =3D of_get_parent(np); =20 >=20 > of_get_parent()? .. >=20 > > + if (!pcs_np) > > + return ERR_PTR(-ENODEV); > > + > > + if (!of_device_is_available(pcs_np)) > > + return ERR_PTR(-ENODEV); =20 >=20 > .. more like of_leak_parent() Indeed, I'll fix that. >=20 > > + pdev =3D of_find_device_by_node(pcs_np); > > + if (!pdev || !platform_get_drvdata(pdev)) > > + return ERR_PTR(-EPROBE_DEFER); > > + > > + miic_port =3D kzalloc(sizeof(*miic_port), GFP_KERNEL); > > + if (!miic_port) > > + return ERR_PTR(-ENOMEM); > > + > > + miic =3D platform_get_drvdata(pdev); > > + device_link_add(dev, miic->dev, DL_FLAG_AUTOREMOVE_CONSUMER); > > + > > + miic_port->miic =3D miic; > > + miic_port->port =3D port - 1; > > + miic_port->pcs.ops =3D &miic_phylink_ops; > > + > > + return &miic_port->pcs; > > +} > > +EXPORT_SYMBOL(miic_create); =20 >=20 > > +static int miic_parse_dt(struct device *dev, u32 *mode_cfg) > > +{ > > + s8 dt_val[MIIC_MODCTRL_CONF_CONV_NUM]; > > + struct device_node *np =3D dev->of_node; > > + struct device_node *conv; > > + u32 conf; > > + int port; > > + > > + memset(dt_val, MIIC_MODCTRL_CONF_NONE, sizeof(dt_val)); > > + > > + of_property_read_u32(np, "renesas,miic-switch-portin", &conf); > > + dt_val[0] =3D conf; > > + > > + for_each_child_of_node(np, conv) { > > + if (of_property_read_u32(conv, "reg", &port)) > > + continue; > > + > > + if (!of_device_is_available(conv)) > > + continue; > > + > > + if (of_property_read_u32(conv, "renesas,miic-input", &conf) =3D=3D 0) > > + dt_val[port] =3D conf; > > + > > + of_node_put(conv); =20 >=20 > Don't these iteration functions put() the current before taking the > next one all by themselves? Or is there supposed to be a "break" here? Yes, of_node_put() should actually only be called in case of early exit. I'll fix that. --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com