From: Richard Cochran <richardcoch...@gmail.com> Date: Sun, 16 Mar 2014 14:29:22 +0100
> + /* Check to see if any other pin previously had this function. */ > + if (mutex_lock_interruptible(&ptp->pincfg_mux)) > + return -ERESTARTSYS; > + 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; > + } > + } > + mutex_unlock(&ptp->pincfg_mux); ... > + if (mutex_lock_interruptible(&ptp->pincfg_mux)) > + return -ERESTARTSYS; > + pin2->func = func; > + pin2->chan = chan; > + if (pin1) { > + pin1->func = PTP_PF_NONE; > + pin1->chan = 0; > + } > + mutex_unlock(&ptp->pincfg_mux); > + > + return 0; This locking seems unnecessarily complex to me. You should be able to do the stateless sanity checks, take the mutex, then do all of the rest of the operations until the end of the function before dropping the lock. So just take the lock once over the operations that need it. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/