@@ -662,17 +662,12 @@ static int nsim_init_netdevsim(struct netdevsim *ns)
struct mock_phc *phc;
int err;
- phc = mock_phc_create(&ns->nsim_bus_dev->dev);
- if (IS_ERR(phc))
- return PTR_ERR(phc);
-
- ns->phc = phc;
ns->netdev->netdev_ops = &nsim_netdev_ops;
ns->netdev->stat_ops = &nsim_stat_ops;
err = nsim_udp_tunnels_info_create(ns->nsim_dev, ns->netdev);
if (err)
- goto err_phc_destroy;
+ return err;
rtnl_lock();
err = nsim_queue_init(ns);
@@ -690,8 +685,18 @@ static int nsim_init_netdevsim(struct netdevsim *ns)
if (err)
goto err_ipsec_teardown;
rtnl_unlock();
+
+ phc = mock_phc_create(ns->netdev);
+ if (IS_ERR(phc)) {
+ err = PTR_ERR(phc);
+ goto err_register_netdevice;
+ }
+
+ ns->phc = phc;
return 0;
+err_register_netdevice:
+ unregister_netdevice(ns->netdev);
err_ipsec_teardown:
nsim_ipsec_teardown(ns);
nsim_macsec_teardown(ns);
@@ -701,8 +706,6 @@ static int nsim_init_netdevsim(struct netdevsim *ns)
err_utn_destroy:
rtnl_unlock();
nsim_udp_tunnels_info_destroy(ns->netdev);
-err_phc_destroy:
- mock_phc_destroy(ns->phc);
return err;
}
@@ -115,7 +115,7 @@ int mock_phc_index(struct mock_phc *phc)
}
EXPORT_SYMBOL_GPL(mock_phc_index);
-struct mock_phc *mock_phc_create(struct device *dev)
+struct mock_phc *mock_phc_create(struct net_device *dev)
{
struct mock_phc *phc;
int err;
@@ -147,7 +147,7 @@ struct mock_phc *mock_phc_create(struct device *dev)
spin_lock_init(&phc->lock);
timecounter_init(&phc->tc, &phc->cc, 0);
- phc->clock = ptp_clock_register(&phc->info, dev);
+ phc->clock = netdev_ptp_clock_register(&phc->info, dev);
if (IS_ERR(phc->clock)) {
err = PTR_ERR(phc->clock);
goto out_free_phc;
@@ -13,13 +13,13 @@ struct mock_phc;
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK_MOCK)
-struct mock_phc *mock_phc_create(struct device *dev);
+struct mock_phc *mock_phc_create(struct net_device *dev);
void mock_phc_destroy(struct mock_phc *phc);
int mock_phc_index(struct mock_phc *phc);
#else
-static inline struct mock_phc *mock_phc_create(struct device *dev)
+static inline struct mock_phc *mock_phc_create(struct net_device *dev)
{
return NULL;
}