Skip to content

Commit

Permalink
[POWERPC] Split out the logic that allocates struct iommus
Browse files Browse the repository at this point in the history
Split out the logic that allocates a struct iommu into a separate
function.  This can fail however the calling code has never cared - so
just return if we can't allocate an iommu.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Michael Ellerman authored and Paul Mackerras committed Jan 31, 2008
1 parent 41d824b commit 209bfbb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions arch/powerpc/platforms/cell/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,18 +565,17 @@ static int __init cell_iommu_get_window(struct device_node *np,
return 0;
}

static void __init cell_iommu_init_one(struct device_node *np, unsigned long offset)
static struct cbe_iommu * __init cell_iommu_alloc(struct device_node *np)
{
struct cbe_iommu *iommu;
unsigned long base, size;
int nid, i;

/* Get node ID */
nid = of_node_to_nid(np);
if (nid < 0) {
printk(KERN_ERR "iommu: failed to get node for %s\n",
np->full_name);
return;
return NULL;
}
pr_debug("iommu: setting up iommu for node %d (%s)\n",
nid, np->full_name);
Expand All @@ -592,7 +591,7 @@ static void __init cell_iommu_init_one(struct device_node *np, unsigned long off
if (cbe_nr_iommus >= NR_IOMMUS) {
printk(KERN_ERR "iommu: too many IOMMUs detected ! (%s)\n",
np->full_name);
return;
return NULL;
}

/* Init base fields */
Expand All @@ -603,6 +602,19 @@ static void __init cell_iommu_init_one(struct device_node *np, unsigned long off
snprintf(iommu->name, sizeof(iommu->name), "iommu%d", i);
INIT_LIST_HEAD(&iommu->windows);

return iommu;
}

static void __init cell_iommu_init_one(struct device_node *np,
unsigned long offset)
{
struct cbe_iommu *iommu;
unsigned long base, size;

iommu = cell_iommu_alloc(np);
if (!iommu)
return;

/* Obtain a window for it */
cell_iommu_get_window(np, &base, &size);

Expand Down

0 comments on commit 209bfbb

Please sign in to comment.