[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1596815885-11094-1-git-send-email-min.li.xe@renesas.com>
Date: Fri, 7 Aug 2020 11:58:05 -0400
From: <min.li.xe@...esas.com>
To: <richardcochran@...il.com>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Min Li <min.li.xe@...esas.com>
Subject: [PATCH net 3/4] ptp: ptp_idt82p33: use do_aux_work for delay work
From: Min Li <min.li.xe@...esas.com>
Instead of declaring its own delay_work, use ptp_clock provided do_aux_work
to configure sync_tod.
Signed-off-by: Min Li <min.li.xe@...esas.com>
---
drivers/ptp/ptp_idt82p33.c | 24 ++++++++++++------------
drivers/ptp/ptp_idt82p33.h | 2 --
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/ptp/ptp_idt82p33.c b/drivers/ptp/ptp_idt82p33.c
index 189bb81..2d62aed 100644
--- a/drivers/ptp/ptp_idt82p33.c
+++ b/drivers/ptp/ptp_idt82p33.c
@@ -531,8 +531,8 @@ static int idt82p33_sync_tod(struct idt82p33_channel *channel, bool enable)
if (enable == channel->sync_tod_on) {
if (enable && sync_tod_timeout) {
- mod_delayed_work(system_wq, &channel->sync_tod_work,
- sync_tod_timeout * HZ);
+ ptp_schedule_worker(channel->ptp_clock,
+ sync_tod_timeout * HZ);
}
return 0;
}
@@ -555,24 +555,27 @@ static int idt82p33_sync_tod(struct idt82p33_channel *channel, bool enable)
channel->sync_tod_on = enable;
if (enable && sync_tod_timeout) {
- mod_delayed_work(system_wq, &channel->sync_tod_work,
- sync_tod_timeout * HZ);
+ ptp_schedule_worker(channel->ptp_clock,
+ sync_tod_timeout * HZ);
}
return 0;
}
-static void idt82p33_sync_tod_work_handler(struct work_struct *work)
+static long idt82p33_sync_tod_work_handler(struct ptp_clock_info *ptp)
{
struct idt82p33_channel *channel =
- container_of(work, struct idt82p33_channel, sync_tod_work.work);
+ container_of(ptp, struct idt82p33_channel, caps);
struct idt82p33 *idt82p33 = channel->idt82p33;
+ int ret;
mutex_lock(&idt82p33->reg_lock);
- (void)idt82p33_sync_tod(channel, false);
+ ret = idt82p33_sync_tod(channel, false);
mutex_unlock(&idt82p33->reg_lock);
+
+ return ret;
}
static int idt82p33_pps_enable(struct idt82p33_channel *channel, bool enable)
@@ -659,10 +662,8 @@ static void idt82p33_ptp_clock_unregister_all(struct idt82p33 *idt82p33)
channel = &idt82p33->channel[i];
- if (channel->ptp_clock) {
+ if (channel->ptp_clock)
ptp_clock_unregister(channel->ptp_clock);
- cancel_delayed_work_sync(&channel->sync_tod_work);
- }
}
}
@@ -862,8 +863,6 @@ static int idt82p33_channel_init(struct idt82p33_channel *channel, int index)
return -EINVAL;
}
- INIT_DELAYED_WORK(&channel->sync_tod_work,
- idt82p33_sync_tod_work_handler);
channel->sync_tod_on = false;
channel->current_freq_ppb = 0;
@@ -881,6 +880,7 @@ static void idt82p33_caps_init(struct ptp_clock_info *caps)
caps->gettime64 = idt82p33_gettime;
caps->settime64 = idt82p33_settime;
caps->enable = idt82p33_enable;
+ caps->do_aux_work = idt82p33_sync_tod_work_handler;
}
static int idt82p33_enable_channel(struct idt82p33 *idt82p33, u32 index)
diff --git a/drivers/ptp/ptp_idt82p33.h b/drivers/ptp/ptp_idt82p33.h
index 9d46966..1dcd2c0 100644
--- a/drivers/ptp/ptp_idt82p33.h
+++ b/drivers/ptp/ptp_idt82p33.h
@@ -119,8 +119,6 @@ struct idt82p33_channel {
struct ptp_clock *ptp_clock;
struct idt82p33 *idt82p33;
enum pll_mode pll_mode;
- /* task to turn off SYNC_TOD bit after pps sync */
- struct delayed_work sync_tod_work;
bool sync_tod_on;
s32 current_freq_ppb;
u8 output_mask;
--
2.7.4
Powered by blists - more mailing lists