From patchwork Fri Aug 21 15:56:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 509553 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id F1795140187 for ; Sat, 22 Aug 2015 01:56:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=GvcU2PEa; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6794E4B656; Fri, 21 Aug 2015 17:56:49 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VphTVH-O_Www; Fri, 21 Aug 2015 17:56:49 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E3ACE4B632; Fri, 21 Aug 2015 17:56:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B30A54B632 for ; Fri, 21 Aug 2015 17:56:45 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R8GHgCyh5iPM for ; Fri, 21 Aug 2015 17:56:45 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f178.google.com (mail-io0-f178.google.com [209.85.223.178]) by theia.denx.de (Postfix) with ESMTPS id 4E0054B62B for ; Fri, 21 Aug 2015 17:56:41 +0200 (CEST) Received: by iodv127 with SMTP id v127so86157497iod.3 for ; Fri, 21 Aug 2015 08:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=JP6GPvLm4FI1HFaUzvXd/Es585JYpTIujxaxR2EkW8I=; b=GvcU2PEa/Bc3Uu7LlM1kBwlCgr0H4dSan1I+5hR99piKJo/Hrd9ufG/nOVUX0q8ejz Sq0B3MIWkRZbOtKRZg77ftGwTlgpWwEfvdtGoO7DGoxZVk4dvu1yswGieXhDb3sIJ7k1 gqZCrWp4DP9lxQ5dK5U1nNWAIHV4etb6OV5SI09ppCSFUmp6NF/s/FkJFui5FmjHsQi9 KUhNKSntQ+/UCG9Tmg2Vq3qX7ZrKu9GBdcKwEgMEER+B/bdjMzcnDqX0VI2vYtzz3VTV m8RyQpkxOSPosHj7yrLrQbseW/TrxvxK+nlYkKsA5KUkCZCDowykKBAteZ8YkwE7xRa5 R1RA== X-Received: by 10.107.34.3 with SMTP id i3mr9717782ioi.109.1440172600230; Fri, 21 Aug 2015 08:56:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.240.235 with HTTP; Fri, 21 Aug 2015 08:56:20 -0700 (PDT) In-Reply-To: <20150821112558.GA21772@og3k.com> References: <1439400246-20472-1-git-send-email-andrew.ruder@elecsyscorp.com> <1439400246-20472-4-git-send-email-andrew.ruder@elecsyscorp.com> <20150821112558.GA21772@og3k.com> From: Joe Hershberger Date: Fri, 21 Aug 2015 10:56:20 -0500 Message-ID: To: Andrew Ruder Cc: u-boot Subject: Re: [U-Boot] [PATCH V2 3/5] dm9000: Add struct eth_device * to SROM functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" Hi Andrew, On Fri, Aug 21, 2015 at 6:25 AM, Andrew Ruder wrote: > On Wed, Aug 12, 2015 at 02:07:20PM -0500, Joe Hershberger wrote: >> On Wed, Aug 12, 2015 at 12:24 PM, Andrew Ruder >> wrote: >> > /****************** function prototypes **********************/ >> > #if !defined(CONFIG_DM9000_NO_SROM) >> > -void dm9000_write_srom_word(int offset, u16 val); >> > -void dm9000_read_srom_word(int offset, u8 *to); >> > +struct eth_device; >> > + >> > +void dm9000_write_srom_word(struct eth_device *dev, int offset, u16 val); >> > +void dm9000_read_srom_word(struct eth_device *dev, int offset, u8 *to); >> >> It will be better to pass the dm9000_priv* instead. See patch 5 for details. > > Even on the "public"-facing functions? Your question got me looking closer at why are these public. These are public just so that a command (presumably only available on one board - trizepsiv) can access the eeprom of a dm9000. It also currently assumes that there is only one dm9000 on that board. I think it should not expose any internal dm9000 struct. Here's what I mocked up: Naturally the dev variable will be unused so it would need to not actually be added until the patch that adds the used to the macro. -Joe diff --git a/board/trizepsiv/eeprom.c b/board/trizepsiv/eeprom.c index 1318edc..93c5733 100644 --- a/board/trizepsiv/eeprom.c +++ b/board/trizepsiv/eeprom.c @@ -16,7 +16,7 @@ static int do_read_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char * for (i=0; i < 0x40; i++) { if (!(i % 0x10)) printf("\n%08x:", i); - dm9000_read_srom_word(i, data); + dm9000_read_srom_word(0, i, data); printf(" %02x%02x", data[1], data[0]); } printf ("\n"); @@ -35,7 +35,7 @@ static int do_write_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char * printf("Wrong offset : 0x%x\n",offset); return cmd_usage(cmdtp); } - dm9000_write_srom_word(offset, value); + dm9000_write_srom_word(0, offset, value); return (0); } diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index 3c41cec..8299f55 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -530,8 +530,10 @@ static int dm9000_rx(struct eth_device *netdev) Read a word data from SROM */ #if !defined(CONFIG_DM9000_NO_SROM) -void dm9000_read_srom_word(int offset, u8 *to) +void dm9000_read_srom_word(int adapter_no, int offset, u8 *to) { + struct eth_device *dev = eth_get_dev_by_index(adapter_no); + DM9000_iow(DM9000_EPAR, offset); DM9000_iow(DM9000_EPCR, 0x4); udelay(8000); @@ -540,8 +542,10 @@ void dm9000_read_srom_word(int offset, u8 *to) to[1] = DM9000_ior(DM9000_EPDRH); } -void dm9000_write_srom_word(int offset, u16 val) +void dm9000_write_srom_word(int adapter_no, int offset, u16 val) { + struct eth_device *dev = eth_get_dev_by_index(adapter_no); + DM9000_iow(DM9000_EPAR, offset); DM9000_iow(DM9000_EPDRH, ((val >> 8) & 0xff)); DM9000_iow(DM9000_EPDRL, (val & 0xff)); diff --git a/include/dm9000.h b/include/dm9000.h index 42b04fa..27d69cf 100644 --- a/include/dm9000.h +++ b/include/dm9000.h @@ -10,8 +10,8 @@ /****************** function prototypes **********************/ #if !defined(CONFIG_DM9000_NO_SROM) -void dm9000_write_srom_word(int offset, u16 val); -void dm9000_read_srom_word(int offset, u8 *to); +void dm9000_write_srom_word(int adapter_no, int offset, u16 val); +void dm9000_read_srom_word(int adapter_no, int offset, u8 *to); #endif #endif /* __DM9000_H__ */