RFC: miiphy changes
Hello,
For my custom board, I've had to make some changes to the 'miiphy' code
in order to handle 'IEEE 802.3ae clause 25' framing. While similar to the typical MDIO framing, this 10GbE extension adds a couple of operation types and uses a different start delimiter.
The existing miiphy code defines a structure with read and write function pointers:
struct mii_dev {
struct list_head link;
char *name;
int (* read)(char *devname, unsigned char addr,
unsigned char reg, unsigned short *value);
int (* write)(char *devname, unsigned char addr,
unsigned char reg, unsigned short value);
};None of the implementations in the U-boot tree make use of the 'char *devname' parameter, and I'd like to change it to a more useful pointer. Not knowing the history of this code, I'm wary of unintended consequences. I'd obviously prefer to not break anybody's out-of-tree code, but that can never be guaranteed.
If anyone has anecdotes or opinions, please let me know. Otherwise, I'll submit a patch within the next few days.
regards,
Ben
Quoted 7 lines · Ben Warren
None of the implementations in the U-boot tree make use of the 'char *devname' parameter, and I'd like to change it to a more useful pointer. Not knowing the history of this code, I'm wary of unintended consequences. I'd obviously prefer to not break anybody's out-of-tree code, but that can never be guaranteed.
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.
Quoted 3 lines
If anyone has anecdotes or opinions, please let me know. Otherwise, I'll submit a patch within the next few days.
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
Haavard,
Quoted 11 lines · --- Haavard Skinnemoen
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;
};Quoted 18 lines
How about passing a pointer to the associated
mii_dev, allowing the
driver to embed themii_devinto a driver-specific struct and usecontainer_of()to access the driver-specific data?This would of course involve changing the declaration of the
miiphy_register()function to take a 'structmii_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 'structmii_dev' statically or as part of a larger
allocation.
Quoted 7 lines
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