On Fri 2020-10-30 12:44:33, Marek BehĂșn wrote: > Add a new integer member phyindex to struct phy_device. This member is > unique for every phy_device. Atomic incrementation occurs in > phy_device_register. > > This can be used for example in LED sysfs API. The LED subsystem names > each LED in format `device:color:function`, but currently the PHY device > names are not suited for this, since in some situations a PHY device > name can look like this > d0032004.mdio-mii:01 > or even like this > !soc!internal-regs@d0000000!mdio@32004!switch0@10!mdio:08 > Clearly this cannot be used as the `device` part of a LED name. > > Signed-off-by: Marek BehĂșn <[email protected]>
Atomic should _not_ be neccessary for this. Just make sure access is
serialised by some existing lock.
Pavel
> @@ -892,6 +893,7 @@ EXPORT_SYMBOL(get_phy_device);
> */
> int phy_device_register(struct phy_device *phydev)
> {
> + static atomic_t phyindex;
> int err;
>
> err = mdiobus_register_device(&phydev->mdio);
> @@ -908,6 +910,7 @@ int phy_device_register(struct phy_device *phydev)
> goto out;
> }
>
> + phydev->phyindex = atomic_inc_return(&phyindex) - 1;
> err = device_add(&phydev->mdio.dev);
> if (err) {
> phydev_err(phydev, "failed to add\n");
--
http://www.livejournal.com/~pavelmachek
signature.asc
Description: PGP signature
