]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/char/tpm/tpm_of.c
HID: usbhid: Add HID_QUIRK_NOGET for Aten CS-1758 KVM switch
[mirror_ubuntu-artful-kernel.git] / drivers / char / tpm / tpm_of.c
CommitLineData
c5df3926
AL
1/*
2 * Copyright 2012 IBM Corporation
3 *
1a0f1b27 4 * Author: Ashley Lai <ashleydlai@gmail.com>
02ae1382 5 * Nayna Jain <nayna@linux.vnet.ibm.com>
c5df3926
AL
6 *
7 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
8 *
9 * Read the event log created by the firmware on PPC64
10 *
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.
15 *
16 */
17
18#include <linux/slab.h>
19#include <linux/of.h>
20
21#include "tpm.h"
22#include "tpm_eventlog.h"
23
02ae1382 24int tpm_read_log_of(struct tpm_chip *chip)
c5df3926
AL
25{
26 struct device_node *np;
27 const u32 *sizep;
d72c3911 28 const u64 *basep;
748935ee 29 struct tpm_bios_log *log;
c5df3926 30
748935ee 31 log = &chip->log;
0cf577a0 32 if (chip->dev.parent && chip->dev.parent->of_node)
ed4fdb4f 33 np = chip->dev.parent->of_node;
79eec5b9 34 else
c5df3926 35 return -ENODEV;
c5df3926
AL
36
37 sizep = of_get_property(np, "linux,sml-size", NULL);
0cf577a0
JG
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)
5efae7d6
NJ
42 return -EIO;
43
c5df3926 44 if (*sizep == 0) {
5efae7d6
NJ
45 dev_warn(&chip->dev, "%s: Event log area empty\n", __func__);
46 return -EIO;
c5df3926
AL
47 }
48
c5df3926 49 log->bios_event_log = kmalloc(*sizep, GFP_KERNEL);
5efae7d6 50 if (!log->bios_event_log)
c5df3926 51 return -ENOMEM;
c5df3926
AL
52
53 log->bios_event_log_end = log->bios_event_log + *sizep;
54
d72c3911 55 memcpy(log->bios_event_log, __va(*basep), *sizep);
c5df3926
AL
56
57 return 0;
c5df3926 58}