Commit 90612b30 authored by Kylene Jo Hall's avatar Kylene Jo Hall Committed by Linus Torvalds

[PATCH] tpm: use ioread8 and iowrite8

Use ioread8 and iowrite8 as suggested.
Signed-off-by: default avatarKylene Hall <kjhall@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ba396115
...@@ -47,13 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -47,13 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
return -EIO; return -EIO;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
status = atmel_getb(chip, 1); status = ioread8(chip->vendor->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) { if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, dev_err(chip->dev, "error reading header\n");
"error reading header\n");
return -EIO; return -EIO;
} }
*buf++ = atmel_getb(chip, 0); *buf++ = ioread8(chip->vendor->iobase);
} }
/* size of the data received */ /* size of the data received */
...@@ -64,10 +63,9 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -64,10 +63,9 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
dev_err(chip->dev, dev_err(chip->dev,
"Recv size(%d) less than available space\n", size); "Recv size(%d) less than available space\n", size);
for (; i < size; i++) { /* clear the waiting data anyway */ for (; i < size; i++) { /* clear the waiting data anyway */
status = atmel_getb(chip, 1); status = ioread8(chip->vendor->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) { if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, dev_err(chip->dev, "error reading data\n");
"error reading data\n");
return -EIO; return -EIO;
} }
} }
...@@ -76,17 +74,17 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -76,17 +74,17 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
/* read all the data available */ /* read all the data available */
for (; i < size; i++) { for (; i < size; i++) {
status = atmel_getb(chip, 1); status = ioread8(chip->vendor->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) { if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(chip->dev, dev_err(chip->dev, "error reading data\n");
"error reading data\n");
return -EIO; return -EIO;
} }
*buf++ = atmel_getb(chip, 0); *buf++ = ioread8(chip->vendor->iobase);
} }
/* make sure data available is gone */ /* make sure data available is gone */
status = atmel_getb(chip, 1); status = ioread8(chip->vendor->iobase + 1);
if (status & ATML_STATUS_DATA_AVAIL) { if (status & ATML_STATUS_DATA_AVAIL) {
dev_err(chip->dev, "data available is stuck\n"); dev_err(chip->dev, "data available is stuck\n");
return -EIO; return -EIO;
...@@ -102,7 +100,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -102,7 +100,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
dev_dbg(chip->dev, "tpm_atml_send:\n"); dev_dbg(chip->dev, "tpm_atml_send:\n");
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
atmel_putb(buf[i], chip, 0); iowrite8(buf[i], chip->vendor->iobase);
} }
return count; return count;
...@@ -110,12 +108,12 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -110,12 +108,12 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
static void tpm_atml_cancel(struct tpm_chip *chip) static void tpm_atml_cancel(struct tpm_chip *chip)
{ {
atmel_putb(ATML_STATUS_ABORT, chip, 1); iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1);
} }
static u8 tpm_atml_status(struct tpm_chip *chip) static u8 tpm_atml_status(struct tpm_chip *chip)
{ {
return atmel_getb(chip, 1); return ioread8(chip->vendor->iobase + 1);
} }
static struct file_operations atmel_ops = { static struct file_operations atmel_ops = {
...@@ -162,7 +160,8 @@ static void atml_plat_remove(void) ...@@ -162,7 +160,8 @@ static void atml_plat_remove(void)
if (chip) { if (chip) {
if (chip->vendor->have_region) if (chip->vendor->have_region)
atmel_release_region(chip->vendor->base, chip->vendor->region_size); atmel_release_region(chip->vendor->base,
chip->vendor->region_size);
atmel_put_base_addr(chip->vendor); atmel_put_base_addr(chip->vendor);
tpm_remove_hardware(chip->dev); tpm_remove_hardware(chip->dev);
platform_device_unregister(pdev); platform_device_unregister(pdev);
...@@ -183,14 +182,19 @@ static int __init init_atmel(void) ...@@ -183,14 +182,19 @@ static int __init init_atmel(void)
driver_register(&atml_drv); driver_register(&atml_drv);
if (atmel_get_base_addr(&tpm_atmel) != 0) { if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) {
rc = -ENODEV; rc = -ENODEV;
goto err_unreg_drv; goto err_unreg_drv;
} }
tpm_atmel.have_region = (atmel_request_region( tpm_atmel.base, tpm_atmel.region_size, "tpm_atmel0") == NULL) ? 0 : 1; tpm_atmel.have_region =
(atmel_request_region
(tpm_atmel.base, tpm_atmel.region_size,
"tpm_atmel0") == NULL) ? 0 : 1;
if (IS_ERR(pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0 ))) { if (IS_ERR
(pdev =
platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
rc = PTR_ERR(pdev); rc = PTR_ERR(pdev);
goto err_rel_reg; goto err_rel_reg;
} }
...@@ -202,9 +206,10 @@ static int __init init_atmel(void) ...@@ -202,9 +206,10 @@ static int __init init_atmel(void)
err_unreg_dev: err_unreg_dev:
platform_device_unregister(pdev); platform_device_unregister(pdev);
err_rel_reg: err_rel_reg:
if (tpm_atmel.have_region)
atmel_release_region(tpm_atmel.base, tpm_atmel.region_size);
atmel_put_base_addr(&tpm_atmel); atmel_put_base_addr(&tpm_atmel);
if (tpm_atmel.have_region)
atmel_release_region(tpm_atmel.base,
tpm_atmel.region_size);
err_unreg_drv: err_unreg_drv:
driver_unregister(&atml_drv); driver_unregister(&atml_drv);
return rc; return rc;
......
...@@ -27,12 +27,14 @@ ...@@ -27,12 +27,14 @@
#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) #define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
#define atmel_request_region request_mem_region #define atmel_request_region request_mem_region
#define atmel_release_region release_mem_region #define atmel_release_region release_mem_region
static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor)
static inline void atmel_put_base_addr(struct tpm_vendor_specific
*vendor)
{ {
iounmap(vendor->iobase); iounmap(vendor->iobase);
} }
static int atmel_get_base_addr(struct tpm_vendor_specific *vendor) static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific *vendor)
{ {
struct device_node *dn; struct device_node *dn;
unsigned long address, size; unsigned long address, size;
...@@ -44,11 +46,11 @@ static int atmel_get_base_addr(struct tpm_vendor_specific *vendor) ...@@ -44,11 +46,11 @@ static int atmel_get_base_addr(struct tpm_vendor_specific *vendor)
dn = of_find_node_by_name(NULL, "tpm"); dn = of_find_node_by_name(NULL, "tpm");
if (!dn) if (!dn)
return 1; return NULL;
if (!device_is_compatible(dn, "AT97SC3201")) { if (!device_is_compatible(dn, "AT97SC3201")) {
of_node_put(dn); of_node_put(dn);
return 1; return NULL;
} }
reg = (unsigned int *) get_property(dn, "reg", &reglen); reg = (unsigned int *) get_property(dn, "reg", &reglen);
...@@ -71,8 +73,7 @@ static int atmel_get_base_addr(struct tpm_vendor_specific *vendor) ...@@ -71,8 +73,7 @@ static int atmel_get_base_addr(struct tpm_vendor_specific *vendor)
vendor->base = address; vendor->base = address;
vendor->region_size = size; vendor->region_size = size;
vendor->iobase = ioremap(address, size); return ioremap(vendor->base, vendor->region_size);
return 0;
} }
#else #else
#define atmel_getb(chip, offset) inb(chip->vendor->base + offset) #define atmel_getb(chip, offset) inb(chip->vendor->base + offset)
...@@ -105,18 +106,19 @@ static int atmel_verify_tpm11(void) ...@@ -105,18 +106,19 @@ static int atmel_verify_tpm11(void)
return 0; return 0;
} }
static inline void atmel_put_base_addr(struct tpm_vendor_specific *vendor) static inline void atmel_put_base_addr(struct tpm_vendor_specific
*vendor)
{ {
} }
/* Determine where to talk to device */ /* Determine where to talk to device */
static unsigned long atmel_get_base_addr(struct tpm_vendor_specific static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific
*vendor) *vendor)
{ {
int lo, hi; int lo, hi;
if (atmel_verify_tpm11() != 0) if (atmel_verify_tpm11() != 0)
return 1; return NULL;
lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); 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,6 +126,6 @@ static unsigned long atmel_get_base_addr(struct tpm_vendor_specific
vendor->base = (hi << 8) | lo; vendor->base = (hi << 8) | lo;
vendor->region_size = 2; vendor->region_size = 2;
return 0; return ioport_map(vendor->base, vendor->region_size);
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment