[PATCH RFC net-next 3/9] net: pcs: xpcs: add custom platform register accessors
Mohd Ayaan Anwar
mohd.anwar at oss.qualcomm.com
Wed Sep 23 05:37:01 PDT 2026
On Wed, Sep 23, 2026 at 02:18:17PM +0200, Andrew Lunn wrote:
> On Wed, Sep 23, 2026 at 06:37:29AM +0530, Mohd Ayaan Anwar wrote:
> > + if (pxpcs->ops)
> > + return pxpcs->ops->reg_read(pxpcs->pdev, pxpcs->reg_base,
> > + MDIO_MMD_VEND2, reg);
> > +
> > if (pxpcs->reg_indir)
> > return xpcs_mmio_read_reg_indirect(pxpcs, MDIO_MMD_VEND2, reg);
> > else
>
> Ugly.
>
> How about changing pxpcs->reg_indir to an enum, with values indirect, direct.
>
> One patch.
>
> Then look at
>
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "direct") ?:
> platform_get_resource_byname(pdev, IORESOURCE_MEM, "indirect");
> if (!res) {
> dev_err(dev, "No reg-space found\n");
> return -EINVAL;
> }
>
> if (!strcmp(res->name, "indirect"))
> pxpcs->reg_indir = true;
>
> if (pxpcs->reg_indir)
> spc_size = pxpcs->reg_width * SZ_256;
> else
> spc_size = pxpcs->reg_width * SZ_2M;
>
> Look how easy it is to cleanly extend this with a new resource name?
> And add accessors using the funky mapping your device has. Another
> patch.
>
That's a better idea. I was debating whether using pcs-xpcs-plat.c
with this HW was a good idea, but what you are proposing should hide
away the ugliness. Thank you for the suggestion.
Ayaan
More information about the linux-arm-kernel
mailing list