Message ID | 20250408095139.51659-7-ansuelsmth@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | net: dsa: Add Airoha AN8855 support | expand |
Hi Christian, On Tue, 8 Apr 2025 11:51:13 +0200 Christian Marangi <ansuelsmth@gmail.com> wrote: > Rework the valid_addr and convert it to a mask in preparation for mdio > regmap to support multiple valid addr in the case the regmap can support > it. Nice to see more users for this ! > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Maxime
On Tue, Apr 08, 2025 at 11:51:13AM +0200, Christian Marangi wrote: > Rework the valid_addr and convert it to a mask in preparation for mdio > regmap to support multiple valid addr in the case the regmap can support > it. > mr = mii->priv; > mr->regmap = config->regmap; > - mr->valid_addr = config->valid_addr; > + mr->valid_addr_mask = BIT(config->valid_addr); I don't see how this allows you to support multiple addresses. You still only have one bit set in mr->valid_addr_mask. Andrew
On Tue, Apr 08, 2025 at 11:51:13AM +0200, Christian Marangi wrote: > Rework the valid_addr and convert it to a mask in preparation for mdio > regmap to support multiple valid addr in the case the regmap can support > it. I think it would be good to pull these MDIO regmap patches out into a series of their own. We know there is a user, so i'm happy for us the accept it without that user. But this code needs further discusion, which will be irrelevant for the switch. Andrew
On Thu, Apr 10, 2025 at 07:13:34PM +0200, Andrew Lunn wrote: > On Tue, Apr 08, 2025 at 11:51:13AM +0200, Christian Marangi wrote: > > Rework the valid_addr and convert it to a mask in preparation for mdio > > regmap to support multiple valid addr in the case the regmap can support > > it. > > mr = mii->priv; > > mr->regmap = config->regmap; > > - mr->valid_addr = config->valid_addr; > > + mr->valid_addr_mask = BIT(config->valid_addr); > > I don't see how this allows you to support multiple addresses. You > still only have one bit set in mr->valid_addr_mask. > This is really a preparation patch for the next 2 and split from the other to better evaluate the change for the mask.
On Thu, Apr 10, 2025 at 07:18:02PM +0200, Andrew Lunn wrote: > On Tue, Apr 08, 2025 at 11:51:13AM +0200, Christian Marangi wrote: > > Rework the valid_addr and convert it to a mask in preparation for mdio > > regmap to support multiple valid addr in the case the regmap can support > > it. > > I think it would be good to pull these MDIO regmap patches out into a > series of their own. We know there is a user, so i'm happy for us the > accept it without that user. But this code needs further discusion, > which will be irrelevant for the switch. > Ok so how you would like to proceed for the remaining patch? Repost as RFC? Still waiting feedback for nvmem and mfd so I would love to get feedback for them (that are also irrelevant to the switch)
diff --git a/drivers/net/mdio/mdio-regmap.c b/drivers/net/mdio/mdio-regmap.c index 8a742a8d6387..810ba0a736f0 100644 --- a/drivers/net/mdio/mdio-regmap.c +++ b/drivers/net/mdio/mdio-regmap.c @@ -19,7 +19,7 @@ struct mdio_regmap_priv { struct regmap *regmap; - u8 valid_addr; + u32 valid_addr_mask; }; static int mdio_regmap_read_c22(struct mii_bus *bus, int addr, int regnum) @@ -28,7 +28,7 @@ static int mdio_regmap_read_c22(struct mii_bus *bus, int addr, int regnum) unsigned int val; int ret; - if (ctx->valid_addr != addr) + if (!(ctx->valid_addr_mask & BIT(addr))) return -ENODEV; ret = regmap_read(ctx->regmap, regnum, &val); @@ -43,7 +43,7 @@ static int mdio_regmap_write_c22(struct mii_bus *bus, int addr, int regnum, { struct mdio_regmap_priv *ctx = bus->priv; - if (ctx->valid_addr != addr) + if (!(ctx->valid_addr_mask & BIT(addr))) return -ENODEV; return regmap_write(ctx->regmap, regnum, val); @@ -65,7 +65,7 @@ struct mii_bus *devm_mdio_regmap_register(struct device *dev, mr = mii->priv; mr->regmap = config->regmap; - mr->valid_addr = config->valid_addr; + mr->valid_addr_mask = BIT(config->valid_addr); mii->name = DRV_NAME; strscpy(mii->id, config->name, MII_BUS_ID_SIZE); @@ -74,7 +74,7 @@ struct mii_bus *devm_mdio_regmap_register(struct device *dev, mii->write = mdio_regmap_write_c22; if (config->autoscan) - mii->phy_mask = ~BIT(config->valid_addr); + mii->phy_mask = ~mr->valid_addr_mask; else mii->phy_mask = ~0;
Rework the valid_addr and convert it to a mask in preparation for mdio regmap to support multiple valid addr in the case the regmap can support it. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> --- drivers/net/mdio/mdio-regmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)