diff options
Diffstat (limited to 'drivers/ptp')
-rw-r--r-- | drivers/ptp/ptp_chardev.c | 9 | ||||
-rw-r--r-- | drivers/ptp/ptp_clock.c | 17 |
2 files changed, 24 insertions, 2 deletions
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 9d72ab593f13..93d574faf1fe 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -175,7 +175,10 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) } req.type = PTP_CLK_REQ_EXTTS; enable = req.extts.flags & PTP_ENABLE_FEATURE ? 1 : 0; + if (mutex_lock_interruptible(&ptp->pincfg_mux)) + return -ERESTARTSYS; err = ops->enable(ops, &req, enable); + mutex_unlock(&ptp->pincfg_mux); break; case PTP_PEROUT_REQUEST: @@ -206,7 +209,10 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) } req.type = PTP_CLK_REQ_PEROUT; enable = req.perout.period.sec || req.perout.period.nsec; + if (mutex_lock_interruptible(&ptp->pincfg_mux)) + return -ERESTARTSYS; err = ops->enable(ops, &req, enable); + mutex_unlock(&ptp->pincfg_mux); break; case PTP_ENABLE_PPS: @@ -217,7 +223,10 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) return -EPERM; req.type = PTP_CLK_REQ_PPS; enable = arg ? 1 : 0; + if (mutex_lock_interruptible(&ptp->pincfg_mux)) + return -ERESTARTSYS; err = ops->enable(ops, &req, enable); + mutex_unlock(&ptp->pincfg_mux); break; case PTP_SYS_OFFSET_PRECISE: diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index ac1f2bf9e888..acabbe72e55e 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -348,7 +348,6 @@ int ptp_find_pin(struct ptp_clock *ptp, struct ptp_pin_desc *pin = NULL; int i; - mutex_lock(&ptp->pincfg_mux); for (i = 0; i < ptp->info->n_pins; i++) { if (ptp->info->pin_config[i].func == func && ptp->info->pin_config[i].chan == chan) { @@ -356,12 +355,26 @@ int ptp_find_pin(struct ptp_clock *ptp, break; } } - mutex_unlock(&ptp->pincfg_mux); return pin ? i : -1; } EXPORT_SYMBOL(ptp_find_pin); +int ptp_find_pin_unlocked(struct ptp_clock *ptp, + enum ptp_pin_function func, unsigned int chan) +{ + int result; + + mutex_lock(&ptp->pincfg_mux); + + result = ptp_find_pin(ptp, func, chan); + + mutex_unlock(&ptp->pincfg_mux); + + return result; +} +EXPORT_SYMBOL(ptp_find_pin_unlocked); + int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay) { return kthread_mod_delayed_work(ptp->kworker, &ptp->aux_work, delay); |