Only call disconnect hook when device is enabled and the hook is not NULL.

This fixes bug 542.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18675 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen
2006-08-28 20:17:33 +00:00
parent ffe8b39144
commit 92fdfb1106
2 changed files with 5 additions and 3 deletions
@@ -87,7 +87,9 @@ ps2_dev_unpublish(ps2_dev *dev)
dev->active = false;
status = devfs_unpublish_device(dev->name, true);
dev->disconnect(dev);
if ((dev->flags & PS2_FLAG_ENABLED) && dev->disconnect)
dev->disconnect(dev);
dprintf("ps2: devfs_unpublish_device %s, status = 0x%08lx\n", dev->name, status);
}
@@ -239,12 +239,12 @@ keyboard_open(const char *name, uint32 flags, void **_cookie)
goto err2;
}
atomic_or(&ps2_device[PS2_DEVICE_KEYB].flags, PS2_FLAG_ENABLED);
*_cookie = NULL;
ps2_device[PS2_DEVICE_KEYB].disconnect = &ps2_keyboard_disconnect;
ps2_device[PS2_DEVICE_KEYB].handle_int = &keyboard_handle_int;
atomic_or(&ps2_device[PS2_DEVICE_KEYB].flags, PS2_FLAG_ENABLED);
dprintf("ps2: keyboard_open %s success\n", name);
return B_OK;