Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reset: sunxi: allow MFD subdevices probe

The current implementation uses sunxi_reset_init function for both early
init and platform device probe.

The sunxi_reset_init function uses DT to retrieve device resources, which
will be an issue if reset controllers are registered from an MFD device
that define resources from mfd_cell definition.

Moreover, we can make of devm functions when we're in the probe context.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>

authored by

Boris BREZILLON and committed by
Maxime Ripard
cd90f0cf 1e84443e

+18 -3
+18 -3
drivers/reset/reset-sunxi.c
··· 145 145 146 146 static int sunxi_reset_probe(struct platform_device *pdev) 147 147 { 148 - return sunxi_reset_init(pdev->dev.of_node); 148 + struct sunxi_reset_data *data; 149 + struct resource *res; 150 + 151 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 152 + if (!data) 153 + return -ENOMEM; 154 + 155 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 156 + data->membase = devm_ioremap_resource(&pdev->dev, res); 157 + if (IS_ERR(data->membase)) 158 + return PTR_ERR(data->membase); 159 + 160 + data->rcdev.owner = THIS_MODULE; 161 + data->rcdev.nr_resets = resource_size(res) * 32; 162 + data->rcdev.ops = &sunxi_reset_ops; 163 + data->rcdev.of_node = pdev->dev.of_node; 164 + 165 + return reset_controller_register(&data->rcdev); 149 166 } 150 167 151 168 static int sunxi_reset_remove(struct platform_device *pdev) ··· 170 153 struct sunxi_reset_data *data = platform_get_drvdata(pdev); 171 154 172 155 reset_controller_unregister(&data->rcdev); 173 - iounmap(data->membase); 174 - kfree(data); 175 156 176 157 return 0; 177 158 }