net: of_get_phy_mode: Change API to solve int/unit warnings
Before this change of_get_phy_mode() returned an enum, phy_interface_t. On error, -ENODEV etc, is returned. If the result of the function is stored in a variable of type phy_interface_t, and the compiler has decided to represent this as an unsigned int, comparision with -ENODEV etc, is a signed vs unsigned comparision. Fix this problem by changing the API. Make the function return an error, or 0 on success, and pass a pointer, of type phy_interface_t, where the phy mode should be stored. v2: Return with *interface set to PHY_INTERFACE_MODE_NA on error. Add error checks to all users of of_get_phy_mode() Fixup a few reverse christmas tree errors Fixup a few slightly malformed reverse christmas trees v3: Fix 0-day reported errors. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
5d1fcaf35d
commit
0c65b2b90d
@@ -2046,7 +2046,9 @@ static int ravb_probe(struct platform_device *pdev)
|
||||
spin_lock_init(&priv->lock);
|
||||
INIT_WORK(&priv->work, ravb_tx_timeout_work);
|
||||
|
||||
priv->phy_interface = of_get_phy_mode(np);
|
||||
error = of_get_phy_mode(np, &priv->phy_interface);
|
||||
if (error && error != -ENODEV)
|
||||
goto out_release;
|
||||
|
||||
priv->no_avb_link = of_property_read_bool(np, "renesas,no-ether-link");
|
||||
priv->avb_link_active_low =
|
||||
|
@@ -3183,6 +3183,7 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
|
||||
{
|
||||
struct device_node *np = dev->of_node;
|
||||
struct sh_eth_plat_data *pdata;
|
||||
phy_interface_t interface;
|
||||
const char *mac_addr;
|
||||
int ret;
|
||||
|
||||
@@ -3190,10 +3191,10 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
|
||||
if (!pdata)
|
||||
return NULL;
|
||||
|
||||
ret = of_get_phy_mode(np);
|
||||
if (ret < 0)
|
||||
ret = of_get_phy_mode(np, &interface);
|
||||
if (ret)
|
||||
return NULL;
|
||||
pdata->phy_interface = ret;
|
||||
pdata->phy_interface = interface;
|
||||
|
||||
mac_addr = of_get_mac_address(np);
|
||||
if (!IS_ERR(mac_addr))
|
||||
|
Reference in New Issue
Block a user