[PATCH v2] phy: Track power-on and init counts in uclass
Alper Nebi Yasak
alpernebiyasak at gmail.com
Wed Dec 29 23:01:06 CET 2021
On 28/12/2021 11:34, Simon Glass wrote:
> Should add comments for the struct
I can do that and send as a v3.
> Also I wonder if a simple fixed-length array might be possible instead
> of the linked list?
I think it's possible, my first prototype was something like:
#define MAX_PHYS 16
struct phy_uc_priv {
int power_on_count[MAX_PHYS];
int init_count[MAX_PHYS];
};
uc_priv = dev_get_uclass_priv(phy->dev);
uc_priv->power_on_count[phy->id];
uc_priv->init_count[phy->id];
UCLASS_DRIVER(phy) = {
...
.per_device_auto = sizeof(struct phy_uc_priv),
}
But I rewrote as a linked list because I couldn't decide on a reasonable
value for that MAX_PHYS. Best guess I have is from
drivers/phy/cadence/phy-cadence-sierra.c which defines SIERRA_MAX_LANES
as 16.
As array-of-structs, I guess things would be roughly:
#define MAX_PHYS 16
struct phy_counts {
int power_on_count;
int init_count;
};
counts = dev_get_uclass_priv(phy->dev)[phy->id];
counts->power_on_count;
counts->init_count;
UCLASS_DRIVER(phy) = {
...
.per_device_auto = sizeof(struct phy_counts[MAX_PHYS]),
}
Should I change to that?
More information about the U-Boot
mailing list