Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 340575
b: refs/heads/master
c: 215b13d
h: refs/heads/master
i:
  340573: fd1c71a
  340571: da907ff
  340567: e261954
  340559: 858ee76
  340543: bac38be
v: v3
  • Loading branch information
Richard Cochran authored and David S. Miller committed Nov 1, 2012
1 parent b9aef03 commit e050822
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a24006ed12616bde1bbdb26868495906a212d8dc
refs/heads/master: 215b13dd288c2e1e4461c1530a801f5f83e8cd90
32 changes: 32 additions & 0 deletions trunk/drivers/ptp/ptp_chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
{
struct ptp_clock_caps caps;
struct ptp_clock_request req;
struct ptp_sys_offset sysoff;
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
struct ptp_clock_info *ops = ptp->info;
struct ptp_clock_time *pct;
struct timespec ts;
int enable, err = 0;
unsigned int i;

switch (cmd) {

Expand Down Expand Up @@ -88,6 +92,34 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
err = ops->enable(ops, &req, enable);
break;

case PTP_SYS_OFFSET:
if (copy_from_user(&sysoff, (void __user *)arg,
sizeof(sysoff))) {
err = -EFAULT;
break;
}
if (sysoff.n_samples > PTP_MAX_SAMPLES) {
err = -EINVAL;
break;
}
pct = &sysoff.ts[0];
for (i = 0; i < sysoff.n_samples; i++) {
getnstimeofday(&ts);
pct->sec = ts.tv_sec;
pct->nsec = ts.tv_nsec;
pct++;
ptp->info->gettime(ptp->info, &ts);
pct->sec = ts.tv_sec;
pct->nsec = ts.tv_nsec;
pct++;
}
getnstimeofday(&ts);
pct->sec = ts.tv_sec;
pct->nsec = ts.tv_nsec;
if (copy_to_user((void __user *)arg, &sysoff, sizeof(sysoff)))
err = -EFAULT;
break;

default:
err = -ENOTTY;
break;
Expand Down
14 changes: 14 additions & 0 deletions trunk/include/uapi/linux/ptp_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,26 @@ struct ptp_perout_request {
unsigned int rsv[4]; /* Reserved for future use. */
};

#define PTP_MAX_SAMPLES 25 /* Maximum allowed offset measurement samples. */

struct ptp_sys_offset {
unsigned int n_samples; /* Desired number of measurements. */
unsigned int rsv[3]; /* Reserved for future use. */
/*
* Array of interleaved system/phc time stamps. The kernel
* will provide 2*n_samples + 1 time stamps, with the last
* one as a system time stamp.
*/
struct ptp_clock_time ts[2 * PTP_MAX_SAMPLES + 1];
};

#define PTP_CLK_MAGIC '='

#define PTP_CLOCK_GETCAPS _IOR(PTP_CLK_MAGIC, 1, struct ptp_clock_caps)
#define PTP_EXTTS_REQUEST _IOW(PTP_CLK_MAGIC, 2, struct ptp_extts_request)
#define PTP_PEROUT_REQUEST _IOW(PTP_CLK_MAGIC, 3, struct ptp_perout_request)
#define PTP_ENABLE_PPS _IOW(PTP_CLK_MAGIC, 4, int)
#define PTP_SYS_OFFSET _IOW(PTP_CLK_MAGIC, 5, struct ptp_sys_offset)

struct ptp_extts_event {
struct ptp_clock_time t; /* Time event occured. */
Expand Down

0 comments on commit e050822

Please sign in to comment.