static int __devinit ace_probe(struct device *device) { struct platform_device *dev = to_platform_device(device); struct ace_device *ace; int i; dev_dbg(device, "ace_probe(%p)\n", device); /* * Allocate the ace device structure */ ace = kzalloc(sizeof(struct ace_device), GFP_KERNEL); if (!ace) goto err_alloc; ace->dev = device; ace->id = dev->id; ace->irq = NO_IRQ; for (i = 0; i < dev->num_resources; i++) { if (dev->resource[i].flags & IORESOURCE_MEM) ace->physaddr = dev->resource[i].start; if (dev->resource[i].flags & IORESOURCE_IRQ) ace->irq = dev->resource[i].start; } /* FIXME: Should get bus_width from the platform_device struct */ ace->bus_width = 1; dev_set_drvdata(&dev->dev, ace); /* Call the bus-independant setup code */ if (ace_setup(ace) != 0) goto err_setup; return 0; err_setup: dev_set_drvdata(&dev->dev, NULL); kfree(ace); err_alloc: printk(KERN_ERR "xsysace: could not initialize device\n"); return -ENOMEM; }
static int __devinit ace_alloc(struct device *dev, int id, resource_size_t physaddr, int irq, int bus_width) { struct ace_device *ace; int rc; dev_dbg(dev, "ace_alloc(%p)\n", dev); if (!physaddr) { rc = -ENODEV; goto err_noreg; } /* Allocate and initialize the ace device structure */ ace = kzalloc(sizeof(struct ace_device), GFP_KERNEL); if (!ace) { rc = -ENOMEM; goto err_alloc; } ace->dev = dev; ace->id = id; ace->physaddr = physaddr; ace->irq = irq; ace->bus_width = bus_width; /* Call the setup code */ rc = ace_setup(ace); if (rc) goto err_setup; dev_set_drvdata(dev, ace); return 0; err_setup: dev_set_drvdata(dev, NULL); kfree(ace); err_alloc: err_noreg: dev_err(dev, "could not initialize device, err=%i\n", rc); return rc; }