Lines 89-95
Link Here
|
89 |
static int autopoll_devs; |
89 |
static int autopoll_devs; |
90 |
int __adb_probe_sync; |
90 |
int __adb_probe_sync; |
91 |
|
91 |
|
92 |
#ifdef CONFIG_PM |
92 |
#ifdef CONFIG_PM && CONFIG_ADB_PMU |
93 |
static int adb_notify_sleep(struct pmu_sleep_notifier *self, int when); |
93 |
static int adb_notify_sleep(struct pmu_sleep_notifier *self, int when); |
94 |
static struct pmu_sleep_notifier adb_sleep_notifier = { |
94 |
static struct pmu_sleep_notifier adb_sleep_notifier = { |
95 |
adb_notify_sleep, |
95 |
adb_notify_sleep, |
Lines 149-155
Link Here
|
149 |
int i, highFree=0, noMovement; |
149 |
int i, highFree=0, noMovement; |
150 |
int devmask = 0; |
150 |
int devmask = 0; |
151 |
struct adb_request req; |
151 |
struct adb_request req; |
152 |
|
152 |
|
153 |
/* assumes adb_handler[] is all zeroes at this point */ |
153 |
/* assumes adb_handler[] is all zeroes at this point */ |
154 |
for (i = 1; i < 16; i++) { |
154 |
for (i = 1; i < 16; i++) { |
155 |
/* see if there is anything at address i */ |
155 |
/* see if there is anything at address i */ |
Lines 222-228
Link Here
|
222 |
(highFree << 4) | 0xb, |
222 |
(highFree << 4) | 0xb, |
223 |
(i | 0x60), 0xfe); |
223 |
(i | 0x60), 0xfe); |
224 |
} |
224 |
} |
225 |
} |
225 |
} |
226 |
} |
226 |
} |
227 |
|
227 |
|
228 |
/* Now fill in the handler_id field of the adb_handler entries. */ |
228 |
/* Now fill in the handler_id field of the adb_handler entries. */ |
Lines 259-268
Link Here
|
259 |
printk(KERN_INFO "adb: starting probe task...\n"); |
259 |
printk(KERN_INFO "adb: starting probe task...\n"); |
260 |
do_adb_reset_bus(); |
260 |
do_adb_reset_bus(); |
261 |
printk(KERN_INFO "adb: finished probe task...\n"); |
261 |
printk(KERN_INFO "adb: finished probe task...\n"); |
262 |
|
262 |
|
263 |
adb_probe_task_pid = 0; |
263 |
adb_probe_task_pid = 0; |
264 |
up(&adb_probe_mutex); |
264 |
up(&adb_probe_mutex); |
265 |
|
265 |
|
266 |
return 0; |
266 |
return 0; |
267 |
} |
267 |
} |
268 |
|
268 |
|
Lines 305-311
Link Here
|
305 |
if (adb_inited) |
305 |
if (adb_inited) |
306 |
return 0; |
306 |
return 0; |
307 |
adb_inited = 1; |
307 |
adb_inited = 1; |
308 |
|
308 |
|
309 |
adb_controller = NULL; |
309 |
adb_controller = NULL; |
310 |
|
310 |
|
311 |
i = 0; |
311 |
i = 0; |
Lines 319-325
Link Here
|
319 |
printk(KERN_WARNING "Warning: no ADB interface detected\n"); |
319 |
printk(KERN_WARNING "Warning: no ADB interface detected\n"); |
320 |
adb_controller = NULL; |
320 |
adb_controller = NULL; |
321 |
} else { |
321 |
} else { |
322 |
#ifdef CONFIG_PM |
322 |
#ifdef CONFIG_PM && CONFIG_ADB_PMU |
323 |
pmu_register_sleep_notifier(&adb_sleep_notifier); |
323 |
pmu_register_sleep_notifier(&adb_sleep_notifier); |
324 |
#endif /* CONFIG_PM */ |
324 |
#endif /* CONFIG_PM */ |
325 |
#ifdef CONFIG_PPC |
325 |
#ifdef CONFIG_PPC |
Lines 336-342
Link Here
|
336 |
|
336 |
|
337 |
__initcall(adb_init); |
337 |
__initcall(adb_init); |
338 |
|
338 |
|
339 |
#ifdef CONFIG_PM |
339 |
#ifdef CONFIG_PM && CONFIG_ADB_PMU |
340 |
/* |
340 |
/* |
341 |
* notify clients before sleep and reset bus afterwards |
341 |
* notify clients before sleep and reset bus afterwards |
342 |
*/ |
342 |
*/ |
Lines 344-350
Link Here
|
344 |
adb_notify_sleep(struct pmu_sleep_notifier *self, int when) |
344 |
adb_notify_sleep(struct pmu_sleep_notifier *self, int when) |
345 |
{ |
345 |
{ |
346 |
int ret; |
346 |
int ret; |
347 |
|
347 |
|
348 |
switch (when) { |
348 |
switch (when) { |
349 |
case PBOOK_SLEEP_REQUEST: |
349 |
case PBOOK_SLEEP_REQUEST: |
350 |
adb_got_sleep = 1; |
350 |
adb_got_sleep = 1; |
Lines 367-373
Link Here
|
367 |
adb_reset_bus(); |
367 |
adb_reset_bus(); |
368 |
} |
368 |
} |
369 |
break; |
369 |
break; |
370 |
|
370 |
|
371 |
case PBOOK_SLEEP_NOW: |
371 |
case PBOOK_SLEEP_NOW: |
372 |
break; |
372 |
break; |
373 |
case PBOOK_WAKE: |
373 |
case PBOOK_WAKE: |
Lines 384-393
Link Here
|
384 |
do_adb_reset_bus(void) |
384 |
do_adb_reset_bus(void) |
385 |
{ |
385 |
{ |
386 |
int ret, nret; |
386 |
int ret, nret; |
387 |
|
387 |
|
388 |
if (adb_controller == NULL) |
388 |
if (adb_controller == NULL) |
389 |
return -ENXIO; |
389 |
return -ENXIO; |
390 |
|
390 |
|
391 |
if (adb_controller->autopoll) |
391 |
if (adb_controller->autopoll) |
392 |
adb_controller->autopoll(0); |
392 |
adb_controller->autopoll(0); |
393 |
|
393 |
|
Lines 431-437
Link Here
|
431 |
ADB_MSG_POST_RESET, NULL); |
431 |
ADB_MSG_POST_RESET, NULL); |
432 |
if (nret & NOTIFY_STOP_MASK) |
432 |
if (nret & NOTIFY_STOP_MASK) |
433 |
return -EBUSY; |
433 |
return -EBUSY; |
434 |
|
434 |
|
435 |
return ret; |
435 |
return ret; |
436 |
} |
436 |
} |
437 |
|
437 |
|
Lines 451-457
Link Here
|
451 |
|
451 |
|
452 |
/* Static request used during probe */ |
452 |
/* Static request used during probe */ |
453 |
static struct adb_request adb_sreq; |
453 |
static struct adb_request adb_sreq; |
454 |
static unsigned long adb_sreq_lock; // Use semaphore ! */ |
454 |
static unsigned long adb_sreq_lock; // Use semaphore ! */ |
455 |
|
455 |
|
456 |
int |
456 |
int |
457 |
adb_request(struct adb_request *req, void (*done)(struct adb_request *), |
457 |
adb_request(struct adb_request *req, void (*done)(struct adb_request *), |
Lines 467-473
Link Here
|
467 |
return -EINVAL; |
467 |
return -EINVAL; |
468 |
if (req == NULL && (flags & ADBREQ_NOSEND)) |
468 |
if (req == NULL && (flags & ADBREQ_NOSEND)) |
469 |
return -EINVAL; |
469 |
return -EINVAL; |
470 |
|
470 |
|
471 |
if (req == NULL) { |
471 |
if (req == NULL) { |
472 |
if (test_and_set_bit(0,&adb_sreq_lock)) { |
472 |
if (test_and_set_bit(0,&adb_sreq_lock)) { |
473 |
printk("adb.c: Warning: contention on static request !\n"); |
473 |
printk("adb.c: Warning: contention on static request !\n"); |
Lines 530-536
Link Here
|
530 |
ids->nids = 0; |
530 |
ids->nids = 0; |
531 |
for (i = 1; i < 16; i++) { |
531 |
for (i = 1; i < 16; i++) { |
532 |
if ((adb_handler[i].original_address == default_id) && |
532 |
if ((adb_handler[i].original_address == default_id) && |
533 |
(!handler_id || (handler_id == adb_handler[i].handler_id) || |
533 |
(!handler_id || (handler_id == adb_handler[i].handler_id) || |
534 |
try_handler_change(i, handler_id))) { |
534 |
try_handler_change(i, handler_id))) { |
535 |
if (adb_handler[i].handler != 0) { |
535 |
if (adb_handler[i].handler != 0) { |
536 |
printk(KERN_ERR |
536 |
printk(KERN_ERR |
Lines 575-581
Link Here
|
575 |
int i, id; |
575 |
int i, id; |
576 |
static int dump_adb_input = 0; |
576 |
static int dump_adb_input = 0; |
577 |
unsigned long flags; |
577 |
unsigned long flags; |
578 |
|
578 |
|
579 |
void (*handler)(unsigned char *, int, int); |
579 |
void (*handler)(unsigned char *, int, int); |
580 |
|
580 |
|
581 |
/* We skip keystrokes and mouse moves when the sleep process |
581 |
/* We skip keystrokes and mouse moves when the sleep process |
Lines 583-589
Link Here
|
583 |
*/ |
583 |
*/ |
584 |
if (adb_got_sleep) |
584 |
if (adb_got_sleep) |
585 |
return; |
585 |
return; |
586 |
|
586 |
|
587 |
id = buf[0] >> 4; |
587 |
id = buf[0] >> 4; |
588 |
if (dump_adb_input) { |
588 |
if (dump_adb_input) { |
589 |
printk(KERN_INFO "adb packet: "); |
589 |
printk(KERN_INFO "adb packet: "); |
Lines 601-607
Link Here
|
601 |
wmb(); |
601 |
wmb(); |
602 |
adb_handler[id].busy = 0; |
602 |
adb_handler[id].busy = 0; |
603 |
} |
603 |
} |
604 |
|
604 |
|
605 |
} |
605 |
} |
606 |
|
606 |
|
607 |
/* Try to change handler to new_id. Will return 1 if successful. */ |
607 |
/* Try to change handler to new_id. Will return 1 if successful. */ |
Lines 783-789
Link Here
|
783 |
ret = -EIO; |
783 |
ret = -EIO; |
784 |
if (req != NULL || ret != 0) |
784 |
if (req != NULL || ret != 0) |
785 |
break; |
785 |
break; |
786 |
|
786 |
|
787 |
if (file->f_flags & O_NONBLOCK) { |
787 |
if (file->f_flags & O_NONBLOCK) { |
788 |
ret = -EAGAIN; |
788 |
ret = -EAGAIN; |
789 |
break; |
789 |
break; |
Lines 800-806
Link Here
|
800 |
current->state = TASK_RUNNING; |
800 |
current->state = TASK_RUNNING; |
801 |
remove_wait_queue(&state->wait_queue, &wait); |
801 |
remove_wait_queue(&state->wait_queue, &wait); |
802 |
spin_unlock_irqrestore(&state->lock, flags); |
802 |
spin_unlock_irqrestore(&state->lock, flags); |
803 |
|
803 |
|
804 |
if (ret) |
804 |
if (ret) |
805 |
return ret; |
805 |
return ret; |
806 |
|
806 |
|
Lines 837-843
Link Here
|
837 |
req->done = adb_write_done; |
837 |
req->done = adb_write_done; |
838 |
req->arg = (void *) state; |
838 |
req->arg = (void *) state; |
839 |
req->complete = 0; |
839 |
req->complete = 0; |
840 |
|
840 |
|
841 |
ret = -EFAULT; |
841 |
ret = -EFAULT; |
842 |
if (copy_from_user(req->data, buf, count)) |
842 |
if (copy_from_user(req->data, buf, count)) |
843 |
goto out; |
843 |
goto out; |
Lines 865-871
Link Here
|
865 |
if (ret == 0) |
865 |
if (ret == 0) |
866 |
ret = count; |
866 |
ret = count; |
867 |
goto out; |
867 |
goto out; |
868 |
} else { |
868 |
} else { |
869 |
req->reply_expected = ((req->data[1] & 0xc) == 0xc); |
869 |
req->reply_expected = ((req->data[1] & 0xc) == 0xc); |
870 |
if (adb_controller && adb_controller->send_request) |
870 |
if (adb_controller && adb_controller->send_request) |
871 |
ret = adb_controller->send_request(req, 0); |
871 |
ret = adb_controller->send_request(req, 0); |