Merge "Fix failure to open AVRCP input device due to EPERM." into eclair
This commit is contained in:
@@ -489,6 +489,7 @@ int EventHub::open_device(const char *deviceName)
|
|||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
int fd;
|
int fd;
|
||||||
|
int attempt;
|
||||||
struct pollfd *new_mFDs;
|
struct pollfd *new_mFDs;
|
||||||
device_t **new_devices;
|
device_t **new_devices;
|
||||||
char **new_device_names;
|
char **new_device_names;
|
||||||
@@ -500,12 +501,17 @@ int EventHub::open_device(const char *deviceName)
|
|||||||
LOGV("Opening device: %s", deviceName);
|
LOGV("Opening device: %s", deviceName);
|
||||||
|
|
||||||
AutoMutex _l(mLock);
|
AutoMutex _l(mLock);
|
||||||
|
|
||||||
fd = open(deviceName, O_RDWR);
|
for (attempt = 0; attempt < 10; attempt++) {
|
||||||
|
fd = open(deviceName, O_RDWR);
|
||||||
|
if (fd >= 0) break;
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
LOGE("could not open %s, %s\n", deviceName, strerror(errno));
|
LOGE("could not open %s, %s\n", deviceName, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
LOGV("Opened device: %s (%d failures)", deviceName, attempt);
|
||||||
|
|
||||||
if(ioctl(fd, EVIOCGVERSION, &version)) {
|
if(ioctl(fd, EVIOCGVERSION, &version)) {
|
||||||
LOGE("could not get driver version for %s, %s\n", deviceName, strerror(errno));
|
LOGE("could not get driver version for %s, %s\n", deviceName, strerror(errno));
|
||||||
|
|||||||
Reference in New Issue
Block a user