acpi_ac & acpi_lid: return early if read position is not zero.

This avoids things like `cat /dev/power/acpi_{ac,lid}/0`
pegging CPUs to 100%, and the command never finishing.

Followed similar code already present on the acpi_thermal driver.

Change-Id: I5f13137716c36170608ab7e9dcbca628f48a138d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7397
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Oscar Lesta 2024-02-05 01:26:59 -03:00 committed by Adrien Destugues
parent cac7a2f426
commit eb2154fd47
2 changed files with 10 additions and 0 deletions

View File

@ -108,6 +108,11 @@ acpi_ac_read(void* _cookie, off_t position, void *buf, size_t* num_bytes)
if (*num_bytes < 1)
return B_IO_ERROR;
if (position > 0) {
*num_bytes = 0;
return B_OK;
}
*((uint8 *)(buf)) = device->last_status;
*num_bytes = 1;

View File

@ -118,6 +118,11 @@ acpi_lid_read(void* _cookie, off_t position, void *buf, size_t* num_bytes)
if (*num_bytes < 1)
return B_IO_ERROR;
if (position > 0) {
*num_bytes = 0;
return B_OK;
}
*((uint8 *)(buf)) = device->last_status;
*num_bytes = 1;
device->updated = false;