Skip to content

Commit f42f3e7

Browse files
MrVanShawn Guo
authored andcommitted
soc: imx: scu: use devm_kasprintf
Use devm_kasprintf to simplify code Signed-off-by: Peng Fan <[email protected]> Reviewed-by: Daniel Baluta <[email protected]> Reviewed-by: Dong Aisheng <[email protected]> Signed-off-by: Shawn Guo <[email protected]>
1 parent 0caf847 commit f42f3e7

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

drivers/soc/imx/soc-imx-scu.c

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -115,43 +115,28 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
115115

116116
/* format soc_id value passed from SCU firmware */
117117
val = id & 0x1f;
118-
soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "0x%x", val);
118+
soc_dev_attr->soc_id = devm_kasprintf(&pdev->dev, GFP_KERNEL, "0x%x", val);
119119
if (!soc_dev_attr->soc_id)
120120
return -ENOMEM;
121121

122122
/* format revision value passed from SCU firmware */
123123
val = (id >> 5) & 0xf;
124124
val = (((val >> 2) + 1) << 4) | (val & 0x3);
125-
soc_dev_attr->revision = kasprintf(GFP_KERNEL,
126-
"%d.%d",
127-
(val >> 4) & 0xf,
128-
val & 0xf);
129-
if (!soc_dev_attr->revision) {
130-
ret = -ENOMEM;
131-
goto free_soc_id;
132-
}
125+
soc_dev_attr->revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d.%d",
126+
(val >> 4) & 0xf, val & 0xf);
127+
if (!soc_dev_attr->revision)
128+
return -ENOMEM;
133129

134-
soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", uid);
135-
if (!soc_dev_attr->serial_number) {
136-
ret = -ENOMEM;
137-
goto free_revision;
138-
}
130+
soc_dev_attr->serial_number = devm_kasprintf(&pdev->dev, GFP_KERNEL,
131+
"%016llX", uid);
132+
if (!soc_dev_attr->serial_number)
133+
return -ENOMEM;
139134

140135
soc_dev = soc_device_register(soc_dev_attr);
141-
if (IS_ERR(soc_dev)) {
142-
ret = PTR_ERR(soc_dev);
143-
goto free_serial_number;
144-
}
136+
if (IS_ERR(soc_dev))
137+
return PTR_ERR(soc_dev);
145138

146139
return 0;
147-
148-
free_serial_number:
149-
kfree(soc_dev_attr->serial_number);
150-
free_revision:
151-
kfree(soc_dev_attr->revision);
152-
free_soc_id:
153-
kfree(soc_dev_attr->soc_id);
154-
return ret;
155140
}
156141

157142
static struct platform_driver imx_scu_soc_driver = {

0 commit comments

Comments
 (0)