Skip to contentSkip to conversation

mfd: core: Don't use devres functions before device is added

PATCH Applied Charles Keepax 3 participants 3 messages Apr 24, 2014 – Apr 28, 2014 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: core: Don't use devres functions before device is added

The supply aliases for the MFD devices were being added using devres but the device hasn't been added at this point and as such we can't use devres.

The MFD already has a function that removes devices this patch uses the non-devres versions of the supply alias functions and adds an unregister in mfd_remove_devices_fn.

---
 drivers/mfd/mfd-core.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/mfd/mfd-core.c +7 -4
index 2676492..892d343 100644
@@ -102,7 +102,7 @@ static int mfd_add_device(struct device *parent, int id,
 	pdev->dev.dma_mask = parent->dma_mask;
 	pdev->dev.dma_parms = parent->dma_parms;
 
-	ret = devm_regulator_bulk_register_supply_alias(
+	ret = regulator_bulk_register_supply_alias(
 			&pdev->dev, cell->parent_supplies,
 			parent, cell->parent_supplies,
 			cell->num_parent_supplies);
@@ -182,9 +182,9 @@ static int mfd_add_device(struct device *parent, int id,
 	return 0;
 
 fail_alias:
-	devm_regulator_bulk_unregister_supply_alias(&pdev->dev,
-						    cell->parent_supplies,
-						    cell->num_parent_supplies);
+	regulator_bulk_unregister_supply_alias(&pdev->dev,
+					       cell->parent_supplies,
+					       cell->num_parent_supplies);
 fail_res:
 	kfree(res);
 fail_device:
@@ -238,6 +238,9 @@ static int mfd_remove_devices_fn(struct device *dev, void *c)
 	pdev = to_platform_device(dev);
 	cell = mfd_get_cell(pdev);
 
+	regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies,
+					       cell->num_parent_supplies);
+
 	/* find the base address of usage_count pointers (for freeing) */
 	if (!*usage_count || (cell->usage_count < *usage_count))
 		*usage_count = cell->usage_count;
Signature · 1 line
1.7.2.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Charles Keepax

The supply aliases for the MFD devices were being added using devres but the device hasn't been added at this point and as such we can't use devres.

The MFD already has a function that removes devices this patch uses the non-devres versions of the supply alias functions and adds an unregister in mfd_remove_devices_fn.

Applied
#2 lore raw
In reply to Charles Keepax
Quoted 8 lines

The supply aliases for the MFD devices were being added using devres but the device hasn't been added at this point and as such we can't use devres.

The MFD already has a function that removes devices this patch uses the non-devres versions of the supply alias functions and adds an unregister in mfd_remove_devices_fn.

Quoted 6 lines
---
 drivers/mfd/mfd-core.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog