Commit e883cafd authored by Andy Shevchenko's avatar Andy Shevchenko

platform/x86: intel_telemetry_pltdrv: use devm_platform_ioremap_resource()

Use devm_platform_ioremap_resource() to simplify the code a bit.

While here, drop initialized but unused ssram_base_addr and ssram_size members.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 554f269f
...@@ -40,13 +40,10 @@ struct telemetry_evtmap { ...@@ -40,13 +40,10 @@ struct telemetry_evtmap {
struct telemetry_unit_config { struct telemetry_unit_config {
struct telemetry_evtmap *telem_evts; struct telemetry_evtmap *telem_evts;
void __iomem *regmap; void __iomem *regmap;
u32 ssram_base_addr;
u8 ssram_evts_used; u8 ssram_evts_used;
u8 curr_period; u8 curr_period;
u8 max_period; u8 max_period;
u8 min_period; u8 min_period;
u32 ssram_size;
}; };
struct telemetry_plt_config { struct telemetry_plt_config {
......
...@@ -1117,9 +1117,9 @@ static const struct telemetry_core_ops telm_pltops = { ...@@ -1117,9 +1117,9 @@ static const struct telemetry_core_ops telm_pltops = {
static int telemetry_pltdrv_probe(struct platform_device *pdev) static int telemetry_pltdrv_probe(struct platform_device *pdev)
{ {
struct resource *res0 = NULL, *res1 = NULL;
const struct x86_cpu_id *id; const struct x86_cpu_id *id;
int size, ret = -ENOMEM; void __iomem *mem;
int ret;
id = x86_match_cpu(telemetry_cpu_ids); id = x86_match_cpu(telemetry_cpu_ids);
if (!id) if (!id)
...@@ -1127,50 +1127,17 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev) ...@@ -1127,50 +1127,17 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev)
telm_conf = (struct telemetry_plt_config *)id->driver_data; telm_conf = (struct telemetry_plt_config *)id->driver_data;
res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = devm_platform_ioremap_resource(pdev, 0);
if (!res0) { if (IS_ERR(mem))
ret = -EINVAL; return PTR_ERR(mem);
goto out;
}
size = resource_size(res0);
if (!devm_request_mem_region(&pdev->dev, res0->start, size,
pdev->name)) {
ret = -EBUSY;
goto out;
}
telm_conf->pss_config.ssram_base_addr = res0->start;
telm_conf->pss_config.ssram_size = size;
res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); telm_conf->pss_config.regmap = mem;
if (!res1) {
ret = -EINVAL;
goto out;
}
size = resource_size(res1);
if (!devm_request_mem_region(&pdev->dev, res1->start, size,
pdev->name)) {
ret = -EBUSY;
goto out;
}
telm_conf->ioss_config.ssram_base_addr = res1->start; mem = devm_platform_ioremap_resource(pdev, 1);
telm_conf->ioss_config.ssram_size = size; if (IS_ERR(mem))
return PTR_ERR(mem);
telm_conf->pss_config.regmap = ioremap_nocache( telm_conf->ioss_config.regmap = mem;
telm_conf->pss_config.ssram_base_addr,
telm_conf->pss_config.ssram_size);
if (!telm_conf->pss_config.regmap) {
ret = -ENOMEM;
goto out;
}
telm_conf->ioss_config.regmap = ioremap_nocache(
telm_conf->ioss_config.ssram_base_addr,
telm_conf->ioss_config.ssram_size);
if (!telm_conf->ioss_config.regmap) {
ret = -ENOMEM;
goto out;
}
mutex_init(&telm_conf->telem_lock); mutex_init(&telm_conf->telem_lock);
mutex_init(&telm_conf->telem_trace_lock); mutex_init(&telm_conf->telem_trace_lock);
...@@ -1188,14 +1155,6 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev) ...@@ -1188,14 +1155,6 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev)
return 0; return 0;
out: out:
if (res0)
release_mem_region(res0->start, resource_size(res0));
if (res1)
release_mem_region(res1->start, resource_size(res1));
if (telm_conf->pss_config.regmap)
iounmap(telm_conf->pss_config.regmap);
if (telm_conf->ioss_config.regmap)
iounmap(telm_conf->ioss_config.regmap);
dev_err(&pdev->dev, "TELEMETRY Setup Failed.\n"); dev_err(&pdev->dev, "TELEMETRY Setup Failed.\n");
return ret; return ret;
...@@ -1204,9 +1163,6 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev) ...@@ -1204,9 +1163,6 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev)
static int telemetry_pltdrv_remove(struct platform_device *pdev) static int telemetry_pltdrv_remove(struct platform_device *pdev)
{ {
telemetry_clear_pltdata(); telemetry_clear_pltdata();
iounmap(telm_conf->pss_config.regmap);
iounmap(telm_conf->ioss_config.regmap);
return 0; return 0;
} }
......
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