Pull bugzilla-8110 into release branch

Len Brown 51e7fff1 bdf3aaf9

+23 -17
+23 -17
drivers/acpi/ec.c
··· 100 unsigned long global_lock; 101 struct mutex lock; 102 atomic_t query_pending; 103 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ 104 wait_queue_head_t wait; 105 } *ec_ecdt; ··· 132 outb(data, ec->data_addr); 133 } 134 135 - static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event) 136 { 137 u8 status = acpi_ec_read_status(ec); 138 - 139 if (event == ACPI_EC_EVENT_OBF_1) { 140 if (status & ACPI_EC_FLAG_OBF) 141 return 1; ··· 149 return 0; 150 } 151 152 - static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event) 153 { 154 if (acpi_ec_mode == EC_POLL) { 155 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); 156 while (time_before(jiffies, delay)) { 157 - if (acpi_ec_check_status(ec, event)) 158 return 0; 159 } 160 } else { 161 if (wait_event_timeout(ec->wait, 162 - acpi_ec_check_status(ec, event), 163 msecs_to_jiffies(ACPI_EC_DELAY)) || 164 - acpi_ec_check_status(ec, event)) { 165 return 0; 166 } else { 167 printk(KERN_ERR PREFIX "acpi_ec_wait timeout," ··· 228 u8 * rdata, unsigned rdata_len) 229 { 230 int result = 0; 231 - 232 acpi_ec_write_cmd(ec, command); 233 234 for (; wdata_len > 0; --wdata_len) { 235 - result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 236 if (result) { 237 printk(KERN_ERR PREFIX 238 "write_cmd timeout, command = %d\n", command); 239 goto end; 240 } 241 acpi_ec_write_data(ec, *(wdata++)); 242 } 243 244 if (!rdata_len) { 245 - result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 246 if (result) { 247 printk(KERN_ERR PREFIX 248 "finish-write timeout, command = %d\n", command); ··· 254 } 255 256 for (; rdata_len > 0; --rdata_len) { 257 - result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1); 258 if (result) { 259 printk(KERN_ERR PREFIX "read timeout, command = %d\n", 260 command); 261 goto end; 262 } 263 - 264 *(rdata++) = acpi_ec_read_data(ec); 265 } 266 end: ··· 292 /* Make sure GPE is enabled before doing transaction */ 293 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 294 295 - status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0); 296 if (status) { 297 printk(KERN_DEBUG PREFIX 298 "input buffer is not empty, aborting transaction\n"); ··· 373 EXPORT_SYMBOL(ec_write); 374 375 int ec_transaction(u8 command, 376 - const u8 * wdata, unsigned wdata_len, 377 - u8 * rdata, unsigned rdata_len) 378 { 379 struct acpi_ec *ec; 380 ··· 439 acpi_status status = AE_OK; 440 u8 value; 441 struct acpi_ec *ec = (struct acpi_ec *)data; 442 - 443 if (acpi_ec_mode == EC_INTR) { 444 wake_up(&ec->wait); 445 } ··· 637 ec->uid = -1; 638 mutex_init(&ec->lock); 639 atomic_set(&ec->query_pending, 0); 640 if (acpi_ec_mode == EC_INTR) { 641 atomic_set(&ec->leaving_burst, 1); 642 init_waitqueue_head(&ec->wait); ··· 812 acpi_status status; 813 814 mutex_init(&ec_ecdt->lock); 815 if (acpi_ec_mode == EC_INTR) { 816 init_waitqueue_head(&ec_ecdt->wait); 817 } ··· 894 return -ENOMEM; 895 896 mutex_init(&ec_ecdt->lock); 897 if (acpi_ec_mode == EC_INTR) { 898 init_waitqueue_head(&ec_ecdt->wait); 899 } ··· 1023 acpi_ec_mode = EC_POLL; 1024 } 1025 acpi_ec_driver.ops.add = acpi_ec_add; 1026 - printk(KERN_NOTICE PREFIX "%s mode.\n", 1027 - intr ? "interrupt" : "polling"); 1028 1029 return 1; 1030 }
··· 100 unsigned long global_lock; 101 struct mutex lock; 102 atomic_t query_pending; 103 + atomic_t event_count; 104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */ 105 wait_queue_head_t wait; 106 } *ec_ecdt; ··· 131 outb(data, ec->data_addr); 132 } 133 134 + static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event, 135 + unsigned old_count) 136 { 137 u8 status = acpi_ec_read_status(ec); 138 + if (old_count == atomic_read(&ec->event_count)) 139 + return 0; 140 if (event == ACPI_EC_EVENT_OBF_1) { 141 if (status & ACPI_EC_FLAG_OBF) 142 return 1; ··· 146 return 0; 147 } 148 149 + static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, unsigned count) 150 { 151 if (acpi_ec_mode == EC_POLL) { 152 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY); 153 while (time_before(jiffies, delay)) { 154 + if (acpi_ec_check_status(ec, event, 0)) 155 return 0; 156 } 157 } else { 158 if (wait_event_timeout(ec->wait, 159 + acpi_ec_check_status(ec, event, count), 160 msecs_to_jiffies(ACPI_EC_DELAY)) || 161 + acpi_ec_check_status(ec, event, 0)) { 162 return 0; 163 } else { 164 printk(KERN_ERR PREFIX "acpi_ec_wait timeout," ··· 225 u8 * rdata, unsigned rdata_len) 226 { 227 int result = 0; 228 + unsigned count = atomic_read(&ec->event_count); 229 acpi_ec_write_cmd(ec, command); 230 231 for (; wdata_len > 0; --wdata_len) { 232 + result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count); 233 if (result) { 234 printk(KERN_ERR PREFIX 235 "write_cmd timeout, command = %d\n", command); 236 goto end; 237 } 238 + count = atomic_read(&ec->event_count); 239 acpi_ec_write_data(ec, *(wdata++)); 240 } 241 242 if (!rdata_len) { 243 + result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, count); 244 if (result) { 245 printk(KERN_ERR PREFIX 246 "finish-write timeout, command = %d\n", command); ··· 250 } 251 252 for (; rdata_len > 0; --rdata_len) { 253 + result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, count); 254 if (result) { 255 printk(KERN_ERR PREFIX "read timeout, command = %d\n", 256 command); 257 goto end; 258 } 259 + count = atomic_read(&ec->event_count); 260 *(rdata++) = acpi_ec_read_data(ec); 261 } 262 end: ··· 288 /* Make sure GPE is enabled before doing transaction */ 289 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR); 290 291 + status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0); 292 if (status) { 293 printk(KERN_DEBUG PREFIX 294 "input buffer is not empty, aborting transaction\n"); ··· 369 EXPORT_SYMBOL(ec_write); 370 371 int ec_transaction(u8 command, 372 + const u8 * wdata, unsigned wdata_len, 373 + u8 * rdata, unsigned rdata_len) 374 { 375 struct acpi_ec *ec; 376 ··· 435 acpi_status status = AE_OK; 436 u8 value; 437 struct acpi_ec *ec = (struct acpi_ec *)data; 438 + atomic_inc(&ec->event_count); 439 if (acpi_ec_mode == EC_INTR) { 440 wake_up(&ec->wait); 441 } ··· 633 ec->uid = -1; 634 mutex_init(&ec->lock); 635 atomic_set(&ec->query_pending, 0); 636 + atomic_set(&ec->event_count, 1); 637 if (acpi_ec_mode == EC_INTR) { 638 atomic_set(&ec->leaving_burst, 1); 639 init_waitqueue_head(&ec->wait); ··· 807 acpi_status status; 808 809 mutex_init(&ec_ecdt->lock); 810 + atomic_set(&ec_ecdt->event_count, 1); 811 if (acpi_ec_mode == EC_INTR) { 812 init_waitqueue_head(&ec_ecdt->wait); 813 } ··· 888 return -ENOMEM; 889 890 mutex_init(&ec_ecdt->lock); 891 + atomic_set(&ec_ecdt->event_count, 1); 892 if (acpi_ec_mode == EC_INTR) { 893 init_waitqueue_head(&ec_ecdt->wait); 894 } ··· 1016 acpi_ec_mode = EC_POLL; 1017 } 1018 acpi_ec_driver.ops.add = acpi_ec_add; 1019 + printk(KERN_NOTICE PREFIX "%s mode.\n", intr ? "interrupt" : "polling"); 1020 1021 return 1; 1022 }