From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFC52C48BC2 for ; Sun, 27 Jun 2021 20:00:48 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 32FDF61C20 for ; Sun, 27 Jun 2021 20:00:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32FDF61C20 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0170B82C66; Sun, 27 Jun 2021 22:00:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kaxje4pq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9380A82C6F; Sun, 27 Jun 2021 22:00:43 +0200 (CEST) Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 59AE782C5C for ; Sun, 27 Jun 2021 22:00:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-oi1-x22f.google.com with SMTP id s17so19264936oij.0 for ; Sun, 27 Jun 2021 13:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qlaUlM5f+AaDIMV0VLiBH5z4wBi7AsdbS7kqE4PEA4Q=; b=kaxje4pqY81+kMQBN5LVOo2bt5Gipz13w0cfNm19cbtDq0USZeR8kPpq5XWyW4MIZX ScAz9yCEKCVlDrZMmO29YYXHGcHNHoBPS0G/fwed2EhflktAuJ9g6hlKBzyO9GI4V2aR OdiZr1i2hHEhDzI8XRlly+iWfp6W2jHMatodtxtLtRtrr4ERm2n5OSlW9ylzUnc5CbMT EdDaBCeWHgT0qceyBA+2pGwWd9DuwopWp3HxmJ92VjPMYuaC4bRIAdGjuuIkOroJpSiU wEtkrj+1iQfAoFPJZ9Uid038xkE6svHM9TZfMFsQLDXubFVB7+rKIr8UuOwdgV+33qBb tkRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qlaUlM5f+AaDIMV0VLiBH5z4wBi7AsdbS7kqE4PEA4Q=; b=ErVGnSED7c5TgBOAPwyFplZ7kGlJB/TXzSYp23HtebE03MMQfR+lGCHkjWzp48bYYg mBesc98oR5FfYSFEn6z+x8WdsJVtKZoarQgrxvLBFaroannRWHCLWdBd/rzlQAt9/9KS 8i1efsr2glxJoKjGkvLB9EKAcj2xc1qCUp4MTdgabN9lUhqAspjhFabKFm9qRuje22HB URkmJq6reUgGcbjI2Zt6xFE7YE45MzE3j2ym9bMJPveK37DJ/BVC22iPVJu7CMTjBRCH 3SbvBI7KWTGXjMveKsb9l3vaqs9vA07YpEyLaKXUu27Xq/NvzAJbv5N8IQ53FvkRMyr1 wxTA== X-Gm-Message-State: AOAM530/qdD+gStrNAtjPDnmBoIIGDfmf20FKBx6y8K+8uZadqArZhRv BM4LlOpP21KGToNMnywpeJ55WLSuiTXTlCTIZUw= X-Google-Smtp-Source: ABdhPJxVEintGFqoV9yYhbWkVBK9xzMvzvmSHbibKyQT+9hxnapFeWpLA0/XgLE8DAf3aL+H79rAzwZdPHYzr7khmMU= X-Received: by 2002:aca:4749:: with SMTP id u70mr1646616oia.22.1624824038988; Sun, 27 Jun 2021 13:00:38 -0700 (PDT) MIME-Version: 1.0 References: <20210624063441.24072-1-ashok.reddy.soma@xilinx.com> <20210624063441.24072-2-ashok.reddy.soma@xilinx.com> In-Reply-To: <20210624063441.24072-2-ashok.reddy.soma@xilinx.com> From: Ramon Fried Date: Sun, 27 Jun 2021 23:00:27 +0300 Message-ID: Subject: Re: [PATCH 1/2] net: xilinx: axi_emac: Cleanup of of_to_plat() To: Ashok Reddy Soma Cc: U-Boot Mailing List , Joe Hershberger , Michal Simek , git , somaashokreddy@gmail.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Thu, Jun 24, 2021 at 9:35 AM Ashok Reddy Soma wrote: > > There are lot of accesses to priv data in of_to_plat(), which is incorrect. > Create a platform data structure and use it in of_to_plat(), then copy all > platform data to priv data in probe. > > Signed-off-by: Ashok Reddy Soma > --- > > drivers/net/xilinx_axi_emac.c | 47 ++++++++++++++++++++++++----------- > 1 file changed, 32 insertions(+), 15 deletions(-) > > diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c > index 2ce6271afe..cfc6082475 100644 > --- a/drivers/net/xilinx_axi_emac.c > +++ b/drivers/net/xilinx_axi_emac.c > @@ -87,6 +87,16 @@ struct axidma_reg { > u32 tail_hi; /* TAILDESC high 32 bit */ > }; > > +/* Platform data structures */ > +struct axidma_plat { > + struct eth_pdata eth_pdata; > + struct axidma_reg *dmatx; > + struct axidma_reg *dmarx; > + int phyaddr; > + u8 eth_hasnobuf; > + int phy_of_handle; > +}; > + > /* Private driver structures */ > struct axidma_priv { > struct axidma_reg *dmatx; > @@ -690,9 +700,20 @@ static int axiemac_miiphy_write(struct mii_dev *bus, int addr, int devad, > > static int axi_emac_probe(struct udevice *dev) > { > + struct axidma_plat *plat = dev_get_plat(dev); > + struct eth_pdata *pdata = &plat->eth_pdata; > struct axidma_priv *priv = dev_get_priv(dev); > int ret; > > + priv->iobase = (struct axi_regs *)pdata->iobase; > + priv->dmatx = plat->dmatx; > + /* RX channel offset is 0x30 */ > + priv->dmarx = (struct axidma_reg *)((phys_addr_t)priv->dmatx + 0x30); > + priv->eth_hasnobuf = plat->eth_hasnobuf; > + priv->phyaddr = plat->phyaddr; > + priv->phy_of_handle = plat->phy_of_handle; > + priv->interface = pdata->phy_interface; > + > priv->bus = mdio_alloc(); > priv->bus->read = axiemac_miiphy_read; > priv->bus->write = axiemac_miiphy_write; > @@ -729,14 +750,13 @@ static const struct eth_ops axi_emac_ops = { > > static int axi_emac_of_to_plat(struct udevice *dev) > { > - struct eth_pdata *pdata = dev_get_plat(dev); > - struct axidma_priv *priv = dev_get_priv(dev); > + struct axidma_plat *plat = dev_get_plat(dev); > + struct eth_pdata *pdata = &plat->eth_pdata; > int node = dev_of_offset(dev); > int offset = 0; > const char *phy_mode; > > pdata->iobase = dev_read_addr(dev); > - priv->iobase = (struct axi_regs *)pdata->iobase; > > offset = fdtdec_lookup_phandle(gd->fdt_blob, node, > "axistream-connected"); > @@ -744,21 +764,19 @@ static int axi_emac_of_to_plat(struct udevice *dev) > printf("%s: axistream is not found\n", __func__); > return -EINVAL; > } > - priv->dmatx = (struct axidma_reg *)fdtdec_get_addr(gd->fdt_blob, > + plat->dmatx = (struct axidma_reg *)fdtdec_get_addr(gd->fdt_blob, > offset, "reg"); > - if (!priv->dmatx) { > + if (!plat->dmatx) { > printf("%s: axi_dma register space not found\n", __func__); > return -EINVAL; > } > - /* RX channel offset is 0x30 */ > - priv->dmarx = (struct axidma_reg *)((phys_addr_t)priv->dmatx + 0x30); > > - priv->phyaddr = -1; > + plat->phyaddr = -1; > > offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle"); > if (offset > 0) { > - priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); > - priv->phy_of_handle = offset; > + plat->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); > + plat->phy_of_handle = offset; > } > > phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); > @@ -768,13 +786,12 @@ static int axi_emac_of_to_plat(struct udevice *dev) > printf("%s: Invalid PHY interface '%s'\n", __func__, phy_mode); > return -EINVAL; > } > - priv->interface = pdata->phy_interface; > > - priv->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node, > + plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node, > "xlnx,eth-hasnobuf"); > > - printf("AXI EMAC: %lx, phyaddr %d, interface %s\n", (ulong)priv->iobase, > - priv->phyaddr, phy_string_for_interface(priv->interface)); > + printf("AXI EMAC: %lx, phyaddr %d, interface %s\n", (ulong)pdata->iobase, > + plat->phyaddr, phy_string_for_interface(pdata->phy_interface)); > > return 0; > } > @@ -793,5 +810,5 @@ U_BOOT_DRIVER(axi_emac) = { > .remove = axi_emac_remove, > .ops = &axi_emac_ops, > .priv_auto = sizeof(struct axidma_priv), > - .plat_auto = sizeof(struct eth_pdata), > + .plat_auto = sizeof(struct axidma_plat), > }; > -- > 2.17.1 > Reviewed-by: Ramon Fried