patch-2.3.43 linux/drivers/macintosh/adb.c
Next file: linux/drivers/macintosh/mac_keyb.c
Previous file: linux/drivers/macintosh/Makefile
Back to the patch index
Back to the overall index
- Lines: 129
- Date:
Wed Feb 9 19:43:57 2000
- Orig file:
v2.3.42/linux/drivers/macintosh/adb.c
- Orig date:
Sat Oct 9 11:47:50 1999
diff -u --recursive --new-file v2.3.42/linux/drivers/macintosh/adb.c linux/drivers/macintosh/adb.c
@@ -247,6 +247,8 @@
switch (when) {
case PBOOK_SLEEP_REQUEST:
adb_got_sleep = 1;
+ if (adb_controller->autopoll)
+ adb_controller->autopoll(0);
ret = notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL);
if (ret & NOTIFY_STOP_MASK)
return PBOOK_SLEEP_REFUSE;
@@ -262,6 +264,7 @@
break;
case PBOOK_WAKE:
adb_reset_bus();
+ adb_got_sleep = 0;
break;
}
return PBOOK_SLEEP_OK;
@@ -271,15 +274,21 @@
int
adb_reset_bus(void)
{
- int ret, devs;
+ int ret, nret, devs;
unsigned long flags;
if (adb_controller == NULL)
return -ENXIO;
- ret = notifier_call_chain(&adb_client_list, ADB_MSG_PRE_RESET, NULL);
- if (ret & NOTIFY_STOP_MASK)
+ if (adb_controller->autopoll)
+ adb_controller->autopoll(0);
+
+ nret = notifier_call_chain(&adb_client_list, ADB_MSG_PRE_RESET, NULL);
+ if (nret & NOTIFY_STOP_MASK) {
+ if (adb_controller->autopoll)
+ adb_controller->autopoll(devs);
return -EBUSY;
+ }
save_flags(flags);
cli();
@@ -291,18 +300,17 @@
else
ret = 0;
- if (!ret)
- {
+ if (!ret) {
devs = adb_scan_bus();
if (adb_controller->autopoll)
adb_controller->autopoll(devs);
}
- ret = notifier_call_chain(&adb_client_list, ADB_MSG_POST_RESET, NULL);
- if (ret & NOTIFY_STOP_MASK)
+ nret = notifier_call_chain(&adb_client_list, ADB_MSG_POST_RESET, NULL);
+ if (nret & NOTIFY_STOP_MASK)
return -EBUSY;
- return 1;
+ return ret;
}
void
@@ -383,6 +391,12 @@
int i, id;
static int dump_adb_input = 0;
+ /* We skip keystrokes and mouse moves when the sleep process
+ * has been started. We stop autopoll, but this is another security
+ */
+ if (adb_got_sleep)
+ return;
+
id = buf[0] >> 4;
if (dump_adb_input) {
printk(KERN_INFO "adb packet: ");
@@ -403,12 +417,8 @@
if (adb_handler[address].handler_id == new_id)
return 1;
- adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1,
- ADB_READREG(address,3));
- if (req.reply_len < 2)
- return 0;
adb_request(&req, NULL, ADBREQ_SYNC, 3,
- ADB_WRITEREG(address, 3), req.reply[1] & 0xF0, new_id);
+ ADB_WRITEREG(address, 3), address | 0x20, new_id);
adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1,
ADB_READREG(address, 3));
if (req.reply_len < 2)
@@ -611,10 +621,11 @@
/* Special case for ADB_BUSRESET request, all others are sent to
the controller */
if ((req->data[0] == ADB_PACKET)&&(count > 1)
- &&(req->data[1] == ADB_BUSRESET))
+ &&(req->data[1] == ADB_BUSRESET)) {
ret = adb_reset_bus();
- else
- {
+ atomic_dec(&state->n_pending);
+ goto out;
+ } else {
req->reply_expected = ((req->data[1] & 0xc) == 0xc);
if (adb_controller && adb_controller->send_request)
@@ -635,16 +646,11 @@
}
static struct file_operations adb_fops = {
- adb_lseek,
- adb_read,
- adb_write,
- NULL, /* no readdir */
- NULL, /* no poll yet */
- NULL, /* no ioctl yet */
- NULL, /* no mmap */
- adb_open,
- NULL, /* flush */
- adb_release
+ llseek: adb_lseek,
+ read: adb_read,
+ write: adb_write,
+ open: adb_open,
+ release: adb_release,
};
void adbdev_init()
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)