Skip to content

Commit c59436f

Browse files
committed
battery: Add support for hot-removal
In cases of hot-removal, further communication with the device should be avoided whenever possible, as it may fail and time out. Signed-off-by: Maximilian Luz <[email protected]>
1 parent b77ee38 commit c59436f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

module/src/clients/surface_battery.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ static bool spwr_battery_present(struct spwr_battery_device *bat)
156156
{
157157
lockdep_assert_held(&bat->lock);
158158

159+
if (ssam_device_is_hot_removed(bat->sdev))
160+
return false;
161+
159162
return le32_to_cpu(bat->sta) & SAM_BATTERY_STA_PRESENT;
160163
}
161164

@@ -245,6 +248,9 @@ static int spwr_battery_update_bix_unlocked(struct spwr_battery_device *bat)
245248

246249
lockdep_assert_held(&bat->lock);
247250

251+
if (ssam_device_is_hot_removed(bat->sdev))
252+
return 0;
253+
248254
status = spwr_battery_load_sta(bat);
249255
if (status)
250256
return status;

0 commit comments

Comments
 (0)