tpm_nsc.c (1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) tpm_nsc.c (700d8bdcd0fa815b08638b1e4d43b66d60cc6a8d)
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Authors:
5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Dave Safford <safford@watson.ibm.com>
7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com>

--- 41 unchanged lines hidden (view full) ---

50#define NSC_COMMAND_EOC 0x03
51#define NSC_COMMAND_CANCEL 0x22
52
53/*
54 * Wait for a certain status to appear
55 */
56static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
57{
1/*
2 * Copyright (C) 2004 IBM Corporation
3 *
4 * Authors:
5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Dave Safford <safford@watson.ibm.com>
7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com>

--- 41 unchanged lines hidden (view full) ---

50#define NSC_COMMAND_EOC 0x03
51#define NSC_COMMAND_CANCEL 0x22
52
53/*
54 * Wait for a certain status to appear
55 */
56static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
57{
58 int expired = 0;
59 struct timer_list status_timer =
60 TIMER_INITIALIZER(tpm_time_expired, jiffies + 10 * HZ,
61 (unsigned long) &expired);
58 unsigned long stop;
62
63 /* status immediately available check */
64 *data = inb(chip->vendor->base + NSC_STATUS);
65 if ((*data & mask) == val)
66 return 0;
67
68 /* wait for status */
59
60 /* status immediately available check */
61 *data = inb(chip->vendor->base + NSC_STATUS);
62 if ((*data & mask) == val)
63 return 0;
64
65 /* wait for status */
69 add_timer(&status_timer);
66 stop = jiffies + 10 * HZ;
70 do {
67 do {
71 set_current_state(TASK_UNINTERRUPTIBLE);
72 schedule_timeout(TPM_TIMEOUT);
68 msleep(TPM_TIMEOUT);
73 *data = inb(chip->vendor->base + 1);
69 *data = inb(chip->vendor->base + 1);
74 if ((*data & mask) == val) {
75 del_singleshot_timer_sync(&status_timer);
70 if ((*data & mask) == val)
76 return 0;
71 return 0;
77 }
78 }
72 }
79 while (!expired);
73 while (time_before(jiffies, stop));
80
81 return -EBUSY;
82}
83
84static int nsc_wait_for_ready(struct tpm_chip *chip)
85{
86 int status;
74
75 return -EBUSY;
76}
77
78static int nsc_wait_for_ready(struct tpm_chip *chip)
79{
80 int status;
87 int expired = 0;
88 struct timer_list status_timer =
89 TIMER_INITIALIZER(tpm_time_expired, jiffies + 100,
90 (unsigned long) &expired);
81 unsigned long stop;
91
92 /* status immediately available check */
93 status = inb(chip->vendor->base + NSC_STATUS);
94 if (status & NSC_STATUS_OBF)
95 status = inb(chip->vendor->base + NSC_DATA);
96 if (status & NSC_STATUS_RDY)
97 return 0;
98
99 /* wait for status */
82
83 /* status immediately available check */
84 status = inb(chip->vendor->base + NSC_STATUS);
85 if (status & NSC_STATUS_OBF)
86 status = inb(chip->vendor->base + NSC_DATA);
87 if (status & NSC_STATUS_RDY)
88 return 0;
89
90 /* wait for status */
100 add_timer(&status_timer);
91 stop = jiffies + 100;
101 do {
92 do {
102 set_current_state(TASK_UNINTERRUPTIBLE);
103 schedule_timeout(TPM_TIMEOUT);
93 msleep(TPM_TIMEOUT);
104 status = inb(chip->vendor->base + NSC_STATUS);
105 if (status & NSC_STATUS_OBF)
106 status = inb(chip->vendor->base + NSC_DATA);
94 status = inb(chip->vendor->base + NSC_STATUS);
95 if (status & NSC_STATUS_OBF)
96 status = inb(chip->vendor->base + NSC_DATA);
107 if (status & NSC_STATUS_RDY) {
108 del_singleshot_timer_sync(&status_timer);
97 if (status & NSC_STATUS_RDY)
109 return 0;
98 return 0;
110 }
111 }
99 }
112 while (!expired);
100 while (time_before(jiffies, stop));
113
114 dev_info(&chip->pci_dev->dev, "wait for ready failed\n");
115 return -EBUSY;
116}
117
118
119static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
120{

--- 253 unchanged lines hidden ---
101
102 dev_info(&chip->pci_dev->dev, "wait for ready failed\n");
103 return -EBUSY;
104}
105
106
107static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
108{

--- 253 unchanged lines hidden ---