]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (lenovo-ec-sensors): Convert to devm_request_region()
authorKean Ren <rh_king@163.com>
Thu, 21 May 2026 03:52:27 +0000 (11:52 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 21 May 2026 13:47:30 +0000 (06:47 -0700)
commit6c4e001cb0567b81340270d8fc3d53e39435ae70
treef69e65b8e798b9eb9e148ac1ce1ca5eee7ebd102
parent5200f5f493f79f14bbdc349e402a40dfb32f23c8
hwmon: (lenovo-ec-sensors): Convert to devm_request_region()

Replace manual request_region()/release_region() with
devm_request_region().  This lets the device-managed framework
handle I/O region lifetime automatically and fixes:

- A double release_region() when probe fails after acquiring the
  I/O region: the probe error path releases it, and then
  lenovo_ec_init() releases it again on the same error path.

- A release-after-use window in lenovo_ec_exit() where
  release_region() was called before platform_device_unregister(),
  leaving the hwmon device active with a released I/O region.

- Missing release_region() in lenovo_ec_probe() if
  devm_hwmon_device_register_with_info() fails.

Remove all four manual release_region() calls that are now handled
automatically and replace request_region with
devm_request_region, use dev_err replace pr_err.

Also remove the now-unnecessary braces around the single-statement
if body.

Fixes: 70118f85e6538 ("hwmon: Add EC Chip driver for Lenovo ThinkStation motherboards")
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Kean Ren <rh_king@163.com>
Link: https://lore.kernel.org/r/20260521035228.533317-2-rh_king@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lenovo-ec-sensors.c