mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 01:10:04 +00:00
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
parent
554f269f0f
commit
e883cafd8d
2 changed files with 10 additions and 57 deletions
|
@ -40,13 +40,10 @@ struct telemetry_evtmap {
|
|||
struct telemetry_unit_config {
|
||||
struct telemetry_evtmap *telem_evts;
|
||||
void __iomem *regmap;
|
||||
u32 ssram_base_addr;
|
||||
u8 ssram_evts_used;
|
||||
u8 curr_period;
|
||||
u8 max_period;
|
||||
u8 min_period;
|
||||
u32 ssram_size;
|
||||
|
||||
};
|
||||
|
||||
struct telemetry_plt_config {
|
||||
|
|
|
@ -1117,9 +1117,9 @@ static const struct telemetry_core_ops telm_pltops = {
|
|||
|
||||
static int telemetry_pltdrv_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct resource *res0 = NULL, *res1 = NULL;
|
||||
const struct x86_cpu_id *id;
|
||||
int size, ret = -ENOMEM;
|
||||
void __iomem *mem;
|
||||
int ret;
|
||||
|
||||
id = x86_match_cpu(telemetry_cpu_ids);
|
||||
if (!id)
|
||||
|
@ -1127,50 +1127,17 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev)
|
|||
|
||||
telm_conf = (struct telemetry_plt_config *)id->driver_data;
|
||||
|
||||
res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res0) {
|
||||
ret = -EINVAL;
|
||||
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;
|
||||
mem = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(mem))
|
||||
return PTR_ERR(mem);
|
||||
|
||||
res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
||||
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->pss_config.regmap = mem;
|
||||
|
||||
telm_conf->ioss_config.ssram_base_addr = res1->start;
|
||||
telm_conf->ioss_config.ssram_size = size;
|
||||
mem = devm_platform_ioremap_resource(pdev, 1);
|
||||
if (IS_ERR(mem))
|
||||
return PTR_ERR(mem);
|
||||
|
||||
telm_conf->pss_config.regmap = ioremap_nocache(
|
||||
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;
|
||||
}
|
||||
telm_conf->ioss_config.regmap = mem;
|
||||
|
||||
mutex_init(&telm_conf->telem_lock);
|
||||
mutex_init(&telm_conf->telem_trace_lock);
|
||||
|
@ -1188,14 +1155,6 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev)
|
|||
return 0;
|
||||
|
||||
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");
|
||||
|
||||
return ret;
|
||||
|
@ -1204,9 +1163,6 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev)
|
|||
static int telemetry_pltdrv_remove(struct platform_device *pdev)
|
||||
{
|
||||
telemetry_clear_pltdata();
|
||||
iounmap(telm_conf->pss_config.regmap);
|
||||
iounmap(telm_conf->ioss_config.regmap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue