acpi: improve check against acpi_mc_group id and improve error msgs

Make sure that the group id received from get_acpi_event_group is not 0
before proceeding it further. At the occasion improve some error
messages.

As per review comments:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3407321/27
that I didn't make before it was merged.

BUG=None
TEST=Build and boot volteer-manatee

Change-Id: I41a77fc3de10b13905f3f94277d2284acf29e67f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539980
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
This commit is contained in:
Grzegorz Jaszczyk 2022-03-21 09:24:04 +00:00 committed by Commit Bot
parent 2fc3036ba8
commit 9317c41ed7

View file

@ -23,9 +23,9 @@ pub enum ACPIPMError {
/// Error while waiting for events.
#[error("failed to wait for events: {0}")]
WaitError(SysError),
#[error("Did not found group_id corresponding to acpi_mc_group")]
#[error("Did not find group_id corresponding to acpi_mc_group")]
AcpiMcGroupError,
#[error("Failed to create and bind NETLINK_GENERIC socket, listening on acpi_mc_group: {0}")]
#[error("Failed to create and bind NETLINK_GENERIC socket for acpi_mc_group: {0}")]
AcpiEventSockError(base::Error),
}
@ -174,11 +174,11 @@ fn run_worker(
// Get group id corresponding to acpi_mc_group of acpi_event family
let nl_groups: u32;
match get_acpi_event_group() {
Some(group) => {
Some(group) if group > 0 => {
nl_groups = 1 << (group - 1);
info!("Listening on acpi_mc_group of acpi_event family");
}
None => {
_ => {
return Err(ACPIPMError::AcpiMcGroupError);
}
}