Patchwork dmi: dmi_decode: check acpi battery if type 22 is present.

login
register
mail settings
Submitter Alex Hung
Date Jan. 31, 2012, 3:02 p.m.
Message ID <1328022156-26170-1-git-send-email-alex.hung@canonical.com>
Download mbox | patch
Permalink /patch/138792/
State Accepted
Headers show

Comments

Alex Hung - Jan. 31, 2012, 3:02 p.m.
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/dmi/dmi_decode/dmi_decode.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
Colin King - Jan. 31, 2012, 3:07 p.m.
On 31/01/12 15:02, Alex Hung wrote:
> Signed-off-by: Alex Hung<alex.hung@canonical.com>
> ---
>   src/dmi/dmi_decode/dmi_decode.c |   13 +++++++++++--
>   1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/dmi/dmi_decode/dmi_decode.c b/src/dmi/dmi_decode/dmi_decode.c
> index 486a826..02790d9 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,14 @@ 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) ");
> +			}
> +			break;
>   		case 23: /* 7.24 */
>   			table = "System Reset (Type 23)";
>   			if (hdr->length<  0x0D)

Thanks Alex! Looks good to me.

Acked-by: Colin King <colin.king@canonical.com>
Keng-Yu Lin - Feb. 7, 2012, 9:16 a.m.
On Tue, Jan 31, 2012 at 11:07 PM, Colin Ian King
<colin.king@canonical.com> wrote:
> On 31/01/12 15:02, Alex Hung wrote:
>>
>> Signed-off-by: Alex Hung<alex.hung@canonical.com>
>> ---
>>  src/dmi/dmi_decode/dmi_decode.c |   13 +++++++++++--
>>  1 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/dmi/dmi_decode/dmi_decode.c
>> b/src/dmi/dmi_decode/dmi_decode.c
>> index 486a826..02790d9 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,14 @@ 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) ");
>> +                       }
>> +                       break;
>>                case 23: /* 7.24 */
>>                        table = "System Reset (Type 23)";
>>                        if (hdr->length<  0x0D)
>
>
> Thanks Alex! Looks good to me.
>
> Acked-by: Colin King <colin.king@canonical.com>
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/dmi/dmi_decode/dmi_decode.c b/src/dmi/dmi_decode/dmi_decode.c
index 486a826..02790d9 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,14 @@  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) ");
+			}
+			break;
 		case 23: /* 7.24 */
 			table = "System Reset (Type 23)";
 			if (hdr->length < 0x0D)