[PATCH] phy: core: Make 'phy_optional_get' return NULL when not implemented

Sascha Hauer sha at pengutronix.de
Mon Nov 1 02:00:39 PDT 2021


On Wed, Oct 20, 2021 at 10:39:54AM +0200, Daniel Brát wrote:
> Make 'phy_optional_get' return NULL instead of ERR_PTR(-ENOSYS) when the
> CONFIG_GENERIC_PHY is not enabled. It makes more sense to return NULL instead
> of straight up throwing a error since the function has 'optional' in its name.
> This also fixes dwc2 usb driver which would previously fail inside its probe
> function despite being able to function without a phy just fine.

The phy is only optional as long as none is specified in the device
tree. When there is one specified then it's no longer optional. We can't
do the right thing here without checking the device tree. Given that
it's simple to enable CONFIG_GENERIC_PHY I think this is the way to go.

How about issuing a warning in the phy_optional_get stub? That would
point the user in the right direction.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list