SUMMARY: Many potential crashes when unplugging the camera while it's in use are fixed. OV7620/OV7120 greyscale mode is fixed too. PER-FILE CHANGES: (+: New, -: Removed, *: Cleanup, @: Bugfix, =: Sync with kernel) [ov511.c] @ Fix race condition: close() and disconnect() could be called at the same time causing a double-free of struct usb_ov511 @ Prevent synchronous control messages from being sent after their transfer buffer is deallocated + Prevent bogus I2C error messages during device detection * Get rid of some unnecessary checks for !ov and !ov->dev. The checks were already performed after taking ov->lock further up the call stack. + Add some checks for !ov->dev in open() and elsewhere * Remove unnecessary calls to ov51x_dealloc() in close() and disconnect() @ Return -ENODEV instead of -EIO if device was disconnected @ In cases where the driver sleeps under ov->lock, check for !ov->present instead of !ov->dev after waking up. This is because ov->dev can't go NULL while ov->lock is taken, since that would make lots of other code unsafe. * Consolidate I2C detection code into ovsensor_probe() @ Remove unnecessary call to destroy_proc_ov511_cam() in probe() error path [ov511.h] + Add struct usb_ov511.present [ov7x20.c] @ Fix greyscale mode: don't put sensor into 8-bit mode [ovfx2.c] - Get rid of some more leftovers from ov511.c @ Fix race condition: close() and disconnect() could be called at the same time causing a double-free of struct usb_ovfx2 @ Prevent synchronous control messages from being sent after their transfer buffer is deallocated. This requires taking ov->cbuf_lock as a barrier against disconnect() finishing even in places where cbuf isn't actually used. + Prevent bogus I2C error messages during device detection * Get rid of some unnecessary checks for !ov and !ov->dev. The checks were already performed after taking ov->lock further up the call stack. - Remove unused interleave() functions, since they turned out to be unnecessary + Add some checks for !ov->dev in open() and elsewhere * Remove unnecessary calls to ovfx2_dealloc() in close() and disconnect() @ Return -ENODEV instead of -EIO if device was disconnected @ In cases where the driver sleeps under ov->lock, check for !ov->present instead of !ov->dev after waking up. This is because ov->dev can't go NULL while ov->lock is taken, since that would make lots of other code unsafe. * Consolidate I2C detection code into ovsensor_probe(). This is a simplified version of ovsensor_probe() from ov511.c [ovsensor.c] @ Set state before calling schedule_timeout() to prevent busy-looping