Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp167220iog; Tue, 14 Jun 2022 22:51:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU2CmcsYnryPgdwjztO2F/0KKrmyIdBPAT0cH1U3uEMqW1SSxqjWOjL9DlcquOjpG1EBew X-Received: by 2002:a63:5b04:0:b0:3fc:61a1:da0d with SMTP id p4-20020a635b04000000b003fc61a1da0dmr7487684pgb.177.1655272295707; Tue, 14 Jun 2022 22:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655272295; cv=none; d=google.com; s=arc-20160816; b=j+rG4NcKKFHOhfGUjlXcBgsm40yPJ3vYGWvckImqxwvGoQrqGgcSA8tpwEOC0HpK8Z g15vRLnn1ErqK58L/mRFtPX49q24RXadHd2uLZNUZi8nkVdOo7ybbqihrzngTXnFrXqM sjCrOQow+wwI/kqbVfJ6+S8oKDS1Sxt3MHtG6QZRuDkrG15X11Nc+ALYUGKnwH2qHtQk GnzjxRTTC/31vjCwKnSrexkwAZRvtTbUn21YGBQtIGNCGMc62wcAYYj+C88fFLlj/+cL bVA4/Fa1iPi+/j07nMPobJzMKaKMOJxHHqoYEhnBbNIPgagrY3BdkW73emQaZ4Hk/p7S E4bQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=RYaSxLGwggfR4kIcWPQWA2869F9scYiYjj55tR1ZQoA=; b=guvgXFF2fpPtlnR6OQcc2Qv7k/cb65JeJdJzfHPwj2UTRjJcWtdqrtkdy01JNL2+QR 4+mFvoh+kriPPFQBo5d7Kk0StbHHsqyK/2XQfFBi0ZAEL037QanpCpfjj7VUa3P4h8YK QCFPyO7UXoLWZzLa9xDrUhevW1Sc97zN5LRNp+KnMNmBUNhkOWEr9GMH6Qb0ipWN3Xx3 PHpQYCvjM2j5x7wt4CzvhpHcKMIL0IAgocVlNtxLSSL5pOZSydbWMgCAMxQZ08NaPTcc hzlEQPPFzLtETz6RAwRmL3W+3AN+IsR/fGPmd+v/y4YzHn5+d+owEZes7ifiks1vPo90 Irig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=epqJaVYU; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a630207000000b003fe24364064si15645533pgc.822.2022.06.14.22.51.24; Tue, 14 Jun 2022 22:51:35 -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=@kernel.org header.s=k20201202 header.b=epqJaVYU; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240434AbiFOFbT (ORCPT + 99 others); Wed, 15 Jun 2022 01:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234510AbiFOFbP (ORCPT ); Wed, 15 Jun 2022 01:31:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2992E49C99; Tue, 14 Jun 2022 22:31:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C0BDAB81C36; Wed, 15 Jun 2022 05:31:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 645AFC34115; Wed, 15 Jun 2022 05:31:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655271071; bh=UP9/PPlSi1ds0ci9Dk+oUiyvyIrwws3/Ir1Z5PIAGWQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=epqJaVYUaaMbXOx6dxJme+50GCKJAN4hmd5ydrTMcFCZlBo2stNqNuemRouFNq3tJ seV6Df3/hG0OxFbINgCBRbEDAuzC3sWMlmPDjEeyVH8yspGMNrkD9vnGZ3jGo1aMdF WPUbnybKGsI8+bJg3BFaEW/lSvXsGWzvfnlI61Dxpc4f0VybKTBeXPVJdTf65SKRpt p0LIdJp9HYocDl3zqK+Yd0rP3JjxQAxUb3CBzTMsCwF73VFwWfOmp0OCtGaz+mDUpa D449yXNvobGB3j6Hqqmtc819Xed4vlDnRsPemlzYBkfTVjg7TJFCs6EeHz7+aXAxxC Oivda28Tyf4Bw== Date: Tue, 14 Jun 2022 22:31:09 -0700 From: Jakub Kicinski To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , Russell King Cc: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , 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: <20220614223109.603935fb@kernel.org> In-Reply-To: <20220610103712.550644-6-clement.leger@bootlin.com> References: <20220610103712.550644-1-clement.leger@bootlin.com> <20220610103712.550644-6-clement.leger@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 conve= rter 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. Could someone with MII &| PCS knowledge cast an eye over this code? All I can do is point out error path issues... > +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); of_get_parent()? .. > + if (!pcs_np) > + return ERR_PTR(-ENODEV); > + > + if (!of_device_is_available(pcs_np)) > + return ERR_PTR(-ENODEV); .. more like of_leak_parent() > + 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); > +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); 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? > + } > + > + return miic_match_dt_conf(dev, dt_val, mode_cfg); > +}