From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot 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 Message-ID: In-Reply-To: <20260427170914.5062-3-macroalpha82@gmail.com> References: <20260427170914.5062-1-macroalpha82@gmail.com> <20260427170914.5062-3-macroalpha82@gmail.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 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