From 4e1842988364446ba0cf2171d1eebb53c15bc44e Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 1 Oct 2019 14:03:26 +0200 Subject: drivers: phy: Handle gracefully NULL pointers For some controllers PHYs can be optional. Handling NULL pointers without crashing nor failing, makes it easy to handle optional PHYs. Signed-off-by: Jean-Jacques Hiblot --- include/generic-phy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/generic-phy.h b/include/generic-phy.h index 947c582f68b..95caf583413 100644 --- a/include/generic-phy.h +++ b/include/generic-phy.h @@ -270,7 +270,7 @@ static inline int generic_phy_get_by_name(struct udevice *user, const char *phy_ */ static inline bool generic_phy_valid(struct phy *phy) { - return phy->dev != NULL; + return phy && phy->dev; } #endif /*__GENERIC_PHY_H */ -- cgit v1.2.3