Thermal: spear_thermal: convert to devm_ioremap_resource
Use the newly introduced devm_ioremap_resource(). devm_ioremap_resource() provides its own error messages; so all explicit error messages can be removed from the failure code paths. CC: Vincenzo Frascino <vincenzo.frascino@st.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
This commit is contained in:
parent
c28f692c6f
commit
253e3ae170
@ -104,7 +104,7 @@ static int spear_thermal_probe(struct platform_device *pdev)
|
|||||||
struct thermal_zone_device *spear_thermal = NULL;
|
struct thermal_zone_device *spear_thermal = NULL;
|
||||||
struct spear_thermal_dev *stdev;
|
struct spear_thermal_dev *stdev;
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
struct resource *stres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
struct resource *res;
|
||||||
int ret = 0, val;
|
int ret = 0, val;
|
||||||
|
|
||||||
if (!np || !of_property_read_u32(np, "st,thermal-flags", &val)) {
|
if (!np || !of_property_read_u32(np, "st,thermal-flags", &val)) {
|
||||||
@ -112,23 +112,23 @@ static int spear_thermal_probe(struct platform_device *pdev)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stres) {
|
|
||||||
dev_err(&pdev->dev, "memory resource missing\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL);
|
stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL);
|
||||||
if (!stdev) {
|
if (!stdev) {
|
||||||
dev_err(&pdev->dev, "kzalloc fail\n");
|
dev_err(&pdev->dev, "kzalloc fail\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
if (!res) {
|
||||||
|
dev_err(&pdev->dev, "memory resource missing\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable thermal sensor */
|
/* Enable thermal sensor */
|
||||||
stdev->thermal_base = devm_ioremap(&pdev->dev, stres->start,
|
stdev->thermal_base = devm_ioremap_resource(dev, res);
|
||||||
resource_size(stres));
|
if (IS_ERR(stdev->thermal_base)) {
|
||||||
if (!stdev->thermal_base) {
|
|
||||||
dev_err(&pdev->dev, "ioremap failed\n");
|
dev_err(&pdev->dev, "ioremap failed\n");
|
||||||
return -ENOMEM;
|
return PTR_ERR(stdev->thermal_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
stdev->clk = devm_clk_get(&pdev->dev, NULL);
|
stdev->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user