diff options
author | Kyle McMartin <kyle@parisc-linux.org> | 2005-11-18 16:39:20 -0500 |
---|---|---|
committer | Kyle McMartin <kyle@parisc-linux.org> | 2005-11-18 16:39:20 -0500 |
commit | 2161558fa5bebfeb272493ae91e836b497029023 (patch) | |
tree | 16304f91757243626d74e65063ee7224cacbf797 /drivers/char/tpm/tpm_atmel.c | |
parent | e670dfb9a4f9e136da44db167da75b2365f7cebb (diff) | |
parent | e67b23c71cb9ee02d65a74c3858716ba2dedd554 (diff) |
Merge branch 'master'
Diffstat (limited to 'drivers/char/tpm/tpm_atmel.c')
-rw-r--r-- | drivers/char/tpm/tpm_atmel.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index deb4b5c80914..ff3654964fe3 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c | |||
@@ -47,13 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
47 | return -EIO; | 47 | return -EIO; |
48 | 48 | ||
49 | for (i = 0; i < 6; i++) { | 49 | for (i = 0; i < 6; i++) { |
50 | status = atmel_getb(chip, 1); | 50 | status = ioread8(chip->vendor->iobase + 1); |
51 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { | 51 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { |
52 | dev_err(chip->dev, | 52 | dev_err(chip->dev, "error reading header\n"); |
53 | "error reading header\n"); | ||
54 | return -EIO; | 53 | return -EIO; |
55 | } | 54 | } |
56 | *buf++ = atmel_getb(chip, 0); | 55 | *buf++ = ioread8(chip->vendor->iobase); |
57 | } | 56 | } |
58 | 57 | ||
59 | /* size of the data received */ | 58 | /* size of the data received */ |
@@ -64,10 +63,9 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
64 | dev_err(chip->dev, | 63 | dev_err(chip->dev, |
65 | "Recv size(%d) less than available space\n", size); | 64 | "Recv size(%d) less than available space\n", size); |
66 | for (; i < size; i++) { /* clear the waiting data anyway */ | 65 | for (; i < size; i++) { /* clear the waiting data anyway */ |
67 | status = atmel_getb(chip, 1); | 66 | status = ioread8(chip->vendor->iobase + 1); |
68 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { | 67 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { |
69 | dev_err(chip->dev, | 68 | dev_err(chip->dev, "error reading data\n"); |
70 | "error reading data\n"); | ||
71 | return -EIO; | 69 | return -EIO; |
72 | } | 70 | } |
73 | } | 71 | } |
@@ -76,17 +74,17 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
76 | 74 | ||
77 | /* read all the data available */ | 75 | /* read all the data available */ |
78 | for (; i < size; i++) { | 76 | for (; i < size; i++) { |
79 | status = atmel_getb(chip, 1); | 77 | status = ioread8(chip->vendor->iobase + 1); |
80 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { | 78 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { |
81 | dev_err(chip->dev, | 79 | dev_err(chip->dev, "error reading data\n"); |
82 | "error reading data\n"); | ||
83 | return -EIO; | 80 | return -EIO; |
84 | } | 81 | } |
85 | *buf++ = atmel_getb(chip, 0); | 82 | *buf++ = ioread8(chip->vendor->iobase); |
86 | } | 83 | } |
87 | 84 | ||
88 | /* make sure data available is gone */ | 85 | /* make sure data available is gone */ |
89 | status = atmel_getb(chip, 1); | 86 | status = ioread8(chip->vendor->iobase + 1); |
87 | |||
90 | if (status & ATML_STATUS_DATA_AVAIL) { | 88 | if (status & ATML_STATUS_DATA_AVAIL) { |
91 | dev_err(chip->dev, "data available is stuck\n"); | 89 | dev_err(chip->dev, "data available is stuck\n"); |
92 | return -EIO; | 90 | return -EIO; |
@@ -102,7 +100,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
102 | dev_dbg(chip->dev, "tpm_atml_send:\n"); | 100 | dev_dbg(chip->dev, "tpm_atml_send:\n"); |
103 | for (i = 0; i < count; i++) { | 101 | for (i = 0; i < count; i++) { |
104 | dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); | 102 | dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); |
105 | atmel_putb(buf[i], chip, 0); | 103 | iowrite8(buf[i], chip->vendor->iobase); |
106 | } | 104 | } |
107 | 105 | ||
108 | return count; | 106 | return count; |
@@ -110,12 +108,12 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
110 | 108 | ||
111 | static void tpm_atml_cancel(struct tpm_chip *chip) | 109 | static void tpm_atml_cancel(struct tpm_chip *chip) |
112 | { | 110 | { |
113 | atmel_putb(ATML_STATUS_ABORT, chip, 1); | 111 | iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1); |
114 | } | 112 | } |
115 | 113 | ||
116 | static u8 tpm_atml_status(struct tpm_chip *chip) | 114 | static u8 tpm_atml_status(struct tpm_chip *chip) |
117 | { | 115 | { |
118 | return atmel_getb(chip, 1); | 116 | return ioread8(chip->vendor->iobase + 1); |
119 | } | 117 | } |
120 | 118 | ||
121 | static struct file_operations atmel_ops = { | 119 | static struct file_operations atmel_ops = { |
@@ -162,7 +160,8 @@ static void atml_plat_remove(void) | |||
162 | 160 | ||
163 | if (chip) { | 161 | if (chip) { |
164 | if (chip->vendor->have_region) | 162 | if (chip->vendor->have_region) |
165 | atmel_release_region(chip->vendor->base, chip->vendor->region_size); | 163 | atmel_release_region(chip->vendor->base, |
164 | chip->vendor->region_size); | ||
166 | atmel_put_base_addr(chip->vendor); | 165 | atmel_put_base_addr(chip->vendor); |
167 | tpm_remove_hardware(chip->dev); | 166 | tpm_remove_hardware(chip->dev); |
168 | platform_device_unregister(pdev); | 167 | platform_device_unregister(pdev); |
@@ -183,14 +182,19 @@ static int __init init_atmel(void) | |||
183 | 182 | ||
184 | driver_register(&atml_drv); | 183 | driver_register(&atml_drv); |
185 | 184 | ||
186 | if (atmel_get_base_addr(&tpm_atmel) != 0) { | 185 | if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) { |
187 | rc = -ENODEV; | 186 | rc = -ENODEV; |
188 | goto err_unreg_drv; | 187 | goto err_unreg_drv; |
189 | } | 188 | } |
190 | 189 | ||
191 | tpm_atmel.have_region = (atmel_request_region( tpm_atmel.base, tpm_atmel.region_size, "tpm_atmel0") == NULL) ? 0 : 1; | 190 | tpm_atmel.have_region = |
191 | (atmel_request_region | ||
192 | (tpm_atmel.base, tpm_atmel.region_size, | ||
193 | "tpm_atmel0") == NULL) ? 0 : 1; | ||
192 | 194 | ||
193 | if (IS_ERR(pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0 ))) { | 195 | if (IS_ERR |
196 | (pdev = | ||
197 | platform_device_register_simple("tpm_atmel", -1, NULL, 0))) { | ||
194 | rc = PTR_ERR(pdev); | 198 | rc = PTR_ERR(pdev); |
195 | goto err_rel_reg; | 199 | goto err_rel_reg; |
196 | } | 200 | } |
@@ -202,9 +206,10 @@ static int __init init_atmel(void) | |||
202 | err_unreg_dev: | 206 | err_unreg_dev: |
203 | platform_device_unregister(pdev); | 207 | platform_device_unregister(pdev); |
204 | err_rel_reg: | 208 | err_rel_reg: |
205 | if (tpm_atmel.have_region) | ||
206 | atmel_release_region(tpm_atmel.base, tpm_atmel.region_size); | ||
207 | atmel_put_base_addr(&tpm_atmel); | 209 | atmel_put_base_addr(&tpm_atmel); |
210 | if (tpm_atmel.have_region) | ||
211 | atmel_release_region(tpm_atmel.base, | ||
212 | tpm_atmel.region_size); | ||
208 | err_unreg_drv: | 213 | err_unreg_drv: |
209 | driver_unregister(&atml_drv); | 214 | driver_unregister(&atml_drv); |
210 | return rc; | 215 | return rc; |