X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fsh%2Fcchips%2Fvoyagergx%2Fconsistent.c;h=5b92585a38d2b3512889557b9cb18e30f78921bc;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=95a309d149b7bccb20d1ac5427fe9224fbe33eec;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/arch/sh/cchips/voyagergx/consistent.c b/arch/sh/cchips/voyagergx/consistent.c index 95a309d14..5b92585a3 100644 --- a/arch/sh/cchips/voyagergx/consistent.c +++ b/arch/sh/cchips/voyagergx/consistent.c @@ -23,7 +23,7 @@ struct voya_alloc_entry { unsigned long len; }; -static spinlock_t voya_list_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(voya_list_lock); static LIST_HEAD(voya_alloc_list); #define OHCI_SRAM_START 0xb0000000 @@ -49,13 +49,13 @@ void *voyagergx_consistent_alloc(struct device *dev, size_t size, if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] || (dev->bus == &sh_bus_types[SH_BUS_VIRT] && shdev->dev_id != SH_DEV_ID_USB_OHCI)) - return consistent_alloc(flag, size, handle); + return NULL; start = OHCI_SRAM_START + OHCI_HCCA_SIZE; entry = kmalloc(sizeof(struct voya_alloc_entry), GFP_ATOMIC); if (!entry) - return NULL; + return ERR_PTR(-ENOMEM); entry->len = (size + 15) & ~15; @@ -91,11 +91,11 @@ out: kfree(entry); spin_unlock_irqrestore(&voya_list_lock, flags); - return NULL; + return ERR_PTR(-EINVAL); } -void voyagergx_consistent_free(struct device *dev, size_t size, - void *vaddr, dma_addr_t handle) +int voyagergx_consistent_free(struct device *dev, size_t size, + void *vaddr, dma_addr_t handle) { struct voya_alloc_entry *entry; struct sh_dev *shdev = to_sh_dev(dev); @@ -103,10 +103,8 @@ void voyagergx_consistent_free(struct device *dev, size_t size, if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] || (dev->bus == &sh_bus_types[SH_BUS_VIRT] && - shdev->dev_id != SH_DEV_ID_USB_OHCI)) { - consistent_free(vaddr, size); - return; - } + shdev->dev_id != SH_DEV_ID_USB_OHCI)) + return -EINVAL; spin_lock_irqsave(&voya_list_lock, flags); list_for_each_entry(entry, &voya_alloc_list, list) { @@ -119,6 +117,8 @@ void voyagergx_consistent_free(struct device *dev, size_t size, break; } spin_unlock_irqrestore(&voya_list_lock, flags); + + return 0; } EXPORT_SYMBOL(voyagergx_consistent_alloc);