From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Mon, 10 Jul 2017 12:03:52 +0200 Subject: [U-Boot] [PATCH v6 4/5] drivers: phy: add generic_phy_valid() method In-Reply-To: <1499679563-641-5-git-send-email-patrice.chotard@st.com> References: <1499679563-641-1-git-send-email-patrice.chotard@st.com> <1499679563-641-5-git-send-email-patrice.chotard@st.com> Message-ID: <20170710120352.1ed6b391@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi, On Mon, 10 Jul 2017 11:39:22 +0200 patrice.chotard at st.com wrote: > From: Patrice Chotard >=20 > This allow to check if a PHY has been correctly > initialised and avoid to get access to phy struct. >=20 > Signed-off-by: Patrice Chotard > Reviewed-by: Marek Vasut > Reviewed-by: Simon Glass > --- >=20 > v6: _ none > v5: _ none > v4: _ none >=20 >=20 > drivers/phy/phy-uclass.c | 5 +++++ > include/generic-phy.h | 8 ++++++++ > 2 files changed, 13 insertions(+) >=20 > diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c > index 68e518f..8ccd9bc 100644 > --- a/drivers/phy/phy-uclass.c > +++ b/drivers/phy/phy-uclass.c > @@ -131,6 +131,11 @@ int generic_phy_power_off(struct phy *phy) > return ops->power_off ? ops->power_off(phy) : 0; > } > =20 > +bool generic_phy_valid(struct phy *phy) > +{ > + return phy->dev !=3D NULL; > +} > + > UCLASS_DRIVER(phy) =3D { > .id =3D UCLASS_PHY, > .name =3D "phy", > diff --git a/include/generic-phy.h b/include/generic-phy.h > index 762704c..343ad03 100644 > --- a/include/generic-phy.h > +++ b/include/generic-phy.h > @@ -220,4 +220,12 @@ int generic_phy_get_by_index(struct udevice *user, i= nt index, > int generic_phy_get_by_name(struct udevice *user, const char *phy_name, > struct phy *phy); > =20 > +/** > + * generic_phy_valid() - check if PHY port is valid > + * > + * @phy: the PHY port to check > + * @return TRUE if valid, or FALSE > + */ > +bool generic_phy_valid(struct phy *phy); > IMO this qualifies as a candidate for a static inline function. Lothar Wa=C3=9Fmann