tpm: drop the field 'time_expired' from struct tpm_chip
[cascardo/linux.git] / drivers / char / tpm / tpm.h
index 28b477e..7317bec 100644 (file)
@@ -34,7 +34,7 @@
 enum tpm_const {
        TPM_MINOR = 224,        /* officially assigned */
        TPM_BUFSIZE = 4096,
-       TPM_NUM_DEVICES = 256,
+       TPM_NUM_DEVICES = 65536,
        TPM_RETRY = 50,         /* 5 seconds */
 };
 
@@ -132,13 +132,9 @@ struct tpm_chip;
 
 struct tpm_vendor_specific {
        void __iomem *iobase;           /* ioremapped address */
-       unsigned long base;             /* TPM base address */
 
        int irq;
 
-       int region_size;
-       int have_region;
-
        struct list_head list;
        int locality;
        unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
@@ -148,9 +144,6 @@ struct tpm_vendor_specific {
        void *priv;
 
        wait_queue_head_t read_queue;
-       wait_queue_head_t int_queue;
-
-       u16 manufacturer_id;
 };
 
 #define TPM_VPRIV(c)     ((c)->vendor.priv)
@@ -167,17 +160,20 @@ enum tpm_chip_flags {
 };
 
 struct tpm_chip {
-       struct device *pdev;    /* Device stuff */
        struct device dev;
        struct cdev cdev;
 
+       /* A driver callback under ops cannot be run unless ops_sem is held
+        * (sometimes implicitly, eg for the sysfs code). ops becomes null
+        * when the driver is unregistered, see tpm_try_get_ops.
+        */
+       struct rw_semaphore ops_sem;
        const struct tpm_class_ops *ops;
+
        unsigned int flags;
 
        int dev_num;            /* /dev/tpm# */
-       char devname[7];
        unsigned long is_open;  /* only one allowed */
-       int time_expired;
 
        struct mutex tpm_mutex; /* tpm is processing */
 
@@ -191,17 +187,10 @@ struct tpm_chip {
        acpi_handle acpi_dev_handle;
        char ppi_version[TPM_PPI_VERSION_LEN + 1];
 #endif /* CONFIG_ACPI */
-
-       struct list_head list;
 };
 
 #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)
 
-static inline void tpm_chip_put(struct tpm_chip *chip)
-{
-       module_put(chip->pdev->driver->owner);
-}
-
 static inline int tpm_read_index(int base, int index)
 {
        outb(index, base);
@@ -493,6 +482,7 @@ static inline void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value)
 extern struct class *tpm_class;
 extern dev_t tpm_devt;
 extern const struct file_operations tpm_fops;
+extern struct idr dev_nums_idr;
 
 ssize_t        tpm_getcap(struct device *, __be32, cap_t *, const char *);
 ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
@@ -509,7 +499,12 @@ extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long,
                             wait_queue_head_t *, bool);
 
 struct tpm_chip *tpm_chip_find_get(int chip_num);
-extern struct tpm_chip *tpmm_chip_alloc(struct device *dev,
+__must_check int tpm_try_get_ops(struct tpm_chip *chip);
+void tpm_put_ops(struct tpm_chip *chip);
+
+extern struct tpm_chip *tpm_chip_alloc(struct device *dev,
+                                      const struct tpm_class_ops *ops);
+extern struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
                                       const struct tpm_class_ops *ops);
 extern int tpm_chip_register(struct tpm_chip *chip);
 extern void tpm_chip_unregister(struct tpm_chip *chip);