Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branches 'acpi-battery' and 'acpi-misc'

Merge ACPI battery driver changes and a generic ACPI watchdog device
driver change for 6.20-rc1/7.0-rc1:

- Convert the generic ACPI battery driver to a proper platform driver
using struct platform_driver for device binding (Rafael Wysocki)

- Fix incorrect charging status when current is zero in the generic
ACPI battery driver (Ata İlhan Köktürk)

- Use LIST_HEAD() for initializing a stack-allocated list in the
generic ACPI watchdog device driver (Can Peng)

* acpi-battery:
ACPI: battery: fix incorrect charging status when current is zero
ACPI: battery: Convert the driver to a platform one
ACPI: battery: Reduce code duplication related to cleanup
ACPI: battery: Adjust event notification routine

* acpi-misc:
ACPI: acpi_watchdog: use LIST_HEAD for stack-allocated list

+41 -43
+1 -3
drivers/acpi/acpi_watchdog.c
··· 103 103 { 104 104 const struct acpi_wdat_entry *entries; 105 105 const struct acpi_table_wdat *wdat; 106 - struct list_head resource_list; 106 + LIST_HEAD(resource_list); 107 107 struct resource_entry *rentry; 108 108 struct platform_device *pdev; 109 109 struct resource *resources; ··· 124 124 if (wdat->pci_segment != 0xff || wdat->pci_bus != 0xff || 125 125 wdat->pci_device != 0xff || wdat->pci_function != 0xff) 126 126 goto fail_put_wdat; 127 - 128 - INIT_LIST_HEAD(&resource_list); 129 127 130 128 entries = (struct acpi_wdat_entry *)(wdat + 1); 131 129 for (i = 0; i < wdat->entries; i++) {
+40 -40
drivers/acpi/battery.c
··· 17 17 #include <linux/list.h> 18 18 #include <linux/module.h> 19 19 #include <linux/mutex.h> 20 + #include <linux/platform_device.h> 20 21 #include <linux/slab.h> 21 22 #include <linux/suspend.h> 22 23 #include <linux/types.h> ··· 212 211 if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) 213 212 val->intval = acpi_battery_handle_discharging(battery); 214 213 else if (battery->state & ACPI_BATTERY_STATE_CHARGING) 215 - val->intval = POWER_SUPPLY_STATUS_CHARGING; 214 + /* Validate the status by checking the current. */ 215 + if (battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 216 + battery->rate_now == 0) { 217 + /* On charge but no current (0W/0mA). */ 218 + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; 219 + } else { 220 + val->intval = POWER_SUPPLY_STATUS_CHARGING; 221 + } 216 222 else if (battery->state & ACPI_BATTERY_STATE_CHARGE_LIMITING) 217 223 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; 218 224 else if (acpi_battery_is_charged(battery)) ··· 1062 1054 /* Driver Interface */ 1063 1055 static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) 1064 1056 { 1065 - struct acpi_device *device = data; 1066 - struct acpi_battery *battery = acpi_driver_data(device); 1057 + struct acpi_battery *battery = data; 1058 + struct acpi_device *device = battery->device; 1067 1059 struct power_supply *old; 1068 1060 1069 1061 if (!battery) ··· 1216 1208 sysfs_remove_battery(battery); 1217 1209 } 1218 1210 1219 - static int acpi_battery_add(struct acpi_device *device) 1211 + static int acpi_battery_probe(struct platform_device *pdev) 1220 1212 { 1221 - int result = 0; 1213 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1222 1214 struct acpi_battery *battery; 1223 - 1224 - if (!device) 1225 - return -EINVAL; 1215 + int result; 1226 1216 1227 1217 if (device->dep_unmet) 1228 1218 return -EPROBE_DEFER; 1229 1219 1230 - battery = devm_kzalloc(&device->dev, sizeof(*battery), GFP_KERNEL); 1220 + battery = devm_kzalloc(&pdev->dev, sizeof(*battery), GFP_KERNEL); 1231 1221 if (!battery) 1232 1222 return -ENOMEM; 1223 + 1224 + platform_set_drvdata(pdev, battery); 1225 + 1233 1226 battery->device = device; 1234 1227 strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); 1235 1228 strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 1236 - device->driver_data = battery; 1237 1229 1238 - result = devm_mutex_init(&device->dev, &battery->update_lock); 1230 + result = devm_mutex_init(&pdev->dev, &battery->update_lock); 1239 1231 if (result) 1240 1232 return result; 1241 1233 ··· 1254 1246 if (result) 1255 1247 goto fail; 1256 1248 1257 - device_init_wakeup(&device->dev, 1); 1249 + device_init_wakeup(&pdev->dev, true); 1258 1250 1259 1251 result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY, 1260 - acpi_battery_notify, device); 1252 + acpi_battery_notify, battery); 1261 1253 if (result) 1262 1254 goto fail_pm; 1263 1255 1264 1256 return 0; 1265 1257 1266 1258 fail_pm: 1267 - device_init_wakeup(&device->dev, 0); 1259 + device_init_wakeup(&pdev->dev, false); 1268 1260 unregister_pm_notifier(&battery->pm_nb); 1269 1261 fail: 1270 1262 sysfs_battery_cleanup(battery); ··· 1272 1264 return result; 1273 1265 } 1274 1266 1275 - static void acpi_battery_remove(struct acpi_device *device) 1267 + static void acpi_battery_remove(struct platform_device *pdev) 1276 1268 { 1277 - struct acpi_battery *battery; 1269 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 1270 + struct acpi_battery *battery = platform_get_drvdata(pdev); 1278 1271 1279 - if (!device || !acpi_driver_data(device)) 1272 + if (!device || !battery) 1280 1273 return; 1281 - 1282 - battery = acpi_driver_data(device); 1283 1274 1284 1275 acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY, 1285 1276 acpi_battery_notify); 1286 1277 1287 - device_init_wakeup(&device->dev, 0); 1278 + device_init_wakeup(&pdev->dev, false); 1288 1279 unregister_pm_notifier(&battery->pm_nb); 1289 1280 1290 - guard(mutex)(&battery->update_lock); 1291 - 1292 - sysfs_remove_battery(battery); 1281 + sysfs_battery_cleanup(battery); 1293 1282 } 1294 1283 1295 1284 /* this is needed to learn about changes made in suspended state */ 1296 1285 static int acpi_battery_resume(struct device *dev) 1297 1286 { 1298 - struct acpi_battery *battery; 1287 + struct acpi_battery *battery = dev_get_drvdata(dev); 1299 1288 1300 - if (!dev) 1301 - return -EINVAL; 1302 - 1303 - battery = acpi_driver_data(to_acpi_device(dev)); 1304 1289 if (!battery) 1305 1290 return -EINVAL; 1306 1291 ··· 1307 1306 1308 1307 static DEFINE_SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume); 1309 1308 1310 - static struct acpi_driver acpi_battery_driver = { 1311 - .name = "battery", 1312 - .class = ACPI_BATTERY_CLASS, 1313 - .ids = battery_device_ids, 1314 - .ops = { 1315 - .add = acpi_battery_add, 1316 - .remove = acpi_battery_remove, 1317 - }, 1318 - .drv.pm = pm_sleep_ptr(&acpi_battery_pm), 1319 - .drv.probe_type = PROBE_PREFER_ASYNCHRONOUS, 1309 + static struct platform_driver acpi_battery_driver = { 1310 + .probe = acpi_battery_probe, 1311 + .remove = acpi_battery_remove, 1312 + .driver = { 1313 + .name = "acpi-battery", 1314 + .acpi_match_table = battery_device_ids, 1315 + .pm = pm_sleep_ptr(&acpi_battery_pm), 1316 + .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1317 + }, 1320 1318 }; 1321 1319 1322 1320 static int __init acpi_battery_init(void) ··· 1325 1325 1326 1326 dmi_check_system(bat_dmi_table); 1327 1327 1328 - return acpi_bus_register_driver(&acpi_battery_driver); 1328 + return platform_driver_register(&acpi_battery_driver); 1329 1329 } 1330 1330 1331 1331 static void __exit acpi_battery_exit(void) 1332 1332 { 1333 - acpi_bus_unregister_driver(&acpi_battery_driver); 1333 + platform_driver_unregister(&acpi_battery_driver); 1334 1334 battery_hook_exit(); 1335 1335 } 1336 1336