lkml.org 
[lkml]   [2022]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v2 net-next] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329
    > +static int davinci_mdiobb_read(struct mii_bus *bus, int phy, int reg)
    > +{
    > + int ret;
    > + struct mdiobb_ctrl *ctrl = bus->priv;
    > + struct davinci_mdio_data *data;
    > +
    > + data = container_of(ctrl, struct davinci_mdio_data, bb_ctrl);
    > +
    > + if (phy & ~PHY_REG_MASK || reg & ~PHY_ID_MASK)
    > + return -EINVAL;

    You don't need this. Leave it up to the bit banging code to do the
    validation. This also breaks C45, which the bit banging code can do,
    and it looks like the hardware cannot.

    > +
    > + ret = pm_runtime_resume_and_get(data->dev);
    > + if (ret < 0)
    > + return ret;
    > +
    > + ret = mdiobb_read(bus, phy, reg);
    > +
    > + pm_runtime_mark_last_busy(data->dev);
    > + pm_runtime_put_autosuspend(data->dev);

    Once you take the validation out, this function then all becomes about
    runtime power management. Should the bit banging core actually be
    doing this? It seems like it is something which could be useful for
    other devices.

    struct mii_bus has a parent member. If set, you could apply these run
    time PM functions to that. Please add a patch to modify the core bit
    banging code, and then you should be able to remove these helpers.

    > static int davinci_mdio_probe(struct platform_device *pdev)
    > {
    > struct mdio_platform_data *pdata = dev_get_platdata(&pdev->dev);
    > @@ -340,12 +535,30 @@ static int davinci_mdio_probe(struct platform_device *pdev)
    > struct phy_device *phy;
    > int ret, addr;
    > int autosuspend_delay_ms = -1;
    > + const struct soc_device_attribute *soc_match_data;

    netdev uses reverse christmas tree. Variables should be sorted longest
    first, shortest last.

    Andrew

    \
     
     \ /
      Last update: 2022-08-11 02:31    [W:4.934 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site