[SPARC64] constify of_get_property return: include
[linux-2.6.git] / include / asm-sparc64 / parport.h
index 56b5197..6340a52 100644 (file)
  */
 #define HAS_DMA
 
+static DEFINE_SPINLOCK(dma_spin_lock);
+
+#define claim_dma_lock() \
+({     unsigned long flags; \
+       spin_lock_irqsave(&dma_spin_lock, flags); \
+       flags; \
+})
+
+#define release_dma_lock(__flags) \
+       spin_unlock_irqrestore(&dma_spin_lock, __flags);
+
 static struct sparc_ebus_info {
        struct ebus_dma_info info;
        unsigned int addr;
        unsigned int count;
+       int lock;
 } sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
 
+static __inline__ int request_dma(unsigned int dmanr, const char *device_id)
+{
+       if (dmanr >= PARPORT_PC_MAX_PORTS)
+               return -EINVAL;
+       if (xchg(&sparc_ebus_dmas[dmanr].lock, 1) != 0)
+               return -EBUSY;
+       return 0;
+}
+
+static __inline__ void free_dma(unsigned int dmanr)
+{
+       if (dmanr >= PARPORT_PC_MAX_PORTS) {
+               printk(KERN_WARNING "Trying to free DMA%d\n", dmanr);
+               return;
+       }
+       if (xchg(&sparc_ebus_dmas[dmanr].lock, 0) == 0) {
+               printk(KERN_WARNING "Trying to free free DMA%d\n", dmanr);
+               return;
+       }       
+}
+
 static __inline__ void enable_dma(unsigned int dmanr)
 {
        ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1);
@@ -67,18 +100,17 @@ static __inline__ unsigned int get_dma_residue(unsigned int dmanr)
 
 static int ebus_ecpp_p(struct linux_ebus_device *edev)
 {
-       if (!strcmp(edev->prom_name, "ecpp"))
+       if (!strcmp(edev->prom_node->name, "ecpp"))
                return 1;
-       if (!strcmp(edev->prom_name, "parallel")) {
-               char compat[19];
-               prom_getstring(edev->prom_node,
-                              "compatible",
-                              compat, sizeof(compat));
-               compat[18] = '\0';
-               if (!strcmp(compat, "ecpp"))
-                       return 1;
-               if (!strcmp(compat, "ns87317-ecpp") &&
-                   !strcmp(compat + 13, "ecpp"))
+       if (!strcmp(edev->prom_node->name, "parallel")) {
+               const char *compat;
+
+               compat = of_get_property(edev->prom_node,
+                                        "compatible", NULL);
+               if (compat &&
+                   (!strcmp(compat, "ecpp") ||
+                    !strcmp(compat, "ns87317-ecpp") ||
+                    !strcmp(compat + 13, "ecpp")))
                        return 1;
        }
        return 0;
@@ -94,12 +126,12 @@ static int parport_isa_probe(int count)
                        struct sparc_isa_device *child;
                        unsigned long base;
 
-                       if (strcmp(isa_dev->prom_name, "dma"))
+                       if (strcmp(isa_dev->prom_node->name, "dma"))
                                continue;
 
                        child = isa_dev->child;
                        while (child) {
-                               if (!strcmp(child->prom_name, "parallel"))
+                               if (!strcmp(child->prom_node->name, "parallel"))
                                        break;
                                child = child->next;
                        }