From patchwork Sun Jul 8 14:26:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 1169701 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by patchwork1.kernel.org (Postfix) with ESMTP id 0763F40134 for ; Sun, 8 Jul 2012 14:39:22 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id q68ER171019889; Sun, 8 Jul 2012 09:27:01 -0500 Received: from DFLE71.ent.ti.com (dfle71.ent.ti.com [128.247.5.62]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q68ER1Uu021466; Sun, 8 Jul 2012 09:27:01 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by dfle71.ent.ti.com (128.247.5.62) with Microsoft SMTP Server id 14.1.323.3; Sun, 8 Jul 2012 09:27:01 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id q68ER0UA030035; Sun, 8 Jul 2012 09:27:00 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 6992B80627; Sun, 8 Jul 2012 09:27:00 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp20.itg.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by linux.omap.com (Postfix) with ESMTP id F15FF80626 for ; Sun, 8 Jul 2012 09:26:58 -0500 (CDT) Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q68EQrm2027536; Sun, 8 Jul 2012 19:56:53 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Sun, 8 Jul 2012 19:56:53 +0530 Received: from [172.24.81.158] (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q68EQlmV028608; Sun, 8 Jul 2012 19:56:48 +0530 Message-ID: <4FF998A7.50309@ti.com> Date: Sun, 8 Jul 2012 19:56:47 +0530 From: Sekhar Nori User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Heiko Schocher Subject: Re: [PATCH v5 4/7] ARM: davinci: net: davinci_emac: add OF support References: <1338373143-7467-1-git-send-email-hs@denx.de> <1338373143-7467-5-git-send-email-hs@denx.de> In-Reply-To: <1338373143-7467-5-git-send-email-hs@denx.de> CC: , Wolfgang Denk , , , Grant Likely , Anatoly Sivov , X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Hi Heiko, On 5/30/2012 3:49 PM, Heiko Schocher wrote: > add of support for the davinci_emac driver. > > Signed-off-by: Heiko Schocher > Cc: davinci-linux-open-source@linux.davincidsp.com > Cc: linux-arm-kernel@lists.infradead.org > Cc: devicetree-discuss@lists.ozlabs.org > Cc: netdev@vger.kernel.org > Cc: Grant Likely > Cc: Sekhar Nori > Cc: Wolfgang Denk > Cc: Anatoly Sivov > > --- > +#ifdef CONFIG_OF > +static struct emac_platform_data > + *davinci_emac_of_get_pdata(struct platform_device *pdev, > + struct emac_priv *priv) > +{ > + struct device_node *np; > + struct emac_platform_data *pdata = NULL; > + const u8 *mac_addr; > + u32 data; > + int ret; > + > + pdata = pdev->dev.platform_data; > + if (!pdata) { > + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); > + if (!pdata) > + goto nodata; > + } > + > + np = pdev->dev.of_node; > + if (!np) > + goto nodata; > + else > + pdata->version = EMAC_VERSION_2; > + > + mac_addr = of_get_mac_address(np); > + if (mac_addr) > + memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); I suspect that even in the DT case, many boards will continue to read mac address from on-board EEPROMs or from an on-chip eFUSE. To take care of such cases, I propose use mac address in DT data only if no valid address is passed through platform data. The attached patch does this change. If you are OK with this modification, can you please merge it and repost just this patch for review? Please CC David Miller (davem@davemloft.net) on your next post as he is the netdev maintainer and this patch needs to be merged through him or at least needs his ack. With this modification, you can add my: Acked-by: Sekhar Nori Thanks, Sekhar ---8<---- diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 645618d..6b4b0fe 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1795,9 +1795,11 @@ static struct emac_platform_data else pdata->version = EMAC_VERSION_2; - mac_addr = of_get_mac_address(np); - if (mac_addr) - memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); + if (!is_valid_ether_addr(pdata->mac_addr)) { + mac_addr = of_get_mac_address(np); + if (mac_addr) + memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); + } ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data); if (!ret)