diff options
author | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 12:17:53 -0700 |
---|---|---|
committer | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 15:44:42 -0700 |
commit | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (patch) | |
tree | 1c9cafbcd35f783a87880a10f85d1a060db1a563 /kernel/drivers/fmc/fru-parse.c | |
parent | 98260f3884f4a202f9ca5eabed40b1354c489b29 (diff) |
Add the rt linux 4.1.3-rt3 as base
Import the rt linux 4.1.3-rt3 as OPNFV kvm base.
It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and
the base is:
commit 0917f823c59692d751951bf5ea699a2d1e2f26a2
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat Jul 25 12:13:34 2015 +0200
Prepare v4.1.3-rt3
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
We lose all the git history this way and it's not good. We
should apply another opnfv project repo in future.
Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Diffstat (limited to 'kernel/drivers/fmc/fru-parse.c')
-rw-r--r-- | kernel/drivers/fmc/fru-parse.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/kernel/drivers/fmc/fru-parse.c b/kernel/drivers/fmc/fru-parse.c new file mode 100644 index 000000000..cb46263c5 --- /dev/null +++ b/kernel/drivers/fmc/fru-parse.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2012 CERN (www.cern.ch) + * Author: Alessandro Rubini <rubini@gnudd.com> + * + * Released according to the GNU GPL, version 2 or any later version. + * + * This work is part of the White Rabbit project, a research effort led + * by CERN, the European Institute for Nuclear Research. + */ +#include <linux/ipmi-fru.h> + +/* Some internal helpers */ +static struct fru_type_length * +__fru_get_board_tl(struct fru_common_header *header, int nr) +{ + struct fru_board_info_area *bia; + struct fru_type_length *tl; + + bia = fru_get_board_area(header); + tl = bia->tl; + while (nr > 0 && !fru_is_eof(tl)) { + tl = fru_next_tl(tl); + nr--; + } + if (fru_is_eof(tl)) + return NULL; + return tl; +} + +static char *__fru_alloc_get_tl(struct fru_common_header *header, int nr) +{ + struct fru_type_length *tl; + char *res; + int len; + + tl = __fru_get_board_tl(header, nr); + if (!tl) + return NULL; + len = fru_strlen(tl); + res = fru_alloc(fru_strlen(tl) + 1); + if (!res) + return NULL; + return fru_strcpy(res, tl); +} + +/* Public checksum verifiers */ +int fru_header_cksum_ok(struct fru_common_header *header) +{ + uint8_t *ptr = (void *)header; + int i, sum; + + for (i = sum = 0; i < sizeof(*header); i++) + sum += ptr[i]; + return (sum & 0xff) == 0; +} +int fru_bia_cksum_ok(struct fru_board_info_area *bia) +{ + uint8_t *ptr = (void *)bia; + int i, sum; + + for (i = sum = 0; i < 8 * bia->area_len; i++) + sum += ptr[i]; + return (sum & 0xff) == 0; +} + +/* Get various stuff, trivial */ +char *fru_get_board_manufacturer(struct fru_common_header *header) +{ + return __fru_alloc_get_tl(header, 0); +} +char *fru_get_product_name(struct fru_common_header *header) +{ + return __fru_alloc_get_tl(header, 1); +} +char *fru_get_serial_number(struct fru_common_header *header) +{ + return __fru_alloc_get_tl(header, 2); +} +char *fru_get_part_number(struct fru_common_header *header) +{ + return __fru_alloc_get_tl(header, 3); +} |