sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / char / tpm / tpm_of.c
blob7dee42d7b5e05c03f7d01c3ea3554ba89921f5c1
1 /*
2 * Copyright 2012 IBM Corporation
4 * Author: Ashley Lai <ashleydlai@gmail.com>
5 * Nayna Jain <nayna@linux.vnet.ibm.com>
7 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
9 * Read the event log created by the firmware on PPC64
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
18 #include <linux/slab.h>
19 #include <linux/of.h>
21 #include "tpm.h"
22 #include "tpm_eventlog.h"
24 int tpm_read_log_of(struct tpm_chip *chip)
26 struct device_node *np;
27 const u32 *sizep;
28 const u64 *basep;
29 struct tpm_bios_log *log;
31 log = &chip->log;
32 if (chip->dev.parent && chip->dev.parent->of_node)
33 np = chip->dev.parent->of_node;
34 else
35 return -ENODEV;
37 sizep = of_get_property(np, "linux,sml-size", NULL);
38 basep = of_get_property(np, "linux,sml-base", NULL);
39 if (sizep == NULL && basep == NULL)
40 return -ENODEV;
41 if (sizep == NULL || basep == NULL)
42 return -EIO;
44 if (*sizep == 0) {
45 dev_warn(&chip->dev, "%s: Event log area empty\n", __func__);
46 return -EIO;
49 log->bios_event_log = kmalloc(*sizep, GFP_KERNEL);
50 if (!log->bios_event_log)
51 return -ENOMEM;
53 log->bios_event_log_end = log->bios_event_log + *sizep;
55 memcpy(log->bios_event_log, __va(*basep), *sizep);
57 return 0;