From patchwork Tue Jan 31 13:43:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 138772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id CCAFB1007DF for ; Wed, 1 Feb 2012 00:43:58 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1RsE02-0005Yz-GR for incoming@patchwork.ozlabs.org; Tue, 31 Jan 2012 13:43:54 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1RsE00-0005Yu-9o for fwts-devel@lists.ubuntu.com; Tue, 31 Jan 2012 13:43:52 +0000 Received: from [175.182.130.230] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1RsDzz-000664-9H; Tue, 31 Jan 2012 13:43:52 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] dmi: dmi_decode: check acpi battery if type 22 is present. Date: Tue, 31 Jan 2012 21:43:45 +0800 Message-Id: <1328017425-12017-1-git-send-email-alex.hung@canonical.com> X-Mailer: git-send-email 1.7.5.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com Signed-off-by: Alex Hung --- src/dmi/dmi_decode/dmi_decode.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dmi/dmi_decode/dmi_decode.c b/src/dmi/dmi_decode/dmi_decode.c index 00565d6..c922ee4 100644 --- a/src/dmi/dmi_decode/dmi_decode.c +++ b/src/dmi/dmi_decode/dmi_decode.c @@ -49,6 +49,7 @@ #define DMI_ILLEGAL_MAPPED_ADDR_RANGE "DMIIllegalMappedAddrRange" #define DMI_MGMT_CTRL_HOST_TYPE "DMIMgmtCtrlHostType" #define DMI_INVALID_ENTRY_LENGTH "DMIInvalidEntryLength" +#define DMI_INVALID_HARDWARE_ENTRY "DMIInvalidHardwareEntry" #define GET_UINT16(x) (uint16_t)(*(const uint16_t *)(x)) #define GET_UINT32(x) (uint32_t)(*(const uint32_t *)(x)) @@ -241,6 +242,8 @@ static void dmi_decode_entry(fwts_framework *fw, int i; int len; int failed_count = fw->minor_tests.failed; + int battery_count; + int ret; switch (hdr->type) { case 0: /* 7.1 */ @@ -644,7 +647,7 @@ static void dmi_decode_entry(fwts_framework *fw, "(range allowed 0x01..0x08, 0xa0..0xa2) " "while accessing '%s', field '%s', offset 0x%2.2x", data[0x5], table, "Interface", 0x5); -} + } break; case 22: /* 7.23 */ @@ -666,8 +669,15 @@ static void dmi_decode_entry(fwts_framework *fw, break; if (data[0x09] == 0x02) dmi_str_check(fw, table, addr, "SBDS Device Chemistry", hdr, 0x14); - break; + ret = fwts_battery_get_count(fw, &battery_count); + if (ret != FWTS_OK || battery_count < 1) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, DMI_INVALID_HARDWARE_ENTRY, + "Invalid Hardware Configuration " + "(no battery found at '%s') ", + FWTS_PROC_ACPI_BATTERY); + } + break; case 23: /* 7.24 */ table = "System Reset (Type 23)"; if (hdr->length < 0x0D)