]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/hwspinlock/hwspinlock_core.c
Merge tag 'linux-can-fixes-for-5.5-20191208' of git://git.kernel.org/pub/scm/linux...
[linux.git] / drivers / hwspinlock / hwspinlock_core.c
index 8862445aa85805d0f19570a50c7c4f0387bc5a1e..fd5f5c5a5244d623e01cea6923339efdbfd8177f 100644 (file)
@@ -92,8 +92,8 @@ int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
 {
        int ret;
 
-       BUG_ON(!hwlock);
-       BUG_ON(!flags && mode == HWLOCK_IRQSTATE);
+       if (WARN_ON(!hwlock || (!flags && mode == HWLOCK_IRQSTATE)))
+               return -EINVAL;
 
        /*
         * This spin_lock{_irq, _irqsave} serves three purposes:
@@ -264,8 +264,8 @@ EXPORT_SYMBOL_GPL(__hwspin_lock_timeout);
  */
 void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
 {
-       BUG_ON(!hwlock);
-       BUG_ON(!flags && mode == HWLOCK_IRQSTATE);
+       if (WARN_ON(!hwlock || (!flags && mode == HWLOCK_IRQSTATE)))
+               return;
 
        /*
         * We must make sure that memory operations (both reads and writes),
@@ -657,13 +657,15 @@ static int __hwspin_lock_request(struct hwspinlock *hwlock)
 
        /* notify PM core that power is now needed */
        ret = pm_runtime_get_sync(dev);
-       if (ret < 0) {
+       if (ret < 0 && ret != -EACCES) {
                dev_err(dev, "%s: can't power on device\n", __func__);
                pm_runtime_put_noidle(dev);
                module_put(dev->driver->owner);
                return ret;
        }
 
+       ret = 0;
+
        /* mark hwspinlock as used, should not fail */
        tmp = radix_tree_tag_clear(&hwspinlock_tree, hwlock_to_id(hwlock),
                                                        HWSPINLOCK_UNUSED);
@@ -820,9 +822,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock)
        }
 
        /* notify the underlying device that power is not needed */
-       ret = pm_runtime_put(dev);
-       if (ret < 0)
-               goto out;
+       pm_runtime_put(dev);
 
        /* mark this hwspinlock as available */
        tmp = radix_tree_tag_set(&hwspinlock_tree, hwlock_to_id(hwlock),