diff options
author | Dave Jones <davej@redhat.com> | 2005-11-21 09:56:52 -0500 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2005-11-21 09:56:52 -0500 |
commit | e7e37ee9c547213d726b29c2510cbb6696050405 (patch) | |
tree | 50c45625de666b23f209d79eb1bfae05c64feee9 /drivers/char | |
parent | c243f1f1f6545985afcc6adf1fc085729029c3ee (diff) | |
parent | db93a82fa9d8b4d6e31c227922eaae829253bb88 (diff) |
Merge ../linus/
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 2 | ||||
-rw-r--r-- | drivers/char/tpm/Kconfig | 2 | ||||
-rw-r--r-- | drivers/char/tpm/tpm.c | 2 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_atmel.c | 47 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_atmel.h | 22 |
5 files changed, 42 insertions, 33 deletions
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index ea89dca3dbb5..01a1f6badb53 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -2203,7 +2203,7 @@ static void setup_xaction_handlers(struct smi_info *smi_info) | |||
2203 | 2203 | ||
2204 | static inline void wait_for_timer_and_thread(struct smi_info *smi_info) | 2204 | static inline void wait_for_timer_and_thread(struct smi_info *smi_info) |
2205 | { | 2205 | { |
2206 | if (smi_info->thread != ERR_PTR(-ENOMEM)) | 2206 | if (smi_info->thread != NULL && smi_info->thread != ERR_PTR(-ENOMEM)) |
2207 | kthread_stop(smi_info->thread); | 2207 | kthread_stop(smi_info->thread); |
2208 | del_timer_sync(&smi_info->si_timer); | 2208 | del_timer_sync(&smi_info->si_timer); |
2209 | } | 2209 | } |
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index b58adfe3ed19..a6873bf89ffa 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
@@ -6,7 +6,7 @@ menu "TPM devices" | |||
6 | 6 | ||
7 | config TCG_TPM | 7 | config TCG_TPM |
8 | tristate "TPM Hardware Support" | 8 | tristate "TPM Hardware Support" |
9 | depends on EXPERIMENTAL && PCI | 9 | depends on EXPERIMENTAL |
10 | ---help--- | 10 | ---help--- |
11 | If you have a TPM security chip in your system, which | 11 | If you have a TPM security chip in your system, which |
12 | implements the Trusted Computing Group's specification, | 12 | implements the Trusted Computing Group's specification, |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 0b283d246730..a9be0e8eaea5 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -377,6 +377,7 @@ int tpm_release(struct inode *inode, struct file *file) | |||
377 | file->private_data = NULL; | 377 | file->private_data = NULL; |
378 | chip->num_opens--; | 378 | chip->num_opens--; |
379 | del_singleshot_timer_sync(&chip->user_read_timer); | 379 | del_singleshot_timer_sync(&chip->user_read_timer); |
380 | flush_scheduled_work(); | ||
380 | atomic_set(&chip->data_pending, 0); | 381 | atomic_set(&chip->data_pending, 0); |
381 | put_device(chip->dev); | 382 | put_device(chip->dev); |
382 | kfree(chip->data_buffer); | 383 | kfree(chip->data_buffer); |
@@ -428,6 +429,7 @@ ssize_t tpm_read(struct file * file, char __user *buf, | |||
428 | int ret_size; | 429 | int ret_size; |
429 | 430 | ||
430 | del_singleshot_timer_sync(&chip->user_read_timer); | 431 | del_singleshot_timer_sync(&chip->user_read_timer); |
432 | flush_scheduled_work(); | ||
431 | ret_size = atomic_read(&chip->data_pending); | 433 | ret_size = atomic_read(&chip->data_pending); |
432 | atomic_set(&chip->data_pending, 0); | 434 | atomic_set(&chip->data_pending, 0); |
433 | if (ret_size > 0) { /* relay data */ | 435 | if (ret_size > 0) { /* relay data */ |
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 |