Skip to content

Commit fb85a8c

Browse files
Linus Walleijvinodkoul
authored andcommitted
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>
1 parent 5a1a3b9 commit fb85a8c

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

drivers/dma/ste_dma40.c

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,6 +3104,7 @@ static int __init d40_phy_res_init(struct d40_base *base)
31043104
static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
31053105
{
31063106
struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
3107+
struct device *dev = &pdev->dev;
31073108
struct clk *clk;
31083109
void __iomem *virtbase;
31093110
struct resource *res;
@@ -3117,15 +3118,15 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
31173118
u32 cid;
31183119
u8 rev;
31193120

3120-
clk = clk_get(&pdev->dev, NULL);
3121+
clk = clk_get(dev, NULL);
31213122
if (IS_ERR(clk)) {
3122-
d40_err(&pdev->dev, "No matching clock found\n");
3123+
d40_err(dev, "No matching clock found\n");
31233124
goto check_prepare_enabled;
31243125
}
31253126

31263127
clk_ret = clk_prepare_enable(clk);
31273128
if (clk_ret) {
3128-
d40_err(&pdev->dev, "Failed to prepare/enable clock\n");
3129+
d40_err(dev, "Failed to prepare/enable clock\n");
31293130
goto disable_unprepare;
31303131
}
31313132

@@ -3151,11 +3152,11 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
31513152
& 255) << (i * 8);
31523153

31533154
if (cid != AMBA_CID) {
3154-
d40_err(&pdev->dev, "Unknown hardware! No PrimeCell ID\n");
3155+
d40_err(dev, "Unknown hardware! No PrimeCell ID\n");
31553156
goto unmap_io;
31563157
}
31573158
if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) {
3158-
d40_err(&pdev->dev, "Unknown designer! Got %x wanted %x\n",
3159+
d40_err(dev, "Unknown designer! Got %x wanted %x\n",
31593160
AMBA_MANF_BITS(pid),
31603161
AMBA_VENDOR_ST);
31613162
goto unmap_io;
@@ -3171,7 +3172,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
31713172
*/
31723173
rev = AMBA_REV_BITS(pid);
31733174
if (rev < 2) {
3174-
d40_err(&pdev->dev, "hardware revision: %d is not supported", rev);
3175+
d40_err(dev, "hardware revision: %d is not supported", rev);
31753176
goto unmap_io;
31763177
}
31773178

@@ -3189,7 +3190,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
31893190

31903191
num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY;
31913192

3192-
dev_info(&pdev->dev,
3193+
dev_info(dev,
31933194
"hardware rev: %d @ %pa with %d physical and %d logical channels\n",
31943195
rev, &res->start, num_phy_chans, num_log_chans);
31953196

@@ -3209,7 +3210,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
32093210
base->phy_size = resource_size(res);
32103211
base->virtbase = virtbase;
32113212
base->plat_data = plat_data;
3212-
base->dev = &pdev->dev;
3213+
base->dev = dev;
32133214
base->phy_chans = ((void *)base) + ALIGN(sizeof(struct d40_base), 4);
32143215
base->log_chans = &base->phy_chans[num_phy_chans];
32153216

@@ -3505,7 +3506,8 @@ static int __init d40_of_probe(struct platform_device *pdev,
35053506

35063507
static int __init d40_probe(struct platform_device *pdev)
35073508
{
3508-
struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
3509+
struct device *dev = &pdev->dev;
3510+
struct stedma40_platform_data *plat_data = dev_get_platdata(dev);
35093511
struct device_node *np = pdev->dev.of_node;
35103512
struct device_node *np_lcpa;
35113513
int ret = -ENOENT;
@@ -3522,7 +3524,7 @@ static int __init d40_probe(struct platform_device *pdev)
35223524
goto report_failure;
35233525
}
35243526
} else {
3525-
d40_err(&pdev->dev, "No pdata or Device Tree provided\n");
3527+
d40_err(dev, "No pdata or Device Tree provided\n");
35263528
goto report_failure;
35273529
}
35283530
}
@@ -3541,24 +3543,24 @@ static int __init d40_probe(struct platform_device *pdev)
35413543
/* Get IO for logical channel parameter address (LCPA) */
35423544
np_lcpa = of_parse_phandle(np, "sram", 0);
35433545
if (!np_lcpa) {
3544-
dev_err(&pdev->dev, "no LCPA SRAM node\n");
3546+
dev_err(dev, "no LCPA SRAM node\n");
35453547
goto report_failure;
35463548
}
35473549
/* This is no device so read the address directly from the node */
35483550
ret = of_address_to_resource(np_lcpa, 0, &res_lcpa);
35493551
if (ret) {
3550-
dev_err(&pdev->dev, "no LCPA SRAM resource\n");
3552+
dev_err(dev, "no LCPA SRAM resource\n");
35513553
goto report_failure;
35523554
}
35533555
base->lcpa_size = resource_size(&res_lcpa);
35543556
base->phy_lcpa = res_lcpa.start;
3555-
dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n",
3557+
dev_info(dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n",
35563558
(u32)base->phy_lcpa, base->lcpa_size);
35573559

35583560
/* We make use of ESRAM memory for this. */
35593561
val = readl(base->virtbase + D40_DREG_LCPA);
35603562
if (base->phy_lcpa != val && val != 0) {
3561-
dev_warn(&pdev->dev,
3563+
dev_warn(dev,
35623564
"[%s] Mismatch LCPA dma 0x%x, def %08x\n",
35633565
__func__, val, (u32)base->phy_lcpa);
35643566
} else
@@ -3567,7 +3569,7 @@ static int __init d40_probe(struct platform_device *pdev)
35673569
base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size);
35683570
if (!base->lcpa_base) {
35693571
ret = -ENOMEM;
3570-
d40_err(&pdev->dev, "Failed to ioremap LCPA region\n");
3572+
d40_err(dev, "Failed to ioremap LCPA region\n");
35713573
goto release_base;
35723574
}
35733575
/* If lcla has to be located in ESRAM we don't need to allocate */
@@ -3576,23 +3578,23 @@ static int __init d40_probe(struct platform_device *pdev)
35763578
"lcla_esram");
35773579
if (!res) {
35783580
ret = -ENOENT;
3579-
d40_err(&pdev->dev,
3581+
d40_err(dev,
35803582
"No \"lcla_esram\" memory resource\n");
35813583
goto destroy_cache;
35823584
}
35833585
base->lcla_pool.base = ioremap(res->start,
35843586
resource_size(res));
35853587
if (!base->lcla_pool.base) {
35863588
ret = -ENOMEM;
3587-
d40_err(&pdev->dev, "Failed to ioremap LCLA region\n");
3589+
d40_err(dev, "Failed to ioremap LCLA region\n");
35883590
goto destroy_cache;
35893591
}
35903592
writel(res->start, base->virtbase + D40_DREG_LCLA);
35913593

35923594
} else {
35933595
ret = d40_lcla_allocate(base);
35943596
if (ret) {
3595-
d40_err(&pdev->dev, "Failed to allocate LCLA area\n");
3597+
d40_err(dev, "Failed to allocate LCLA area\n");
35963598
goto destroy_cache;
35973599
}
35983600
}
@@ -3603,23 +3605,23 @@ static int __init d40_probe(struct platform_device *pdev)
36033605

36043606
ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base);
36053607
if (ret) {
3606-
d40_err(&pdev->dev, "No IRQ defined\n");
3608+
d40_err(dev, "No IRQ defined\n");
36073609
goto destroy_cache;
36083610
}
36093611

36103612
if (base->plat_data->use_esram_lcla) {
36113613

36123614
base->lcpa_regulator = regulator_get(base->dev, "lcla_esram");
36133615
if (IS_ERR(base->lcpa_regulator)) {
3614-
d40_err(&pdev->dev, "Failed to get lcpa_regulator\n");
3616+
d40_err(dev, "Failed to get lcpa_regulator\n");
36153617
ret = PTR_ERR(base->lcpa_regulator);
36163618
base->lcpa_regulator = NULL;
36173619
goto destroy_cache;
36183620
}
36193621

36203622
ret = regulator_enable(base->lcpa_regulator);
36213623
if (ret) {
3622-
d40_err(&pdev->dev,
3624+
d40_err(dev,
36233625
"Failed to enable lcpa_regulator\n");
36243626
regulator_put(base->lcpa_regulator);
36253627
base->lcpa_regulator = NULL;
@@ -3642,7 +3644,7 @@ static int __init d40_probe(struct platform_device *pdev)
36423644

36433645
ret = dma_set_max_seg_size(base->dev, STEDMA40_MAX_SEG_SIZE);
36443646
if (ret) {
3645-
d40_err(&pdev->dev, "Failed to set dma max seg size\n");
3647+
d40_err(dev, "Failed to set dma max seg size\n");
36463648
goto destroy_cache;
36473649
}
36483650

@@ -3651,7 +3653,7 @@ static int __init d40_probe(struct platform_device *pdev)
36513653
if (np) {
36523654
ret = of_dma_controller_register(np, d40_xlate, NULL);
36533655
if (ret)
3654-
dev_err(&pdev->dev,
3656+
dev_err(dev,
36553657
"could not register of_dma_controller\n");
36563658
}
36573659

@@ -3701,7 +3703,7 @@ static int __init d40_probe(struct platform_device *pdev)
37013703
kfree(base->phy_res);
37023704
kfree(base);
37033705
report_failure:
3704-
d40_err(&pdev->dev, "probe failed\n");
3706+
d40_err(dev, "probe failed\n");
37053707
return ret;
37063708
}
37073709

0 commit comments

Comments
 (0)