hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
kernel/drivers/base/regmap/regmap.c
....@@ -14,6 +14,7 @@
1414 #include <linux/property.h>
1515 #include <linux/rbtree.h>
1616 #include <linux/sched.h>
17
+#include <linux/dovetail.h>
1718 #include <linux/delay.h>
1819 #include <linux/log2.h>
1920 #include <linux/hwspinlock.h>
....@@ -523,6 +524,23 @@
523524 spin_unlock_irqrestore(&map->spinlock, map->spinlock_flags);
524525 }
525526
527
+static void regmap_lock_oob(void *__map)
528
+__acquires(&map->oob_lock)
529
+{
530
+ struct regmap *map = __map;
531
+ unsigned long flags;
532
+
533
+ raw_spin_lock_irqsave(&map->oob_lock, flags);
534
+ map->spinlock_flags = flags;
535
+}
536
+
537
+static void regmap_unlock_oob(void *__map)
538
+__releases(&map->oob_lock)
539
+{
540
+ struct regmap *map = __map;
541
+ raw_spin_unlock_irqrestore(&map->oob_lock, map->spinlock_flags);
542
+}
543
+
526544 static void dev_get_regmap_release(struct device *dev, void *res)
527545 {
528546 /*
....@@ -761,18 +779,29 @@
761779 } else {
762780 if ((bus && bus->fast_io) ||
763781 config->fast_io) {
764
- spin_lock_init(&map->spinlock);
765
- map->lock = regmap_lock_spinlock;
766
- map->unlock = regmap_unlock_spinlock;
767
- lockdep_set_class_and_name(&map->spinlock,
768
- lock_key, lock_name);
769
- } else {
782
+ if (dovetailing() && config->oob_io) {
783
+ raw_spin_lock_init(&map->oob_lock);
784
+ map->lock = regmap_lock_oob;
785
+ map->unlock = regmap_unlock_oob;
786
+ lockdep_set_class_and_name(&map->oob_lock,
787
+ lock_key, lock_name);
788
+ } else {
789
+ spin_lock_init(&map->spinlock);
790
+ map->lock = regmap_lock_spinlock;
791
+ map->unlock = regmap_unlock_spinlock;
792
+ lockdep_set_class_and_name(&map->spinlock,
793
+ lock_key, lock_name);
794
+ }
795
+ } else if (!config->oob_io) {
770796 mutex_init(&map->mutex);
771797 map->lock = regmap_lock_mutex;
772798 map->unlock = regmap_unlock_mutex;
773799 map->can_sleep = true;
774800 lockdep_set_class_and_name(&map->mutex,
775801 lock_key, lock_name);
802
+ } else {
803
+ ret = -ENXIO;
804
+ goto err_name;
776805 }
777806 map->lock_arg = map;
778807 }