]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
DSP: Clean up memory allocation return values
authorTony Lindgren <tony@atomide.com>
Wed, 28 Nov 2007 23:33:49 +0000 (15:33 -0800)
committerTony Lindgren <tony@atomide.com>
Fri, 30 Nov 2007 19:50:59 +0000 (11:50 -0800)
Clean up memory allocation return values

Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap1/mmu.c
arch/arm/plat-omap/mcbsp.c
arch/arm/plat-omap/mmu.c
include/asm-arm/arch-omap/dsp_common.h

index c7cb4ff15e357737974d5f59954ccb680d14c14b..2d05708de7a0be8de91db2228e801cbd9cf3d0d1 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/err.h>
 #include "mmu.h"
 #include <asm/tlbflush.h>
-#include <asm/arch/dsp.h>
 #include <asm/arch/dsp_common.h>
 
 static void *dspvect_page;
index a17b5ae1f6e23e46a78c232c0de4998ba1d208ea..4083cf51d7168066335e6689e6fc9473cfcbfdaa 100644 (file)
@@ -28,8 +28,8 @@
 #include <asm/arch/dma.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/irqs.h>
-#include <asm/arch/mcbsp.h>
 #include <asm/arch/dsp_common.h>
+#include <asm/arch/mcbsp.h>
 
 #ifdef CONFIG_MCBSP_DEBUG
 #define DBG(x...)      printk(x)
@@ -197,7 +197,14 @@ static int omap_mcbsp_check(unsigned int id)
 static void omap_mcbsp_dsp_request(void)
 {
        if (cpu_is_omap15xx() || cpu_is_omap16xx()) {
-               omap_dsp_request_mem();
+               int ret;
+
+               ret = omap_dsp_request_mem();
+               if (ret < 0) {
+                       printk(KERN_ERR "Could not get dsp memory: %i\n", ret);
+                       return;
+               }
+
                clk_enable(mcbsp_dsp_ck);
                clk_enable(mcbsp_api_ck);
 
index c92afd6a9f9a9b8805cec7513c1abe9489db7d80..c80d411d185370005af1aa9f77fbfe5721a2d19f 100644 (file)
@@ -588,9 +588,12 @@ int omap_mmu_load_tlb_entry(struct omap_mmu *mmu,
 {
        struct omap_mmu_tlb_lock lock;
        struct cam_ram_regset *cr;
+       int ret;
 
        clk_enable(mmu->clk);
-       omap_dsp_request_mem();
+       ret = omap_dsp_request_mem();
+       if (ret < 0)
+               goto out;
 
        omap_mmu_get_tlb_lock(mmu, &lock);
        for (lock.victim = 0; lock.victim < lock.base; lock.victim++) {
@@ -624,6 +627,7 @@ found_victim:
        omap_mmu_set_tlb_lock(mmu, &lock);
 
        omap_dsp_release_mem();
+out:
        clk_disable(mmu->clk);
        return 0;
 }
@@ -638,11 +642,13 @@ omap_mmu_cam_va(struct omap_mmu *mmu, struct cam_ram_regset *cr)
 int omap_mmu_clear_tlb_entry(struct omap_mmu *mmu, unsigned long vadr)
 {
        struct omap_mmu_tlb_lock lock;
-       int i;
+       int i, ret = 0;
        int max_valid = 0;
 
        clk_enable(mmu->clk);
-       omap_dsp_request_mem();
+       ret = omap_dsp_request_mem();
+       if (ret < 0)
+               goto out;
 
        omap_mmu_get_tlb_lock(mmu, &lock);
        for (i = 0; i < lock.base; i++) {
@@ -666,23 +672,28 @@ int omap_mmu_clear_tlb_entry(struct omap_mmu *mmu, unsigned long vadr)
        omap_mmu_set_tlb_lock(mmu, &lock);
 
        omap_dsp_release_mem();
+out:
        clk_disable(mmu->clk);
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(omap_mmu_clear_tlb_entry);
 
 static void omap_mmu_gflush(struct omap_mmu *mmu)
 {
        struct omap_mmu_tlb_lock lock;
+       int ret;
 
        clk_enable(mmu->clk);
-       omap_dsp_request_mem();
+       ret = omap_dsp_request_mem();
+       if (ret < 0)
+               goto out;
 
        omap_mmu_write_reg(mmu, 0x1, OMAP_MMU_GFLUSH);
        lock.base = lock.victim = mmu->nr_exmap_preserved;
        omap_mmu_set_tlb_lock(mmu, &lock);
 
        omap_dsp_release_mem();
+out:
        clk_disable(mmu->clk);
 }
 
@@ -1073,7 +1084,10 @@ static int omap_mmu_init(struct omap_mmu *mmu)
        int ret = 0;
 
        clk_enable(mmu->clk);
-       omap_dsp_request_mem();
+       ret = omap_dsp_request_mem();
+       if (ret < 0)
+               goto out;
+
        down_write(&mmu->exmap_sem);
 
        ret = request_irq(mmu->irq, omap_mmu_interrupt, IRQF_DISABLED,
@@ -1093,9 +1107,10 @@ static int omap_mmu_init(struct omap_mmu *mmu)
 
        if (unlikely(mmu->ops->startup))
                ret = mmu->ops->startup(mmu);
- fail:
+fail:
        up_write(&mmu->exmap_sem);
        omap_dsp_release_mem();
+out:
        clk_disable(mmu->clk);
 
        return ret;
@@ -1309,15 +1324,18 @@ static ssize_t omap_mmu_show(struct device *dev, struct device_attribute *attr,
 {
        struct omap_mmu *mmu = dev_get_drvdata(dev);
        struct omap_mmu_tlb_lock tlb_lock;
-       int ret = -EIO;
+       int ret;
 
        clk_enable(mmu->clk);
-       omap_dsp_request_mem();
+       ret = omap_dsp_request_mem();
+       if (ret < 0)
+               goto out;
 
        down_read(&mmu->exmap_sem);
 
        omap_mmu_get_tlb_lock(mmu, &tlb_lock);
 
+       ret = -EIO;
        if (likely(mmu->ops->show))
                ret = mmu->ops->show(mmu, buf, &tlb_lock);
 
@@ -1326,6 +1344,7 @@ static ssize_t omap_mmu_show(struct device *dev, struct device_attribute *attr,
 
        up_read(&mmu->exmap_sem);
        omap_dsp_release_mem();
+out:
        clk_disable(mmu->clk);
 
        return ret;
index a11deedcd0e4953b51b65f8e7af2c431a3f00838..c52b6c65df06abe85f36a89c0fdc91281f8afdf3 100644 (file)
@@ -66,8 +66,11 @@ extern void omap_dsp_release_mpui(void);
 extern int omap_dsp_request_mem(void);
 extern int omap_dsp_release_mem(void);
 #elif defined(CONFIG_ARCH_OMAP2)
-#define omap_dsp_request_mem() do { } while (0)
-#define omap_dsp_release_mem() do { } while (0)
+static inline int omap_dsp_request_mem(void)
+{
+       return 0;
+}
+#define omap_dsp_release_mem() do {} while (0)
 #endif
 
 #endif /* ASM_ARCH_DSP_COMMON_H */