/* Check to see if any other pin previously had this function. */ for (i = 0; i < info->n_pins; i++) { if (info->pin_config[i].func == func &&
info->pin_config[i].chan == chan) {
pin1 = &info->pin_config[i]; break;
}
} if (pin1 && i == pin) return 0;
/* Check the desired function and channel. */ switch (func) { case PTP_PF_NONE: break; case PTP_PF_EXTTS: if (chan >= info->n_ext_ts) return -EINVAL; break; case PTP_PF_PEROUT: if (chan >= info->n_per_out) return -EINVAL; break; case PTP_PF_PHYSYNC: if (chan != 0) return -EINVAL; break; default: return -EINVAL;
}
if (info->verify(info, pin, func, chan)) {
pr_err("driver cannot use function %u and channel %u on pin %u\n",
func, chan, pin); return -EOPNOTSUPP;
}
/* Disable whatever function was previously assigned. */ if (pin1) {
ptp_disable_pinfunc(info, func, chan);
pin1->func = PTP_PF_NONE;
pin1->chan = 0;
}
ptp_disable_pinfunc(info, pin2->func, pin2->chan);
pin2->func = func;
pin2->chan = chan;
if (copy_from_user(&req.extts, arg, sizeof(req.extts))) return -EFAULT;
if (cmd == PTP_EXTTS_REQUEST2) { /* Tell the drivers to check the flags carefully. */
req.extts.flags |= PTP_STRICT_FLAGS; /* Make sure no reserved bit is set. */ if ((req.extts.flags & ~PTP_EXTTS_VALID_FLAGS) ||
req.extts.rsv[0] || req.extts.rsv[1]) return -EINVAL;
/* Ensure one of the rising/falling edge bits is set. */ if ((req.extts.flags & PTP_ENABLE_FEATURE) &&
(req.extts.flags & PTP_EXTTS_EDGES) == 0) return -EINVAL;
} else {
req.extts.flags &= PTP_EXTTS_V1_VALID_FLAGS;
memset(req.extts.rsv, 0, sizeof(req.extts.rsv));
}
if (req.extts.index >= ops->n_ext_ts) return -EINVAL;
supported_extts_flags = ptp->info->supported_extts_flags; /* The PTP_ENABLE_FEATURE flag is always supported. */
supported_extts_flags |= PTP_ENABLE_FEATURE; /* If the driver does not support strictly checking flags, the * PTP_RISING_EDGE and PTP_FALLING_EDGE flags are merely hints * which are not enforced.
*/ if (!(supported_extts_flags & PTP_STRICT_FLAGS))
supported_extts_flags |= PTP_EXTTS_EDGES; /* Reject unsupported flags */ if (req.extts.flags & ~supported_extts_flags) return -EOPNOTSUPP;
if (copy_from_user(perout, arg, sizeof(*perout))) return -EFAULT;
if (cmd == PTP_PEROUT_REQUEST2) { if (perout->flags & ~PTP_PEROUT_VALID_FLAGS) return -EINVAL;
/* * The "on" field has undefined meaning if * PTP_PEROUT_DUTY_CYCLE isn't set, we must still treat it * as reserved, which must be set to zero.
*/ if (!(perout->flags & PTP_PEROUT_DUTY_CYCLE) &&
!mem_is_zero(perout->rsv, sizeof(perout->rsv))) return -EINVAL;
if (perout->flags & PTP_PEROUT_DUTY_CYCLE) { /* The duty cycle must be subunitary. */ if (perout->on.sec > perout->period.sec ||
(perout->on.sec == perout->period.sec &&
perout->on.nsec > perout->period.nsec)) return -ERANGE;
}
if (perout->flags & PTP_PEROUT_PHASE) { /* * The phase should be specified modulo the period, * therefore anything equal or larger than 1 period * is invalid.
*/ if (perout->phase.sec > perout->period.sec ||
(perout->phase.sec == perout->period.sec &&
perout->phase.nsec >= perout->period.nsec)) return -ERANGE;
}
} else {
perout->flags &= PTP_PEROUT_V1_VALID_FLAGS;
memset(perout->rsv, 0, sizeof(perout->rsv));
}
if (perout->index >= ops->n_per_out) return -EINVAL; if (perout->flags & ~ops->supported_perout_flags) return -EOPNOTSUPP;
extoff = memdup_user(arg, sizeof(*extoff)); if (IS_ERR(extoff)) return PTR_ERR(extoff);
if (extoff->n_samples > PTP_MAX_SAMPLES || extoff->rsv[0] || extoff->rsv[1]) return -EINVAL;
switch (extoff->clockid) { case CLOCK_REALTIME: case CLOCK_MONOTONIC: case CLOCK_MONOTONIC_RAW: break; case CLOCK_AUX ... CLOCK_AUX_LAST: if (IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS)) break;
fallthrough; default: return -EINVAL;
}
sts.clockid = extoff->clockid; for (unsignedint i = 0; i < extoff->n_samples; i++) { struct timespec64 ts; int err;
err = ptp->info->gettimex64(ptp->info, &ts, &sts); if (err) return err;
/* Filter out disabled or unavailable clocks */ if (sts.pre_ts.tv_sec < 0 || sts.post_ts.tv_sec < 0) return -EINVAL;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.