Claude review: gpio: add GPIO controller found on Waveshare DSI TOUCH panels

Claude Code Review Bot
2026-04-11T23:06:58Z

Patch Review

New I2C GPIO controller + backlight driver. Several issues:

1. **Bug -- `max_register` too low**:
```c
.max_register = REG_PWM, /* 0x96 */
```
But probe reads `REG_SIZE` (0x97), `REG_ID` (0x98), and `REG_VERSION` (0x99). Regmap will reject these reads. Should be `.max_register = REG_VERSION`.

2. **Unused `dir_lock` mutex**: `struct mutex dir_lock` is declared and initialized in probe but never acquired anywhere. Remove it.

3. **Driver name mismatch**: The i2c_driver name is `"waveshare-regulator"` but this is a GPIO+backlight driver. Should be `"waveshare-dsi-gpio"` or similar.

4. **Unnecessary `#include <linux/fb.h>`**: No framebuffer APIs are used.

5. **No protection against invalid GPIO offsets**: The chip has 16 GPIO lines (NUM_GPIO=16) but only offsets 0, 1, 2, 4, 8, 9 are meaningful. Writing to undefined offsets (3, 5, 6, 7, 10-15) could set unknown bits in the hardware registers. Consider implementing `.init_valid_mask` to constrain usable offsets.

6. **Minor**: `state->gc.owner = THIS_MODULE` is unnecessary -- the GPIO framework handles this.

---
Generated by Claude Code Patch Reviewer