[Pcsclite-cvs-commit] r4239 - /trunk/PCSC/src/hotplug_libhal.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jun 2 13:32:53 UTC 2009
Author: rousseau
Date: Tue Jun 2 13:32:53 2009
New Revision: 4239
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4239
Log:
if RFAddReader() fails with the libhal scheme then we try with the
(old) libusb scheme.
This patch should allow proprietary drivers to work even if pcsc-lite is
compiled with libhal support.
Modified:
trunk/PCSC/src/hotplug_libhal.c
Modified: trunk/PCSC/src/hotplug_libhal.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/hotplug_libhal.c?rev=4239&op=diff
==============================================================================
--- trunk/PCSC/src/hotplug_libhal.c (original)
+++ trunk/PCSC/src/hotplug_libhal.c Tue Jun 2 13:32:53 2009
@@ -394,13 +394,51 @@
driver->libraryPath, deviceName);
if (SCARD_S_SUCCESS != ret)
{
- Log2(PCSC_LOG_ERROR, "Failed adding USB device: %s", short_name(udi));
- free(readerTracker[i].fullName);
- readerTracker[i].fullName = NULL;
- free(readerTracker[i].udi);
- readerTracker[i].udi = NULL;
-
- (void)CheckForOpenCT();
+ char *parent, *device_file;
+
+ /* get the parent descriptor, without the '_if0' */
+ parent = libhal_device_get_property_string(ctx, udi,
+ "info.parent", NULL);
+ if (! parent)
+ goto error;
+
+ /* get the linux device file: i.e. '/dev/bus/usb/002/012' */
+ device_file = libhal_device_get_property_string(ctx, parent,
+ "linux.device_file", NULL);
+ if (! device_file)
+ goto error;
+
+ /* check the format looks correct */
+#define LIBUSB_HEADER "/dev/bus/usb/"
+ if (strncmp(device_file, LIBUSB_HEADER, strlen(LIBUSB_HEADER)))
+ goto error;
+
+ device_file += strlen(LIBUSB_HEADER);
+
+ (void)snprintf(deviceName, sizeof(deviceName),
+ "usb:%04x/%04x:libusb:%s",
+ driver->manuID, driver->productID, device_file);
+ deviceName[sizeof(deviceName) -1] = '\0';
+
+ /* replace the libusb separator '/' by ':' */
+ if ('/' == deviceName[strlen(deviceName)-3-1])
+ deviceName[strlen(deviceName)-3-1] = ':';
+
+ Log2(PCSC_LOG_INFO, "trying libusb scheme with: %s", deviceName);
+ ret = RFAddReader(readerTracker[i].fullName, PCSCLITE_HP_BASE_PORT + i,
+ driver->libraryPath, deviceName);
+
+ if (SCARD_S_SUCCESS != ret)
+ {
+error:
+ Log2(PCSC_LOG_ERROR, "Failed adding USB device: %s", short_name(udi));
+ free(readerTracker[i].fullName);
+ readerTracker[i].fullName = NULL;
+ free(readerTracker[i].udi);
+ readerTracker[i].udi = NULL;
+
+ (void)CheckForOpenCT();
+ }
}
(void)SYS_MutexUnLock(&usbNotifierMutex);
More information about the Pcsclite-cvs-commit
mailing list