- if (count == 0) {
- error("no data\n");
- return -ENODATA;
- }
- if (count > bufsiz) {
- error("invalid count value %x %zx\n", count, bufsiz);
- return -E2BIG;
- }
-
- debug("Calling send\n");
- rc = tpm_tis_i2c_send(chip, (u8 *)buf, count);
- debug(" ... done calling send\n");
- if (rc < 0) {
- error("tpm_transmit: tpm_send: error %d\n", rc);
- goto out;
- }
-
- if (chip->irq)
- goto out_recv;
-
- start = get_timer(0);
- stop = tpm_tis_i2c_calc_ordinal_duration(chip, ordinal);
- do {
- debug("waiting for status... %ld %ld\n", start, stop);
- u8 status = tpm_tis_i2c_status(chip);
- if ((status & chip->req_complete_mask) ==
- chip->req_complete_val) {
- debug("...got it;\n");
- goto out_recv;
- }
-
- if (status == chip->req_canceled) {
- error("Operation Canceled\n");
- rc = -ECANCELED;
- goto out;
- }
- mdelay(TPM_TIMEOUT_MS);
- } while (get_timer(start) < stop);
-
- tpm_tis_i2c_ready(chip);
- error("Operation Timed out\n");
- rc = -ETIME;
- goto out;
-
-out_recv:
- debug("out_recv: reading response...\n");
- rc = tpm_tis_i2c_recv(chip, (u8 *)buf, TPM_BUFSIZE);