Skip to content

Commit 74c3746

Browse files
dianderslumag
authored andcommitted
drm/msm: Simplify NULL checking in msm_disp_state_dump_regs()
The msm_disp_state_dump_regs(): - Doesn't allocate if the caller already allocated. ...but there's one caller and it doesn't allocate so we don't need this check. - Checks for allocation failure over and over even though it could just do it once right after the allocation. Clean this up. Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Patchwork: https://patchwork.freedesktop.org/patch/619660/ Link: https://lore.kernel.org/r/20241014093605.3.I66049c2c17bd82767661f0ecd741b20453da02b2@changeid Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1 parent 2261751 commit 74c3746

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,21 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b
2525
addr = base_addr;
2626
end_addr = base_addr + aligned_len;
2727

28-
if (!(*reg))
29-
*reg = kvzalloc(len_padded, GFP_KERNEL);
30-
31-
if (*reg)
32-
dump_addr = *reg;
28+
*reg = kvzalloc(len_padded, GFP_KERNEL);
29+
if (!*reg)
30+
return;
3331

32+
dump_addr = *reg;
3433
for (i = 0; i < num_rows; i++) {
3534
x0 = (addr < end_addr) ? readl_relaxed(addr + 0x0) : 0;
3635
x4 = (addr + 0x4 < end_addr) ? readl_relaxed(addr + 0x4) : 0;
3736
x8 = (addr + 0x8 < end_addr) ? readl_relaxed(addr + 0x8) : 0;
3837
xc = (addr + 0xc < end_addr) ? readl_relaxed(addr + 0xc) : 0;
3938

40-
if (dump_addr) {
41-
dump_addr[i * 4] = x0;
42-
dump_addr[i * 4 + 1] = x4;
43-
dump_addr[i * 4 + 2] = x8;
44-
dump_addr[i * 4 + 3] = xc;
45-
}
39+
dump_addr[i * 4] = x0;
40+
dump_addr[i * 4 + 1] = x4;
41+
dump_addr[i * 4 + 2] = x8;
42+
dump_addr[i * 4 + 3] = xc;
4643

4744
addr += REG_DUMP_ALIGN;
4845
}

0 commit comments

Comments
 (0)