2019-05-27 08:55:06 +02:00
// SPDX-License-Identifier: GPL-2.0-or-later
2014-08-26 13:14:51 +00:00
/**
2020-09-25 15:24:42 -07:00
* DOC : emac_arc . c - ARC EMAC specific glue layer
2014-08-26 13:14:51 +00:00
*
* Copyright ( C ) 2014 Romain Perier
*
* Romain Perier < romain . perier @ gmail . com >
*/
# include <linux/etherdevice.h>
# include <linux/module.h>
# include <linux/of_net.h>
# include <linux/platform_device.h>
# include "emac.h"
# define DRV_NAME "emac_arc"
static int emac_arc_probe ( struct platform_device * pdev )
{
struct device * dev = & pdev - > dev ;
struct arc_emac_priv * priv ;
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>
2019-11-04 02:40:33 +01:00
phy_interface_t interface ;
struct net_device * ndev ;
int err ;
2014-08-26 13:14:51 +00:00
if ( ! dev - > of_node )
return - ENODEV ;
ndev = alloc_etherdev ( sizeof ( struct arc_emac_priv ) ) ;
if ( ! ndev )
return - ENOMEM ;
platform_set_drvdata ( pdev , ndev ) ;
SET_NETDEV_DEV ( ndev , dev ) ;
priv = netdev_priv ( ndev ) ;
priv - > drv_name = DRV_NAME ;
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>
2019-11-04 02:40:33 +01:00
err = of_get_phy_mode ( dev - > of_node , & interface ) ;
if ( err ) {
if ( err = = - ENODEV )
interface = PHY_INTERFACE_MODE_MII ;
else
goto out_netdev ;
}
2014-08-26 13:14:51 +00:00
priv - > clk = devm_clk_get ( dev , " hclk " ) ;
if ( IS_ERR ( priv - > clk ) ) {
dev_err ( dev , " failed to retrieve host clock from device tree \n " ) ;
err = - EINVAL ;
goto out_netdev ;
}
err = arc_emac_probe ( ndev , interface ) ;
out_netdev :
if ( err )
free_netdev ( ndev ) ;
return err ;
}
static int emac_arc_remove ( struct platform_device * pdev )
{
struct net_device * ndev = platform_get_drvdata ( pdev ) ;
int err ;
err = arc_emac_remove ( ndev ) ;
free_netdev ( ndev ) ;
return err ;
}
static const struct of_device_id emac_arc_dt_ids [ ] = {
{ . compatible = " snps,arc-emac " } ,
{ /* Sentinel */ }
} ;
2015-09-18 17:54:00 +02:00
MODULE_DEVICE_TABLE ( of , emac_arc_dt_ids ) ;
2014-08-26 13:14:51 +00:00
static struct platform_driver emac_arc_driver = {
. probe = emac_arc_probe ,
. remove = emac_arc_remove ,
. driver = {
. name = DRV_NAME ,
. of_match_table = emac_arc_dt_ids ,
} ,
} ;
module_platform_driver ( emac_arc_driver ) ;
MODULE_AUTHOR ( " Romain Perier <romain.perier@gmail.com> " ) ;
MODULE_DESCRIPTION ( " ARC EMAC platform driver " ) ;
MODULE_LICENSE ( " GPL " ) ;