tpm: Store devname in the tpm_chip

Just put the memory directly in the chip structure, rather than
a 2nd dedicated kalloc.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: Use container_of to locate the tpm_chip in tpm_open

misc_open sets the file->private_date to the misc_dev when calling
open. We can use container_of to go from the misc_dev back to the
tpm_chip.

Future clean ups will move tpm_open into a new file and this change
means we do not have to export the tpm_chip list.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: Pull everything related to /dev/tpmX into tpm-dev.c

CLASS-dev.c is a common idiom for Linux subsystems

This pulls all the code related to the miscdev into tpm-dev.c and makes it
static. The identical file_operation structs in the drivers are purged and the
tpm common code unconditionally creates the miscdev.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: Remove tpm_show_caps_1_2

The version of the TPM should not depend on the bus it is connected
through. 1.1, 1.2 and soon 2.0 TPMS will be all be able to use the
same bus interfaces.

Make tpm_show_caps try the 1.2 capability first. If that fails then
fall back to the 1.1 capability. This effectively auto-detects what
interface the TPM supports at run-time.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: Pull everything related to sysfs into tpm-sysfs.c

CLASS-sysfs.c is a common idiom for linux subsystems.

This pulls all the sysfs attribute functions and related code
into tpm-sysfs.c. To support this change some constants are moved
from tpm.c to tpm.h and __tpm_pcr_read is made non-static and is
called tpm_pcr_read_dev.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
tpm: Create a tpm_class_ops structure and use it

This replaces the static initialization of a tpm_vendor_specific
structure in the drivers with the standard Linux idiom of providing
a const structure of function pointers.

As the first clean up step this just changes the names and copies
ops into chip->vendor exactly as before.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
JUNK: Provide a vio.h good enough to compile tpm_ibmvtpm.c on x86

This way I can easily compile test all TPM drivers
fixup! tpm: Pull everything related to /dev/tpmX into tpm-dev.c
fixup! tpm: Pull everything related to sysfs into tpm-sysfs.c