Skip to content

Commit

Permalink
ptp: dp83640: convert to the 64 bit get/set time methods.
Browse files Browse the repository at this point in the history
This device stores the number of seconds in a 32 bit register, and the
stored value is unsigned.  Therefore this driver and device are ready
for the year 2038.  However, more work will be needed prior to 2106.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
richardcochran authored and davem330 committed Mar 31, 2015
1 parent b9acf24 commit 41c2c18
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/net/phy/dp83640.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static void ext_write(int broadcast, struct phy_device *phydev,

/* Caller must hold extreg_lock. */
static int tdr_write(int bc, struct phy_device *dev,
const struct timespec *ts, u16 cmd)
const struct timespec64 *ts, u16 cmd)
{
ext_write(bc, dev, PAGE4, PTP_TDR, ts->tv_nsec & 0xffff);/* ns[15:0] */
ext_write(bc, dev, PAGE4, PTP_TDR, ts->tv_nsec >> 16); /* ns[31:16] */
Expand Down Expand Up @@ -411,12 +411,12 @@ static int ptp_dp83640_adjtime(struct ptp_clock_info *ptp, s64 delta)
struct dp83640_clock *clock =
container_of(ptp, struct dp83640_clock, caps);
struct phy_device *phydev = clock->chosen->phydev;
struct timespec ts;
struct timespec64 ts;
int err;

delta += ADJTIME_FIX;

ts = ns_to_timespec(delta);
ts = ns_to_timespec64(delta);

mutex_lock(&clock->extreg_lock);

Expand All @@ -427,7 +427,8 @@ static int ptp_dp83640_adjtime(struct ptp_clock_info *ptp, s64 delta)
return err;
}

static int ptp_dp83640_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
static int ptp_dp83640_gettime(struct ptp_clock_info *ptp,
struct timespec64 *ts)
{
struct dp83640_clock *clock =
container_of(ptp, struct dp83640_clock, caps);
Expand All @@ -452,7 +453,7 @@ static int ptp_dp83640_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
}

static int ptp_dp83640_settime(struct ptp_clock_info *ptp,
const struct timespec *ts)
const struct timespec64 *ts)
{
struct dp83640_clock *clock =
container_of(ptp, struct dp83640_clock, caps);
Expand Down Expand Up @@ -605,7 +606,7 @@ static void recalibrate(struct dp83640_clock *clock)
{
s64 now, diff;
struct phy_txts event_ts;
struct timespec ts;
struct timespec64 ts;
struct list_head *this;
struct dp83640_private *tmp;
struct phy_device *master = clock->chosen->phydev;
Expand Down Expand Up @@ -697,7 +698,7 @@ static void recalibrate(struct dp83640_clock *clock)
diff = now - (s64) phy2txts(&event_ts);
pr_info("slave offset %lld nanoseconds\n", diff);
diff += ADJTIME_FIX;
ts = ns_to_timespec(diff);
ts = ns_to_timespec64(diff);
tdr_write(0, tmp->phydev, &ts, PTP_STEP_CLK);
}

Expand Down Expand Up @@ -998,8 +999,8 @@ static void dp83640_clock_init(struct dp83640_clock *clock, struct mii_bus *bus)
clock->caps.pps = 0;
clock->caps.adjfreq = ptp_dp83640_adjfreq;
clock->caps.adjtime = ptp_dp83640_adjtime;
clock->caps.gettime = ptp_dp83640_gettime;
clock->caps.settime = ptp_dp83640_settime;
clock->caps.gettime64 = ptp_dp83640_gettime;
clock->caps.settime64 = ptp_dp83640_settime;
clock->caps.enable = ptp_dp83640_enable;
clock->caps.verify = ptp_dp83640_verify;
/*
Expand Down

0 comments on commit 41c2c18

Please sign in to comment.