diff options
author | Kylene Jo Hall <kjhall@us.ibm.com> | 2005-11-18 04:10:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-18 10:49:45 -0500 |
commit | 90612b308f2a2cc8aa08fbaf6f7184f5b7b5a855 (patch) | |
tree | ec50684193a201c7f6762287ce4f3b66bae1b04d /drivers/char/tpm | |
parent | ba3961152e7016237e15e3dfc18f08c1853d156b (diff) |
[PATCH] tpm: use ioread8 and iowrite8
Use ioread8 and iowrite8 as suggested.
Signed-off-by: Kylene Hall <kjhall@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r-- | drivers/char/tpm/tpm_atmel.c | 47 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_atmel.h | 22 |
2 files changed, 38 insertions, 31 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; |
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h index 3c5b9a8d1c49..d3478aaadd77 100644 --- a/drivers/char/tpm/tpm_atmel.h +++ b/drivers/char/tpm/tpm_atmel.h | |||
@@ -27,12 +27,14 @@ | |||
27 | #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) | 27 | #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) |
28 | #define atmel_request_region request_mem_region | 28 | #define atmel_request_region request_mem_region |
29 | #define atmel_release_region release_mem_region | 29 | #define atmel_release_region release_mem_region |
30 | static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor) | 30 | |
31 | static inline void atmel_put_base_addr(struct tpm_vendor_specific | ||
32 | *vendor) | ||
31 | { | 33 | { |
32 | iounmap(vendor->iobase); | 34 | iounmap(vendor->iobase); |
33 | } | 35 | } |
34 | 36 | ||
35 | static int atmel_get_base_addr(struct tpm_vendor_specific *vendor) | 37 | static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific *vendor) |
36 | { | 38 | { |
37 | struct device_node *dn; | 39 | struct device_node *dn; |
38 | unsigned long address, size; | 40 | unsigned long address, size; |
@@ -44,11 +46,11 @@ static int atmel_get_base_addr(struct tpm_vendor_specific *vendor) | |||
44 | dn = of_find_node_by_name(NULL, "tpm"); | 46 | dn = of_find_node_by_name(NULL, "tpm"); |
45 | 47 | ||
46 | if (!dn) | 48 | if (!dn) |
47 | return 1; | 49 | return NULL; |
48 | 50 | ||
49 | if (!device_is_compatible(dn, "AT97SC3201")) { | 51 | if (!device_is_compatible(dn, "AT97SC3201")) { |
50 | of_node_put(dn); | 52 | of_node_put(dn); |
51 | return 1; | 53 | return NULL; |
52 | } | 54 | } |
53 | 55 | ||
54 | reg = (unsigned int *) get_property(dn, "reg", ®len); | 56 | reg = (unsigned int *) get_property(dn, "reg", ®len); |
@@ -71,8 +73,7 @@ static int atmel_get_base_addr(struct tpm_vendor_specific *vendor) | |||
71 | 73 | ||
72 | vendor->base = address; | 74 | vendor->base = address; |
73 | vendor->region_size = size; | 75 | vendor->region_size = size; |
74 | vendor->iobase = ioremap(address, size); | 76 | return ioremap(vendor->base, vendor->region_size); |
75 | return 0; | ||
76 | } | 77 | } |
77 | #else | 78 | #else |
78 | #define atmel_getb(chip, offset) inb(chip->vendor->base + offset) | 79 | #define atmel_getb(chip, offset) inb(chip->vendor->base + offset) |
@@ -105,18 +106,19 @@ static int atmel_verify_tpm11(void) | |||
105 | return 0; | 106 | return 0; |
106 | } | 107 | } |
107 | 108 | ||
108 | static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor) | 109 | static inline void atmel_put_base_addr(struct tpm_vendor_specific |
110 | *vendor) | ||
109 | { | 111 | { |
110 | } | 112 | } |
111 | 113 | ||
112 | /* Determine where to talk to device */ | 114 | /* Determine where to talk to device */ |
113 | static unsigned long atmel_get_base_addr(struct tpm_vendor_specific | 115 | static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific |
114 | *vendor) | 116 | *vendor) |
115 | { | 117 | { |
116 | int lo, hi; | 118 | int lo, hi; |
117 | 119 | ||
118 | if (atmel_verify_tpm11() != 0) | 120 | if (atmel_verify_tpm11() != 0) |
119 | return 1; | 121 | return NULL; |
120 | 122 | ||
121 | lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); | 123 | lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); |
122 | hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); | 124 | hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); |
@@ -124,6 +126,6 @@ static unsigned long atmel_get_base_addr(struct tpm_vendor_specific | |||
124 | vendor->base = (hi << 8) | lo; | 126 | vendor->base = (hi << 8) | lo; |
125 | vendor->region_size = 2; | 127 | vendor->region_size = 2; |
126 | 128 | ||
127 | return 0; | 129 | return ioport_map(vendor->base, vendor->region_size); |
128 | } | 130 | } |
129 | #endif | 131 | #endif |