dmaengine: ste_dma40: Add dev helper variable

The &pdev->dev device pointer is used so many times in the
probe() and d40_hw_detect_init() functions that a local *dev
variable makes the code way easier to read.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230417-ux500-dma40-cleanup-v3-3-60bfa6785968@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Linus Walleij 2023-05-16 14:55:33 +02:00 committed by Vinod Koul
parent 5a1a3b9c19
commit fb85a8c517
1 changed files with 26 additions and 24 deletions

View File

@ -3104,6 +3104,7 @@ static int __init d40_phy_res_init(struct d40_base *base)
static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
{
struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
struct device *dev = &pdev->dev;
struct clk *clk;
void __iomem *virtbase;
struct resource *res;
@ -3117,15 +3118,15 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
u32 cid;
u8 rev;
clk = clk_get(&pdev->dev, NULL);
clk = clk_get(dev, NULL);
if (IS_ERR(clk)) {
d40_err(&pdev->dev, "No matching clock found\n");
d40_err(dev, "No matching clock found\n");
goto check_prepare_enabled;
}
clk_ret = clk_prepare_enable(clk);
if (clk_ret) {
d40_err(&pdev->dev, "Failed to prepare/enable clock\n");
d40_err(dev, "Failed to prepare/enable clock\n");
goto disable_unprepare;
}
@ -3151,11 +3152,11 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
& 255) << (i * 8);
if (cid != AMBA_CID) {
d40_err(&pdev->dev, "Unknown hardware! No PrimeCell ID\n");
d40_err(dev, "Unknown hardware! No PrimeCell ID\n");
goto unmap_io;
}
if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) {
d40_err(&pdev->dev, "Unknown designer! Got %x wanted %x\n",
d40_err(dev, "Unknown designer! Got %x wanted %x\n",
AMBA_MANF_BITS(pid),
AMBA_VENDOR_ST);
goto unmap_io;
@ -3171,7 +3172,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
*/
rev = AMBA_REV_BITS(pid);
if (rev < 2) {
d40_err(&pdev->dev, "hardware revision: %d is not supported", rev);
d40_err(dev, "hardware revision: %d is not supported", rev);
goto unmap_io;
}
@ -3189,7 +3190,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY;
dev_info(&pdev->dev,
dev_info(dev,
"hardware rev: %d @ %pa with %d physical and %d logical channels\n",
rev, &res->start, num_phy_chans, num_log_chans);
@ -3209,7 +3210,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
base->phy_size = resource_size(res);
base->virtbase = virtbase;
base->plat_data = plat_data;
base->dev = &pdev->dev;
base->dev = dev;
base->phy_chans = ((void *)base) + ALIGN(sizeof(struct d40_base), 4);
base->log_chans = &base->phy_chans[num_phy_chans];
@ -3505,7 +3506,8 @@ static int __init d40_of_probe(struct platform_device *pdev,
static int __init d40_probe(struct platform_device *pdev)
{
struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
struct device *dev = &pdev->dev;
struct stedma40_platform_data *plat_data = dev_get_platdata(dev);
struct device_node *np = pdev->dev.of_node;
struct device_node *np_lcpa;
int ret = -ENOENT;
@ -3522,7 +3524,7 @@ static int __init d40_probe(struct platform_device *pdev)
goto report_failure;
}
} else {
d40_err(&pdev->dev, "No pdata or Device Tree provided\n");
d40_err(dev, "No pdata or Device Tree provided\n");
goto report_failure;
}
}
@ -3541,24 +3543,24 @@ static int __init d40_probe(struct platform_device *pdev)
/* Get IO for logical channel parameter address (LCPA) */
np_lcpa = of_parse_phandle(np, "sram", 0);
if (!np_lcpa) {
dev_err(&pdev->dev, "no LCPA SRAM node\n");
dev_err(dev, "no LCPA SRAM node\n");
goto report_failure;
}
/* This is no device so read the address directly from the node */
ret = of_address_to_resource(np_lcpa, 0, &res_lcpa);
if (ret) {
dev_err(&pdev->dev, "no LCPA SRAM resource\n");
dev_err(dev, "no LCPA SRAM resource\n");
goto report_failure;
}
base->lcpa_size = resource_size(&res_lcpa);
base->phy_lcpa = res_lcpa.start;
dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n",
dev_info(dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n",
(u32)base->phy_lcpa, base->lcpa_size);
/* We make use of ESRAM memory for this. */
val = readl(base->virtbase + D40_DREG_LCPA);
if (base->phy_lcpa != val && val != 0) {
dev_warn(&pdev->dev,
dev_warn(dev,
"[%s] Mismatch LCPA dma 0x%x, def %08x\n",
__func__, val, (u32)base->phy_lcpa);
} else
@ -3567,7 +3569,7 @@ static int __init d40_probe(struct platform_device *pdev)
base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size);
if (!base->lcpa_base) {
ret = -ENOMEM;
d40_err(&pdev->dev, "Failed to ioremap LCPA region\n");
d40_err(dev, "Failed to ioremap LCPA region\n");
goto release_base;
}
/* If lcla has to be located in ESRAM we don't need to allocate */
@ -3576,7 +3578,7 @@ static int __init d40_probe(struct platform_device *pdev)
"lcla_esram");
if (!res) {
ret = -ENOENT;
d40_err(&pdev->dev,
d40_err(dev,
"No \"lcla_esram\" memory resource\n");
goto destroy_cache;
}
@ -3584,7 +3586,7 @@ static int __init d40_probe(struct platform_device *pdev)
resource_size(res));
if (!base->lcla_pool.base) {
ret = -ENOMEM;
d40_err(&pdev->dev, "Failed to ioremap LCLA region\n");
d40_err(dev, "Failed to ioremap LCLA region\n");
goto destroy_cache;
}
writel(res->start, base->virtbase + D40_DREG_LCLA);
@ -3592,7 +3594,7 @@ static int __init d40_probe(struct platform_device *pdev)
} else {
ret = d40_lcla_allocate(base);
if (ret) {
d40_err(&pdev->dev, "Failed to allocate LCLA area\n");
d40_err(dev, "Failed to allocate LCLA area\n");
goto destroy_cache;
}
}
@ -3603,7 +3605,7 @@ static int __init d40_probe(struct platform_device *pdev)
ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base);
if (ret) {
d40_err(&pdev->dev, "No IRQ defined\n");
d40_err(dev, "No IRQ defined\n");
goto destroy_cache;
}
@ -3611,7 +3613,7 @@ static int __init d40_probe(struct platform_device *pdev)
base->lcpa_regulator = regulator_get(base->dev, "lcla_esram");
if (IS_ERR(base->lcpa_regulator)) {
d40_err(&pdev->dev, "Failed to get lcpa_regulator\n");
d40_err(dev, "Failed to get lcpa_regulator\n");
ret = PTR_ERR(base->lcpa_regulator);
base->lcpa_regulator = NULL;
goto destroy_cache;
@ -3619,7 +3621,7 @@ static int __init d40_probe(struct platform_device *pdev)
ret = regulator_enable(base->lcpa_regulator);
if (ret) {
d40_err(&pdev->dev,
d40_err(dev,
"Failed to enable lcpa_regulator\n");
regulator_put(base->lcpa_regulator);
base->lcpa_regulator = NULL;
@ -3642,7 +3644,7 @@ static int __init d40_probe(struct platform_device *pdev)
ret = dma_set_max_seg_size(base->dev, STEDMA40_MAX_SEG_SIZE);
if (ret) {
d40_err(&pdev->dev, "Failed to set dma max seg size\n");
d40_err(dev, "Failed to set dma max seg size\n");
goto destroy_cache;
}
@ -3651,7 +3653,7 @@ static int __init d40_probe(struct platform_device *pdev)
if (np) {
ret = of_dma_controller_register(np, d40_xlate, NULL);
if (ret)
dev_err(&pdev->dev,
dev_err(dev,
"could not register of_dma_controller\n");
}
@ -3701,7 +3703,7 @@ release_base:
kfree(base->phy_res);
kfree(base);
report_failure:
d40_err(&pdev->dev, "probe failed\n");
d40_err(dev, "probe failed\n");
return ret;
}