Re: [PATCH net-next 1/3] net: phy: add concept of shared storage for PHYs

From: Florian Fainelli
Date: Mon May 04 2020 - 13:45:19 EST




On 5/4/2020 9:38 AM, Michael Walle wrote:
> There are packages which contain multiple PHY devices, eg. a quad PHY
> transceiver. Provide functions to allocate and free shared storage.
>
> Usually, a quad PHY contains global registers, which don't belong to any
> PHY. Provide convenience functions to access these registers.
>
> Signed-off-by: Michael Walle <michael@xxxxxxxx>

This looks pretty good, just a few comments below.

[snip]

> +
> +/**
> + * devm_phy_package_join - resource managed phy_package_join()
> + * @dev: device that is registering this GPIO device

You mean device registering this PHY package here?

[snip]

Might be worth a comment that this is a used as a bit number.

> +
> +#define PHY_SHARED_F_INIT_DONE 0
> +
> /*
> * The Bus class for PHYs. Devices which provide access to
> * PHYs should register using this structure
> @@ -278,6 +301,12 @@ struct mii_bus {
> int reset_delay_us;
> /* RESET GPIO descriptor pointer */
> struct gpio_desc *reset_gpiod;
> +
> + /* protect access to the shared element */
> + struct mutex shared_lock;
> +
> + /* shared state across different PHYs */
> + struct phy_package_shared *shared[PHY_MAX_ADDR];
> };
> #define to_mii_bus(d) container_of(d, struct mii_bus, dev)
>
> @@ -478,6 +507,10 @@ struct phy_device {
> /* For use by PHYs to maintain extra state */
> void *priv;
>
> + /* shared data pointer */
> + /* For use by PHYs inside the same package and needs a shared state. */

s/and needs/that need/
--
Florian