Linux 6.9-rc1
[linux-2.6-microblaze.git] / lib / genalloc.c
index 00fc50d..4fa5635 100644 (file)
@@ -32,7 +32,9 @@
 #include <linux/rculist.h>
 #include <linux/interrupt.h>
 #include <linux/genalloc.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <linux/vmalloc.h>
 
 static inline size_t chunk_size(const struct gen_pool_chunk *chunk)
@@ -40,32 +42,30 @@ static inline size_t chunk_size(const struct gen_pool_chunk *chunk)
        return chunk->end_addr - chunk->start_addr + 1;
 }
 
-static int set_bits_ll(unsigned long *addr, unsigned long mask_to_set)
+static inline int
+set_bits_ll(unsigned long *addr, unsigned long mask_to_set)
 {
-       unsigned long val, nval;
+       unsigned long val = READ_ONCE(*addr);
 
-       nval = *addr;
        do {
-               val = nval;
                if (val & mask_to_set)
                        return -EBUSY;
                cpu_relax();
-       } while ((nval = cmpxchg(addr, val, val | mask_to_set)) != val);
+       } while (!try_cmpxchg(addr, &val, val | mask_to_set));
 
        return 0;
 }
 
-static int clear_bits_ll(unsigned long *addr, unsigned long mask_to_clear)
+static inline int
+clear_bits_ll(unsigned long *addr, unsigned long mask_to_clear)
 {
-       unsigned long val, nval;
+       unsigned long val = READ_ONCE(*addr);
 
-       nval = *addr;
        do {
-               val = nval;
                if ((val & mask_to_clear) != mask_to_clear)
                        return -EBUSY;
                cpu_relax();
-       } while ((nval = cmpxchg(addr, val, val & ~mask_to_clear)) != val);
+       } while (!try_cmpxchg(addr, &val, val & ~mask_to_clear));
 
        return 0;
 }
@@ -897,7 +897,7 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
 
                of_property_read_string(np_pool, "label", &name);
                if (!name)
-                       name = np_pool->name;
+                       name = of_node_full_name(np_pool);
        }
        if (pdev)
                pool = gen_pool_get(&pdev->dev, name);