From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: power: supply: sgm41542: Add SG Micro sgm41542 charger
Date: Tue, 28 Apr 2026 14:19:02 +1000 [thread overview]
Message-ID: <review-patch2-20260427170914.5062-3-macroalpha82@gmail.com> (raw)
In-Reply-To: <20260427170914.5062-3-macroalpha82@gmail.com>
Patch Review
This is a large BSP-derived driver. Several issues:
**Bug: `power_supply_put_battery_info` called on error path.**
When `power_supply_get_battery_info()` fails, `bat_info` is uninitialized/invalid, but the code falls through to `power_supply_put_battery_info()`:
```c
ret = power_supply_get_battery_info(sgm->charger, &bat_info);
if (ret)
dev_warn(sgm->dev, "sgm4154x: cannot read battery info\n");
else {
...
}
power_supply_put_battery_info(sgm->charger, bat_info);
```
This should be inside the `else` block, or `bat_info` should be initialized to NULL and the put function checked for NULL safety.
**Bug: `sgm4154x_hw_chipid_detect` failure is not fatal.**
The probe function logs the error but continues anyway:
```c
ret = sgm4154x_hw_chipid_detect(sgm);
if (ret)
dev_err_probe(dev, ret, "Unable to read HW ID\n");
```
If the chip ID can't be read at all (I2C failure), probe should fail. The `dev_err_probe` return value is discarded.
**Missing error check for `sgm4154x_vbus_regulator_register`:**
```c
sgm4154x_vbus_regulator_register(sgm);
```
The return value is ignored. If OTG regulator registration fails, it should be propagated.
**`sgm4154x_set_watchdog_timer` uses raw values instead of defines for the argument.**
In `sgm4154x_charger_set_property`:
```c
sgm4154x_set_watchdog_timer(sgm, SGM4154X_WDT_TIMER_40S);
```
This passes the register bit value (`BIT(4)` = 16) but the function expects seconds (0, 40, 80, 160). This is a semantic mismatch. The call should pass `40`, not `SGM4154X_WDT_TIMER_40S`.
**Typo in file header:**
```c
* Chrager driver for Sgm4154x
```
Should be "Charger".
**Style issues from BSP:**
- `enum SGM4154X_VINDPM_OS` uses uppercase for the enum tag, which is not kernel coding style.
- Workqueue naming uses `%s` format specifier but passes a string literal:
```c
sgm->sgm_monitor_wq = alloc_ordered_workqueue("%s",
WQ_MEM_RECLAIM | WQ_FREEZABLE, "sgm-monitor-wq");
```
This works but is odd; just use `"sgm-monitor-wq"` directly as the format string.
- The `REGCACHE_NONE` in regmap config is the default and doesn't need to be specified.
- The `i2c_client_get_device_id()` result (`id`) is used for `id->name` but there's no NULL check. If probed via DT only, `id` could be NULL. The model_name copy via `strscpy(sgm->model_name, id->name, ...)` would then crash.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-04-28 4:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 17:09 [PATCH 0/6] Add Anbernic RG Vita-Pro Chris Morgan
2026-04-27 17:09 ` [PATCH 1/6] dt-bindings: power: supply: sgm41542: document sgm41542 Chris Morgan
2026-04-28 4:19 ` Claude review: " Claude Code Review Bot
2026-04-27 17:09 ` [PATCH 2/6] power: supply: sgm41542: Add SG Micro sgm41542 charger Chris Morgan
2026-04-28 4:19 ` Claude Code Review Bot [this message]
2026-04-27 17:09 ` [PATCH 3/6] dt-bindings: display: panel: document Anbernic TD4310 panel Chris Morgan
2026-04-28 4:19 ` Claude review: " Claude Code Review Bot
2026-04-27 17:09 ` [PATCH 4/6] drm/panel: anbernic-td4310: Add RG Vita Pro panel Chris Morgan
2026-04-28 4:19 ` Claude review: " Claude Code Review Bot
2026-04-27 17:09 ` [PATCH 5/6] dt-bindings: arm: rockchip: Add Anbernic RG Vita-Pro Chris Morgan
2026-04-28 4:19 ` Claude review: " Claude Code Review Bot
2026-04-27 17:09 ` [PATCH 6/6] arm64: dts: " Chris Morgan
2026-04-27 17:13 ` Chris Morgan
2026-04-28 4:19 ` Claude review: " Claude Code Review Bot
2026-04-28 4:19 ` Claude review: " Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=review-patch2-20260427170914.5062-3-macroalpha82@gmail.com \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox