fix forced redetect of cards

This commit is contained in:
Chris Danford
2004-06-06 18:39:40 +00:00
parent 9d2c6d078a
commit 8eb7550bf4
@@ -128,9 +128,10 @@ MemoryCardDriverThreaded_Linux::MemoryCardDriverThreaded_Linux()
{ {
m_fd = open(USB_DEVICE_LIST_FILE, O_RDONLY); m_fd = open(USB_DEVICE_LIST_FILE, O_RDONLY);
if( m_fd == -1 ) if( m_fd == -1 )
{
LOG->Warn( "Failed to open \"%s\": %s", USB_DEVICE_LIST_FILE, strerror(errno) ); LOG->Warn( "Failed to open \"%s\": %s", USB_DEVICE_LIST_FILE, strerror(errno) );
}
m_bForceRedetect = false;
this->StartThread(); this->StartThread();
} }
@@ -155,7 +156,8 @@ void MemoryCardDriverThreaded_Linux::MountThreadReset()
ExecuteCommand( "rmmod usb-storage" ); ExecuteCommand( "rmmod usb-storage" );
ExecuteCommand( "modprobe usb-storage" ); ExecuteCommand( "modprobe usb-storage" );
m_vDevicesLastSeen.clear(); // redetect all devices m_vDevicesLastSeen.clear();
m_bForceRedetect = true;
} }
void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate() void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
@@ -163,6 +165,12 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
if( m_fd == -1 ) if( m_fd == -1 )
return; return;
if( m_bForceRedetect )
{
// fall through
}
else
{
pollfd pfd = { m_fd, POLLIN, 0 }; pollfd pfd = { m_fd, POLLIN, 0 };
int ret = poll( &pfd, 1, 100 ); int ret = poll( &pfd, 1, 100 );
switch( ret ) switch( ret )
@@ -177,6 +185,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
LOG->Warn( "Error polling: %s", strerror(errno) ); LOG->Warn( "Error polling: %s", strerror(errno) );
return; return;
} }
}
// TRICKY: We're waiting for a change in the USB device list, but // TRICKY: We're waiting for a change in the USB device list, but
// the usb-storage descriptors take a bit longer to update. It's more convenient to wait // the usb-storage descriptors take a bit longer to update. It's more convenient to wait