Commit f42f3e7f authored by Peng Fan's avatar Peng Fan Committed by Shawn Guo

soc: imx: scu: use devm_kasprintf

Use devm_kasprintf to simplify code
Signed-off-by: default avatarPeng Fan <peng.fan@nxp.com>
Reviewed-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: default avatarDong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
parent 0caf8479
...@@ -115,43 +115,28 @@ static int imx_scu_soc_probe(struct platform_device *pdev) ...@@ -115,43 +115,28 @@ static int imx_scu_soc_probe(struct platform_device *pdev)
/* format soc_id value passed from SCU firmware */ /* format soc_id value passed from SCU firmware */
val = id & 0x1f; val = id & 0x1f;
soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "0x%x", val); soc_dev_attr->soc_id = devm_kasprintf(&pdev->dev, GFP_KERNEL, "0x%x", val);
if (!soc_dev_attr->soc_id) if (!soc_dev_attr->soc_id)
return -ENOMEM; return -ENOMEM;
/* format revision value passed from SCU firmware */ /* format revision value passed from SCU firmware */
val = (id >> 5) & 0xf; val = (id >> 5) & 0xf;
val = (((val >> 2) + 1) << 4) | (val & 0x3); val = (((val >> 2) + 1) << 4) | (val & 0x3);
soc_dev_attr->revision = kasprintf(GFP_KERNEL, soc_dev_attr->revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d.%d",
"%d.%d", (val >> 4) & 0xf, val & 0xf);
(val >> 4) & 0xf, if (!soc_dev_attr->revision)
val & 0xf); return -ENOMEM;
if (!soc_dev_attr->revision) {
ret = -ENOMEM;
goto free_soc_id;
}
soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", uid); soc_dev_attr->serial_number = devm_kasprintf(&pdev->dev, GFP_KERNEL,
if (!soc_dev_attr->serial_number) { "%016llX", uid);
ret = -ENOMEM; if (!soc_dev_attr->serial_number)
goto free_revision; return -ENOMEM;
}
soc_dev = soc_device_register(soc_dev_attr); soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR(soc_dev)) { if (IS_ERR(soc_dev))
ret = PTR_ERR(soc_dev); return PTR_ERR(soc_dev);
goto free_serial_number;
}
return 0; return 0;
free_serial_number:
kfree(soc_dev_attr->serial_number);
free_revision:
kfree(soc_dev_attr->revision);
free_soc_id:
kfree(soc_dev_attr->soc_id);
return ret;
} }
static struct platform_driver imx_scu_soc_driver = { static struct platform_driver imx_scu_soc_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment