Skip to content

Commit 1b3376d

Browse files
ambaruskrzk
authored andcommitted
soc: samsung: exynos-chipid: use devm action to unregister soc device
Simplify the unwinding of the soc device by using a devm action. Add the action before the exynos_asv_init() to avoid an explicit call to soc_device_unregister(). Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Reviewed-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20251120-gs101-chipid-v3-1-1aeaa8b7fe35@linaro.org Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
1 parent ce39d25 commit 1b3376d

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

drivers/soc/samsung/exynos-chipid.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <linux/array_size.h>
1616
#include <linux/device.h>
17+
#include <linux/device/devres.h>
1718
#include <linux/errno.h>
1819
#include <linux/mfd/syscon.h>
1920
#include <linux/module.h>
@@ -104,6 +105,11 @@ static int exynos_chipid_get_chipid_info(struct regmap *regmap,
104105
return 0;
105106
}
106107

108+
static void exynos_chipid_unregister_soc(void *data)
109+
{
110+
soc_device_unregister(data);
111+
}
112+
107113
static int exynos_chipid_probe(struct platform_device *pdev)
108114
{
109115
const struct exynos_chipid_variant *drv_data;
@@ -152,28 +158,19 @@ static int exynos_chipid_probe(struct platform_device *pdev)
152158
if (IS_ERR(soc_dev))
153159
return PTR_ERR(soc_dev);
154160

155-
ret = exynos_asv_init(dev, regmap);
161+
ret = devm_add_action_or_reset(dev, exynos_chipid_unregister_soc,
162+
soc_dev);
156163
if (ret)
157-
goto err;
164+
return dev_err_probe(dev, ret, "failed to add devm action\n");
158165

159-
platform_set_drvdata(pdev, soc_dev);
166+
ret = exynos_asv_init(dev, regmap);
167+
if (ret)
168+
return ret;
160169

161170
dev_info(dev, "Exynos: CPU[%s] PRO_ID[0x%x] REV[0x%x] Detected\n",
162171
soc_dev_attr->soc_id, soc_info.product_id, soc_info.revision);
163172

164173
return 0;
165-
166-
err:
167-
soc_device_unregister(soc_dev);
168-
169-
return ret;
170-
}
171-
172-
static void exynos_chipid_remove(struct platform_device *pdev)
173-
{
174-
struct soc_device *soc_dev = platform_get_drvdata(pdev);
175-
176-
soc_device_unregister(soc_dev);
177174
}
178175

179176
static const struct exynos_chipid_variant exynos4210_chipid_drv_data = {
@@ -206,7 +203,6 @@ static struct platform_driver exynos_chipid_driver = {
206203
.of_match_table = exynos_chipid_of_device_ids,
207204
},
208205
.probe = exynos_chipid_probe,
209-
.remove = exynos_chipid_remove,
210206
};
211207
module_platform_driver(exynos_chipid_driver);
212208

0 commit comments

Comments
 (0)