2 * Copyright (C) 2012 CERN (www.cern.ch)
3 * Author: Alessandro Rubini <rubini@gnudd.com>
5 * Released according to the GNU GPL, version 2 or any later version.
7 * This work is part of the White Rabbit project, a research effort led
8 * by CERN, the European Institute for Nuclear Research.
10 #include <linux/ipmi-fru.h>
12 /* Some internal helpers */
13 static struct fru_type_length
*
14 __fru_get_board_tl(struct fru_common_header
*header
, int nr
)
16 struct fru_board_info_area
*bia
;
17 struct fru_type_length
*tl
;
19 bia
= fru_get_board_area(header
);
21 while (nr
> 0 && !fru_is_eof(tl
)) {
30 static char *__fru_alloc_get_tl(struct fru_common_header
*header
, int nr
)
32 struct fru_type_length
*tl
;
36 tl
= __fru_get_board_tl(header
, nr
);
40 res
= fru_alloc(fru_strlen(tl
) + 1);
43 return fru_strcpy(res
, tl
);
46 /* Public checksum verifiers */
47 int fru_header_cksum_ok(struct fru_common_header
*header
)
49 uint8_t *ptr
= (void *)header
;
52 for (i
= sum
= 0; i
< sizeof(*header
); i
++)
54 return (sum
& 0xff) == 0;
56 int fru_bia_cksum_ok(struct fru_board_info_area
*bia
)
58 uint8_t *ptr
= (void *)bia
;
61 for (i
= sum
= 0; i
< 8 * bia
->area_len
; i
++)
63 return (sum
& 0xff) == 0;
66 /* Get various stuff, trivial */
67 char *fru_get_board_manufacturer(struct fru_common_header
*header
)
69 return __fru_alloc_get_tl(header
, 0);
71 char *fru_get_product_name(struct fru_common_header
*header
)
73 return __fru_alloc_get_tl(header
, 1);
75 char *fru_get_serial_number(struct fru_common_header
*header
)
77 return __fru_alloc_get_tl(header
, 2);
79 char *fru_get_part_number(struct fru_common_header
*header
)
81 return __fru_alloc_get_tl(header
, 3);