Commit 6c691405 authored by Grygorii Strashko's avatar Grygorii Strashko Committed by David S. Miller

net: ethernet: ti: cpts: fix registration order

The ptp clock registered before spinlock, which is protecting it, and
before timecounter and cyclecounter initialization in cpts_register().

So, ensure that ptp clock is registered the last, after everything
else is done.
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fd123a94
...@@ -356,15 +356,8 @@ int cpts_register(struct device *dev, struct cpts *cpts, ...@@ -356,15 +356,8 @@ int cpts_register(struct device *dev, struct cpts *cpts,
u32 mult, u32 shift) u32 mult, u32 shift)
{ {
int err, i; int err, i;
unsigned long flags;
cpts->info = cpts_info; cpts->info = cpts_info;
cpts->clock = ptp_clock_register(&cpts->info, dev);
if (IS_ERR(cpts->clock)) {
err = PTR_ERR(cpts->clock);
cpts->clock = NULL;
return err;
}
spin_lock_init(&cpts->lock); spin_lock_init(&cpts->lock);
cpts->cc.read = cpts_systim_read; cpts->cc.read = cpts_systim_read;
...@@ -382,15 +375,26 @@ int cpts_register(struct device *dev, struct cpts *cpts, ...@@ -382,15 +375,26 @@ int cpts_register(struct device *dev, struct cpts *cpts,
cpts_write32(cpts, CPTS_EN, control); cpts_write32(cpts, CPTS_EN, control);
cpts_write32(cpts, TS_PEND_EN, int_enable); cpts_write32(cpts, TS_PEND_EN, int_enable);
spin_lock_irqsave(&cpts->lock, flags);
timecounter_init(&cpts->tc, &cpts->cc, ktime_to_ns(ktime_get_real())); timecounter_init(&cpts->tc, &cpts->cc, ktime_to_ns(ktime_get_real()));
spin_unlock_irqrestore(&cpts->lock, flags);
INIT_DELAYED_WORK(&cpts->overflow_work, cpts_overflow_check); INIT_DELAYED_WORK(&cpts->overflow_work, cpts_overflow_check);
schedule_delayed_work(&cpts->overflow_work, CPTS_OVERFLOW_PERIOD);
cpts->clock = ptp_clock_register(&cpts->info, dev);
if (IS_ERR(cpts->clock)) {
err = PTR_ERR(cpts->clock);
cpts->clock = NULL;
goto err_ptp;
}
cpts->phc_index = ptp_clock_index(cpts->clock); cpts->phc_index = ptp_clock_index(cpts->clock);
schedule_delayed_work(&cpts->overflow_work, CPTS_OVERFLOW_PERIOD);
return 0; return 0;
err_ptp:
if (cpts->refclk)
cpts_clk_release(cpts);
return err;
} }
EXPORT_SYMBOL_GPL(cpts_register); EXPORT_SYMBOL_GPL(cpts_register);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment