Claude review: drm/amd/display: Deduplicate DCN DDC register assignment

Claude Code Review Bot
2026-03-21T17:15:10Z

Patch Review

**Critical: Wrong parameter types — will not compile**

In `hw_factory_dcn_ddc.h:14-15`, the helper declares:
```c
const struct ddc_shift *shift,
const struct ddc_mask *mask)
```

The types `struct ddc_shift` and `struct ddc_mask` **do not exist** anywhere in the kernel tree. The correct type for both is `struct ddc_sh_mask`, as defined in `ddc_regs.h:130` and used by all the caller arrays (e.g. `hw_factory_dcn20.c:137`):
```c
static const struct ddc_sh_mask ddc_shift[] = { ... };
static const struct ddc_sh_mask ddc_mask[] = { ... };
```

And the `hw_ddc` struct (`hw_ddc.h:34-35`) stores them as:
```c
const struct ddc_sh_mask *shifts;
const struct ddc_sh_mask *masks;
```

The fix is to change both parameters to `const struct ddc_sh_mask *`.

**Minor: Copyright year**

The new header (`hw_factory_dcn_ddc.h:4`) says `Copyright 2024` but this is new code written in 2026. Should be `2026`.

**Minor: Missing include guard for dependencies**

The new header `hw_factory_dcn_ddc.h` uses `struct hw_gpio_pin`, `struct ddc_registers`, `struct hw_ddc`, `HW_DDC_FROM_BASE`, `GPIO_ID_DDC_DATA`, `GPIO_ID_DDC_CLOCK`, and `ASSERT_CRITICAL` without including any headers. It relies entirely on the including `.c` file having already included the right headers in the right order. This is fragile — a comment at the top noting the required includes, or explicit includes, would be more robust. This is a pre-existing pattern in the codebase though, so it's not a blocker.

**Design: `static inline` in a header**

Using `static inline` is reasonable for this small helper. Each translation unit gets its own copy, but the function is small enough that the compiler will inline it, so there's no code size penalty.

**Correctness of the transformation (modulo the type bug)**

The logic in the helper faithfully reproduces the original `switch`/assignment pattern from all 6 files. The `en` index, the `ASSERT_CRITICAL(false)` default case, and the shift/mask assignment after the switch are all preserved correctly.

**Summary:** Fix the `struct ddc_shift`/`struct ddc_mask` → `struct ddc_sh_mask` type error, update the copyright year, and this is a clean, correct deduplication patch.