From a47ceb2aecc097943a4504cc4af800c479240ea5 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 22 Jun 2008 13:30:56 +0000 Subject: [PATCH] * Only set the select hook on the device module if we actually got a select hook from the legacy driver. * Add note explaining why it is set to an arbitrary invalid value (~0) and why it still works by redirecting in the virtual Select() of LegacyDevice. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26079 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/device_manager/legacy_drivers.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp b/src/system/kernel/device_manager/legacy_drivers.cpp index 304c229d2d..80e75248b5 100644 --- a/src/system/kernel/device_manager/legacy_drivers.cpp +++ b/src/system/kernel/device_manager/legacy_drivers.cpp @@ -1229,7 +1229,16 @@ LegacyDevice::SetHooks(device_hooks* hooks) // According to Be newsletter, vol II, issue 36, // version 2 added readv/writev, which we don't support, but also // select/deselect. - fDeviceModule->select = (status_t (*)(void*, uint8, selectsync*))~0; + if (hooks->select != NULL) { + // Note we set the module's select to a non-null value to indicate + // that we have select. HasSelect() will therefore return the + // correct answer. As Select() is virtual our compatibility + // version below is going to be called though, that redirects to + // the proper select hook, so it is ok to set it to an invalid + // address here. + fDeviceModule->select = (status_t (*)(void*, uint8, selectsync*))~0; + } + fDeviceModule->deselect = hooks->deselect; } }