/* Save the new parameters */
pps->params = params;
/* Restore the read only parameters */ if ((params.mode & (PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)) == 0) { /* section 3.3 of RFC 2783 interpreted */
dev_dbg(&pps->dev, "time format unspecified (%x)\n",
params.mode);
pps->params.mode |= PPS_TSFMT_TSPEC;
} if (pps->info.mode & PPS_CANWAIT)
pps->params.mode |= PPS_CANWAIT;
pps->params.api_version = PPS_API_VERS;
/* * Clear unused fields of pps_kparams to avoid leaking * uninitialized data of the PPS_SETPARAMS caller via * PPS_GETPARAMS
*/
pps->params.assert_off_tu.flags = 0;
pps->params.clear_off_tu.flags = 0;
spin_unlock_irq(&pps->lock);
break;
case PPS_GETCAP:
dev_dbg(&pps->dev, "PPS_GETCAP\n");
err = put_user(pps->info.mode, iuarg); if (err) return -EFAULT;
break;
case PPS_FETCH: { struct pps_fdata fdata;
dev_dbg(&pps->dev, "PPS_FETCH\n");
err = copy_from_user(&fdata, uarg, sizeof(struct pps_fdata)); if (err) return -EFAULT;
err = pps_cdev_pps_fetch(pps, &fdata); if (err) return err;
/* Return the fetched timestamp and save last fetched event */
spin_lock_irq(&pps->lock);
int pps_register_cdev(struct pps_device *pps)
{ int err;
mutex_lock(&pps_idr_lock); /* * Get new ID for the new PPS source. After idr_alloc() calling * the new source will be freely available into the kernel.
*/
err = idr_alloc(&pps_idr, pps, 0, PPS_MAX_SOURCES, GFP_KERNEL); if (err < 0) { if (err == -ENOSPC) {
pr_err("%s: too many PPS sources in the system\n",
pps->info.name);
err = -EBUSY;
}
kfree(pps); goto out_unlock;
}
pps->id = err;
/* Now we can release the ID for re-use */
mutex_lock(&pps_idr_lock);
idr_remove(&pps_idr, pps->id);
put_device(&pps->dev);
mutex_unlock(&pps_idr_lock);
}
/* * Look up a pps device by magic cookie. * The cookie is usually a pointer to some enclosing device, but this * code doesn't care; you should never be dereferencing it. * * This is a bit of a kludge that is currently used only by the PPS * serial line discipline. It may need to be tweaked when a second user * is found. * * There is no function interface for setting the lookup_cookie field. * It's initialized to NULL when the pps device is created, and if a * client wants to use it, just fill it in afterward. * * The cookie is automatically set to NULL in pps_unregister_source() * so that it will not be used again, even if the pps device cannot * be removed from the idr due to pending references holding the minor * number in use. * * Since pps_idr holds a reference to the device, the returned * pps_device is guaranteed to be valid until pps_unregister_cdev() is * called on it. But after calling pps_unregister_cdev(), it may be * freed at any time.
*/ struct pps_device *pps_lookup_dev(voidconst *cookie)
{ struct pps_device *pps; unsigned id;
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.