tpm: Use the ops structure instead of a copy in tpm_vendor_specific
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tue, 26 Nov 2013 20:30:44 +0000 (13:30 -0700)
committerPeter Huewe <peterhuewe@gmx.de>
Mon, 6 Jan 2014 13:37:25 +0000 (14:37 +0100)
This builds on the last commit to use the ops structure in the core
and reduce the size of tpm_vendor_specific.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Reviewed-by: Ashley Lai <adlai@linux.vnet.ibm.com>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
drivers/char/tpm/tpm-interface.c
drivers/char/tpm/tpm-sysfs.c
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm_i2c_stm_st33.c

index 1b01246..62e10fd 100644 (file)
@@ -353,7 +353,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 
        mutex_lock(&chip->tpm_mutex);
 
-       rc = chip->vendor.send(chip, (u8 *) buf, count);
+       rc = chip->ops->send(chip, (u8 *) buf, count);
        if (rc < 0) {
                dev_err(chip->dev,
                        "tpm_transmit: tpm_send: error %zd\n", rc);
@@ -365,12 +365,12 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 
        stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
        do {
-               u8 status = chip->vendor.status(chip);
-               if ((status & chip->vendor.req_complete_mask) ==
-                   chip->vendor.req_complete_val)
+               u8 status = chip->ops->status(chip);
+               if ((status & chip->ops->req_complete_mask) ==
+                   chip->ops->req_complete_val)
                        goto out_recv;
 
-               if (chip->vendor.req_canceled(chip, status)) {
+               if (chip->ops->req_canceled(chip, status)) {
                        dev_err(chip->dev, "Operation Canceled\n");
                        rc = -ECANCELED;
                        goto out;
@@ -380,13 +380,13 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
                rmb();
        } while (time_before(jiffies, stop));
 
-       chip->vendor.cancel(chip);
+       chip->ops->cancel(chip);
        dev_err(chip->dev, "Operation Timed out\n");
        rc = -ETIME;
        goto out;
 
 out_recv:
-       rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz);
+       rc = chip->ops->recv(chip, (u8 *) buf, bufsiz);
        if (rc < 0)
                dev_err(chip->dev,
                        "tpm_transmit: tpm_recv: error %zd\n", rc);
@@ -807,12 +807,12 @@ EXPORT_SYMBOL_GPL(tpm_send);
 static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
                                        bool check_cancel, bool *canceled)
 {
-       u8 status = chip->vendor.status(chip);
+       u8 status = chip->ops->status(chip);
 
        *canceled = false;
        if ((status & mask) == mask)
                return true;
-       if (check_cancel && chip->vendor.req_canceled(chip, status)) {
+       if (check_cancel && chip->ops->req_canceled(chip, status)) {
                *canceled = true;
                return true;
        }
@@ -828,7 +828,7 @@ int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
        bool canceled = false;
 
        /* check current status */
-       status = chip->vendor.status(chip);
+       status = chip->ops->status(chip);
        if ((status & mask) == mask)
                return 0;
 
@@ -855,7 +855,7 @@ again:
        } else {
                do {
                        msleep(TPM_TIMEOUT);
-                       status = chip->vendor.status(chip);
+                       status = chip->ops->status(chip);
                        if ((status & mask) == mask)
                                return 0;
                } while (time_before(jiffies, stop));
@@ -1027,9 +1027,6 @@ void tpm_dev_vendor_release(struct tpm_chip *chip)
        if (!chip)
                return;
 
-       if (chip->vendor.release)
-               chip->vendor.release(chip->dev);
-
        clear_bit(chip->dev_num, dev_mask);
 }
 EXPORT_SYMBOL_GPL(tpm_dev_vendor_release);
@@ -1073,14 +1070,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
        mutex_init(&chip->tpm_mutex);
        INIT_LIST_HEAD(&chip->list);
 
-       chip->vendor.req_complete_mask = ops->req_complete_mask;
-       chip->vendor.req_complete_val = ops->req_complete_val;
-       chip->vendor.req_canceled = ops->req_canceled;
-       chip->vendor.recv = ops->recv;
-       chip->vendor.send = ops->send;
-       chip->vendor.cancel = ops->cancel;
-       chip->vendor.status = ops->status;
-
+       chip->ops = ops;
        chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES);
 
        if (chip->dev_num >= TPM_NUM_DEVICES) {
index 506a07b..c3503cb 100644 (file)
@@ -245,7 +245,7 @@ static ssize_t cancel_store(struct device *dev, struct device_attribute *attr,
        if (chip == NULL)
                return 0;
 
-       chip->vendor.cancel(chip);
+       chip->ops->cancel(chip);
        return count;
 }
 static DEVICE_ATTR_WO(cancel);
Simple merge
Simple merge