From: Ben Warren Date: Sat, 20 Jan 2007 06:53:46 -0800 (PST) Subject: [U-Boot-Users] RFC: miiphy changes In-Reply-To: <1defaf580701200434m2609dca1m2b541eaf6471ba5b@mail.gmail.com> Message-ID: <857580.78087.qm@web307.biz.mail.mud.yahoo.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Haavard, --- Haavard Skinnemoen wrote: > Don't know what you mean by a "more useful" pointer, > but I think the > idea is good. I have an out-of-tree ethernet driver > supporting > multiple interfaces, and one of the things I've been > wondering about > is how to know which of the two I'm supposed to use > for the MII stuff. > > Looking at the code again, I suspect the thing > doesn't even work. Oh well. I was trying to keep my message short, and left out some details. Here's my proposed structure. I think you'll agree that the pointer is "more useful" struct mii_dev { struct list_head link; char *name; int (* read)(struct mii_dev *dev, unsigned char addr, unsigned char reg, unsigned short *value); int (* write)(struct mii_dev *dev, unsigned char addr, unsigned char reg, unsigned short value); int (* read_noninc)(struct mii_dev *dev, unsigned char addr, unsigned char reg, unsigned short *value); int (* address)(struct mii_dev *dev, unsigned char addr, unsigned char reg, unsigned short value); unsigned char flags; }; > How about passing a pointer to the associated > mii_dev, allowing the > driver to embed the mii_dev into a driver-specific > struct and use > container_of() to access the driver-specific data? > > This would of course involve changing the > declaration of the > miiphy_register() function to take a 'struct > mii_dev' instead of all > of the other parameters, but this would in turn > allow us to remove > most of the code from that function, and it would > allow drivers to > allocate its 'struct mii_dev' statically or as part > of a larger > allocation. > > Ok, maybe it's too intrusive and the out-of-tree > maintainers will get > angry, but I have to admit that I don't really care > that much ;-) > > Haavard > Looks like we're on the same wavelength... cheers, Ben