[Cbe-oss-dev] [PATCH] axonram: 1st version

Michael Ellerman michael at ellerman.id.au
Sat Feb 24 21:49:27 EST 2007


On Fri, 2007-02-16 at 09:33 +0100, Maxim Shchetynin wrote:
> Hello,
> 
> Here is a couple of lines shorter version of axonram driver. I have removed
> all the chrdev stuff and changed the rest of code according your
> recommendations.
> 
> Subject: cell: driver for DDR2 memory on AXON
> 
> From: Maxim Shchetynin <maxim.shchetynin at de.ibm.com>

This patch is whitespace damaged, I applied it by hand, but my patch is
similarly whitespace damaged as a result.

I think you should change the probe routine to check that the size is
non-zero first, that way if you have no memory backing the thing it
doesn't crash horribly. Something like this:

cheers

Index: ecell/arch/powerpc/sysdev/axonram.c
===================================================================
--- ecell.orig/arch/powerpc/sysdev/axonram.c
+++ ecell/arch/powerpc/sysdev/axonram.c
@@ -133,6 +133,15 @@ axon_ram_probe(struct of_device *device,
      struct axon_ram_bank *bank;
      struct resource resource;
 
+     if (of_address_to_resource(device->node, 0, &resource) != 0) {
+           dev_err(&device->dev, "Cannot access device tree\n");
+           return -EFAULT;
+     }
+
+     if (resource.start == resource.end)
+          /* zero size memory bank */
+          return 0;
+
      /* There should be a better solution... */
      axon_ram_bank_id++;
 
@@ -148,12 +157,6 @@ axon_ram_probe(struct of_device *device,
 
      device->dev.platform_data = (void*) bank;
 
-     if (of_address_to_resource(device->node, 0, &resource) != 0) {
-           dev_err(&device->dev, "Cannot access device tree\n");
-           kfree(bank);
-           return -EFAULT;
-     }
-
      bank->device = device;
      bank->size = resource.end - resource.start + 1;
      bank->ph_addr = resource.start;


-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person




More information about the cbe-oss-dev mailing list