diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-11-11 23:44:31 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-11-11 23:44:31 +0100 |
commit | 90b128ed1557c2f523995a379a53e5105891ecf8 (patch) | |
tree | d64cc5dc7448b0dba62b14565e2d187245f7874e /drivers/mfd/mfd-core.c | |
parent | 5e90169c5a02da69a1ef721bea7a823e9e48fcb6 (diff) | |
parent | 9a46847aeac1148d8b15f0db629c8bbd754dfe24 (diff) | |
download | op-kernel-dev-90b128ed1557c2f523995a379a53e5105891ecf8.zip op-kernel-dev-90b128ed1557c2f523995a379a53e5105891ecf8.tar.gz |
Merge tag 'mfd-lee-3.13-3' of git://git.linaro.org/people/ljones/mfd
mfd-lee-3.13-3
MFD patches due for v3.13 - 2nd round.
Diffstat (limited to 'drivers/mfd/mfd-core.c')
-rw-r--r-- | drivers/mfd/mfd-core.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index f421586..968775d 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -63,7 +63,8 @@ int mfd_cell_disable(struct platform_device *pdev) EXPORT_SYMBOL(mfd_cell_disable); static int mfd_platform_add_cell(struct platform_device *pdev, - const struct mfd_cell *cell) + const struct mfd_cell *cell, + atomic_t *usage_count) { if (!cell) return 0; @@ -72,11 +73,12 @@ static int mfd_platform_add_cell(struct platform_device *pdev, if (!pdev->mfd_cell) return -ENOMEM; + pdev->mfd_cell->usage_count = usage_count; return 0; } static int mfd_add_device(struct device *parent, int id, - const struct mfd_cell *cell, + const struct mfd_cell *cell, atomic_t *usage_count, struct resource *mem_base, int irq_base, struct irq_domain *domain) { @@ -115,7 +117,7 @@ static int mfd_add_device(struct device *parent, int id, goto fail_res; } - ret = mfd_platform_add_cell(pdev, cell); + ret = mfd_platform_add_cell(pdev, cell, usage_count); if (ret) goto fail_res; @@ -180,12 +182,12 @@ fail_alloc: } int mfd_add_devices(struct device *parent, int id, - struct mfd_cell *cells, int n_devs, + const struct mfd_cell *cells, int n_devs, struct resource *mem_base, int irq_base, struct irq_domain *domain) { int i; - int ret = 0; + int ret; atomic_t *cnts; /* initialize reference counting for all cells */ @@ -195,16 +197,19 @@ int mfd_add_devices(struct device *parent, int id, for (i = 0; i < n_devs; i++) { atomic_set(&cnts[i], 0); - cells[i].usage_count = &cnts[i]; - ret = mfd_add_device(parent, id, cells + i, mem_base, + ret = mfd_add_device(parent, id, cells + i, cnts + i, mem_base, irq_base, domain); if (ret) - break; + goto fail; } - if (ret) - mfd_remove_devices(parent); + return 0; +fail: + if (i) + mfd_remove_devices(parent); + else + kfree(cnts); return ret; } EXPORT_SYMBOL(mfd_add_devices); @@ -259,8 +264,8 @@ int mfd_clone_cell(const char *cell, const char **clones, size_t n_clones) for (i = 0; i < n_clones; i++) { cell_entry.name = clones[i]; /* don't give up if a single call fails; just report error */ - if (mfd_add_device(pdev->dev.parent, -1, &cell_entry, NULL, 0, - NULL)) + if (mfd_add_device(pdev->dev.parent, -1, &cell_entry, + cell_entry.usage_count, NULL, 0, NULL)) dev_err(dev, "failed to create platform device '%s'\n", clones[i]); } |